PropertyChangeSupport
을 확장하는 클래스를 만들고 있습니다. 그것이 의해 PropertyChangeSupport에서 구현으로하위 클래스의 비공개 필드에 액세스
firePropertyChange을 :
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
firePropertyChange(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
}
}
firePropertyChange
의 내 구성 재정의 :
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
if (oldValue == null || newValue == null || !oldValue.equals(newValue)) {
firePropertyChange(new JoystickPropertyChangeEvent(this.source, propertyName, oldValue, newValue)); //compile error: source is not visible
}
}
JoystickPropertyChangeEvent
내가 만든 클래스이며, 내가 현재하고 싶은 firePropertyChange()
를 오버라이드 (override)입니다 확장하여 ProperyChangeEvent
입니다.
소스가 비공개이고 PropertyChangeSupport
에 getters
이 없으므로 의도 한 구현이 컴파일되지 않으므로 하위 클래스에 액세스 할 수 없습니다. PropertyChangeSupport
의 코드를 수정할 수 없습니다.
소스의 복사본을 내 서브 클래스의 필드로 사용하는 것보다 더 우아한 해결책이 있습니까?
관련 질문 : How to access the private variables of a class in its subclass?
나는 네가 완벽하다고 생각한다. – deinocheirus