📄 binding.java
字号:
}
/**
* Sets the {@code Binding's} target property.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "targetProperty"} when the value of
* this property changes.
* <p>
* This method may not be called on a bound binding.
*
* @param targetProperty the target property
* @throws IllegalArgumentException if the target property is {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isBound()
*/
protected final void setTargetProperty(Property<TS, TV> targetProperty) {
throwIfBound();
if (targetProperty == null) {
throw new IllegalArgumentException("target property can't be null");
}
Property<TS, TV> old = this.targetProperty;
this.targetProperty = targetProperty;
firePropertyChange("targetProperty", old, targetProperty);
}
/**
* Returns the {@code Binding's} name, which may be {@code null}.
*
* @return the {@code Binding's} name, or {@code null}
*/
public final String getName() {
return name;
}
/**
* Returns the {@code Binding's} source property, which may not be {@code null}.
*
* @return the {@code Binding's} source property, {@code non-null}
* @see #setSourceProperty
*/
public final Property<SS, SV> getSourceProperty() {
return sourceProperty;
}
/**
* Returns the {@code Binding's} target property, which may not be {@code null}.
*
* @return the {@code Binding's} target property, {@code non-null}
* @see #setTargetProperty
*/
public final Property<TS, TV> getTargetProperty() {
return targetProperty;
}
/**
* Returns the {@code Binding's} source object, which may be {@code null}.
*
* @return the {@code Binding's} source object, or {@code null}
* @see #setSourceObject
*/
public final SS getSourceObject() {
return sourceObject;
}
/**
* Returns the {@code Binding's} target object, which may be {@code null}.
*
* @return the {@code Binding's} target object, or {@code null}
* @see #setTargetObject
*/
public final TS getTargetObject() {
return targetObject;
}
/**
* Sets the {@code Binding's} source object, which may be {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "sourceObject"} when the value of
* this property changes.
* <p>
* This method may not be called on a managed or bound binding.
*
* @param sourceObject the source object, or {@code null}
* @throws UnsupportedOperationException if the {@code Binding} is managed
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isManaged()
* @see #isBound()
*/
public final void setSourceObject(SS sourceObject) {
throwIfManaged();
setSourceObjectUnmanaged(sourceObject);
}
/**
* A protected version of {@link #setSourceObject} that allows managed
* subclasses to set the source object without throwing an exception
* for being managed.
*
* @param sourceObject the source object, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isManaged()
* @see #isBound()
*/
protected final void setSourceObjectUnmanaged(SS sourceObject) {
throwIfBound();
SS old = this.sourceObject;
this.sourceObject = sourceObject;
firePropertyChange("sourceObject", old, sourceObject);
}
/**
* Sets the {@code Binding's} target object, which may be {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "targetObject"} when the value of
* this property changes.
* <p>
* This method may not be called on a managed or bound binding.
*
* @param targetObject the target object, or {@code null}
* @throws UnsupportedOperationException if the {@code Binding} is managed
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isManaged()
* @see #isBound()
*/
public final void setTargetObject(TS targetObject) {
throwIfManaged();
setTargetObjectUnmanaged(targetObject);
}
/**
* A protected version of {@link #setTargetObject} that allows managed
* subclasses to set the target object without throwing an exception
* for being managed.
*
* @param targetObject the target object, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isManaged()
* @see #isBound()
*/
protected final void setTargetObjectUnmanaged(TS targetObject) {
throwIfBound();
TS old = this.targetObject;
this.targetObject = targetObject;
firePropertyChange("targetObject", old, targetObject);
}
/**
* Sets the {@code Validator} for the {@code Binding}, which may be {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "validator"} when the value of
* this property changes.
* <p>
* This method may not be called on a bound binding.
* <p>
* See the documentation on {@link #getTargetValueForSource} for details on how
* a {@code Binding's Validator} is used.
*
* @param validator the {@code Validator}, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isBound()
*/
public final void setValidator(Validator<? super SV> validator) {
throwIfBound();
Validator<? super SV> old = this.validator;
this.validator = validator;
firePropertyChange("validator", old, validator);
}
/**
* Returns the {@code Binding's Validator}, which may be {@code null}.
*
* @return the {@code Binding's Validator}, or {@code null}
* @see #setValidator
*/
public final Validator<? super SV> getValidator() {
return validator;
}
/**
* Sets the {@code Converter} for the {@code Binding}, which may be {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "converter"} when the value of
* this property changes.
* <p>
* This method may not be called on a bound binding.
* <p>
* See the documentation on {@link #getTargetValueForSource} and
* {@link #getSourceValueForTarget} for details on how
* a {@code Binding's Converter} is used.
*
* @param converter the {@code Converter}, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isBound()
*/
public final void setConverter(Converter<SV, TV> converter) {
throwIfBound();
Converter<SV, TV> old = this.converter;
this.converter = converter;
firePropertyChange("converter", old, converter);
}
/**
* Returns the {@code Binding's Converter}, which may be {@code null}.
*
* @return the {@code Binding's Converter}, or {@code null}
* @see #setConverter
*/
public final Converter<SV, TV> getConverter() {
return converter;
}
/**
* Sets the value to be returned by {@link #getSourceValueForTarget}
* when the source property returns {@code null} for the source object.
* The default for this property is {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "sourceNullValue"} when the value of
* this property changes.
* <p>
* This method may not be called on a bound binding.
*
* @param sourceNullValue the value, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
*/
public final void setSourceNullValue(TV sourceNullValue) {
throwIfBound();
TV old = this.sourceNullValue;
this.sourceNullValue = sourceNullValue;
firePropertyChange("sourceNullValue", old, sourceNullValue);
}
/**
* Returns the value to be returned by {@link #getSourceValueForTarget}
* when the source property returns {@code null} for the source object.
* The default for this property is {@code null}.
*
* @return the value that replaces a source value of {@code null}, or {@code null}
* if there is no replacement
* @see #setSourceNullValue
*/
public final TV getSourceNullValue() {
return sourceNullValue;
}
/**
* Sets the value to be returned by {@link #getTargetValueForSource}
* when the target property returns {@code null} for the target object.
* The default for this property is {@code null}.
* <p>
* {@code Binding} fires a property change notification with
* property name {@code "targetNullValue"} when the value of
* this property changes.
* <p>
* This method may not be called on a bound binding.
*
* @param targetNullValue the value, or {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
*/
public final void setTargetNullValue(SV targetNullValue) {
throwIfBound();
SV old = this.targetNullValue;
this.targetNullValue = targetNullValue;
firePropertyChange("targetNullValue", old, targetNullValue);
}
/**
* Returns the value to be returned by {@link #getTargetValueForSource}
* when the target property returns {@code null} for the target object.
* The default for this property is {@code null}.
*
* @return the value that replaces a target value of {@code null}, or {@code null}
* if there is no replacement
* @see #setTargetNullValue
*/
public final SV getTargetNullValue() {
return targetNullValue;
}
/**
* Sets the value to be returned by {@link #getSourceValueForTarget}
* when the source property is unreadable for the source object.
* Calling this method stores the given value and indicates that
* {@code getSourceValueForTarget} should use it, by setting the
* {@code sourceUnreadableValueSet} property to {@code true}.
* <p>
* By default, the {@code sourceUnreadableValue} property is unset,
* indicated by the {@code sourceUnreadableValueSet} property being
* {@code false}.
* <p>
* Setting this property to {@code null} acts the same as setting it to
* any other value. To return the property to the unset state (clearing
* the value and setting {@code sourceUnreadableValueSet} back to
* {@code false}) call {@link #unsetSourceUnreadableValue}.
* <p>
* If this property was previously unset, this method fires a property
* change notification with property name {@code "sourceUnreadableValueSet"}.
* For all invocations, it also fires a property change notification with
* property name {@code "sourceUnreadableValue"}, if necessary, to indicate
* a change in the property value. If previously unset, the event will
* indicate an old value of {@code null}.
* <p>
* This method may not be called on a bound binding.
*
* @param sourceUnreadableValue the value, which may be {@code null}
* @throws IllegalStateException if the {@code Binding} is bound
* @see #isSourceUnreadableValueSet
* @see #getSourceUnreadableValue
*/
public final void setSourceUnreadableValue(TV sourceUnreadableValue) {
throwIfBound();
TV old = this.sourceUnreadableValue;
boolean oldSet = this.sourceUnreadableValueSet;
this.sourceUnreadableValue = sourceUnreadableValue;
this.sourceUnreadableValueSet = true;
firePropertyChange("sourceUnreadableValueSet", oldSet, true);
firePropertyChange("sourceUnreadableValue", old, sourceUnreadableValue);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -