Module is.codion.swing.common.ui
Class AbstractComponentValue<C extends JComponent,T>
java.lang.Object
is.codion.common.reactive.value.AbstractValue<T>
is.codion.swing.common.ui.component.value.AbstractComponentValue<C,T>
- Type Parameters:
C- the component typeT- the value type
- All Implemented Interfaces:
Observable<T>,Observer<T>,Value<T>,ComponentValue<C,T>
- Direct Known Subclasses:
AbstractTextComponentValue
public abstract class AbstractComponentValue<C extends JComponent,T>
extends AbstractValue<T>
implements ComponentValue<C,T>
An abstract base implementation of
ComponentValue.-
Nested Class Summary
Nested classes/interfaces inherited from class is.codion.common.reactive.value.AbstractValue
AbstractValue.AbstractBuilder<T,B extends Value.Builder<T, B>> Nested classes/interfaces inherited from interface is.codion.common.reactive.value.Value
Value.Builder<T,B extends Value.Builder<T, B>>, Value.BuilderFactory, Value.Locked, Value.Notify, Value.Validator<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractComponentValue(C component) Instantiates a new nullableAbstractComponentValueprotectedAbstractComponentValue(C component, @Nullable T nullValue) Instantiates a newAbstractComponentValue -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanaddValidator(Value.Validator<? super T> validator) Adds a validator to thisValue.final Observer<ValueChange<T>> changed()final Cprotected Observable<T> Returns the value from the underlying componentgetValue()Returns the actual internalfinal booleanIf false then get() is guaranteed to never return null.final voidlink(Observable<T> observable) Creates a unidirectional link between this value and the given observable, so that changes in the observable are reflected in this one.final voidCreates a bidirectional link between this and the given original value, so that changes in one are reflected in the other.final Value.Lockedlocked()Locking a value prevents it from being changed, it does not prevent it from being set.protected final voidNotifies the underlying observer that the underlying value has changed or at least that it may have changedobserver()final booleanremoveValidator(Value.Validator<? super T> validator) Removes the given validator from this valueprotected abstract voidsetComponentValue(@Nullable T value) Sets the given value in the underlying component.protected final voidSets the actual internalfinal voidunlink(Observable<T> observable) Unlinks this value from the given observablefinal voidUnlinks this value from the given original valuefinal voidValidate the given value using all validatorsMethods inherited from class is.codion.common.reactive.value.AbstractValue
clear, get, set, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface is.codion.common.reactive.observer.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, get, getOrThrow, getOrThrow, is, isNot, isNull, isNullable, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener, when, whenMethods inherited from interface is.codion.common.reactive.value.Value
addValidator, changed, clear, link, link, locked, observable, removeValidator, set, unlink, unlink, update, validate
-
Constructor Details
-
AbstractComponentValue
Instantiates a new nullableAbstractComponentValue- Parameters:
component- the component- Throws:
NullPointerException- in case component is null
-
AbstractComponentValue
Instantiates a newAbstractComponentValue- Parameters:
component- the componentnullValue- the value to use instead of null- Throws:
NullPointerException- in case component is null
-
-
Method Details
-
component
- Specified by:
componentin interfaceComponentValue<C extends JComponent,T> - Returns:
- the input component representing the value
-
getValue
Returns the actual internal- Returns:
- the value
-
setValue
Sets the actual internal- Parameters:
value- the value
-
getComponentValue
Returns the value from the underlying component- Returns:
- the value from the underlying component
- See Also:
-
setComponentValue
Sets the given value in the underlying component. Note that this method is called on the Event Dispatch Thread.- Parameters:
value- the value to display in the underlying component- See Also:
-
observable
- Specified by:
observablein interfaceValue<T>- Returns:
- a read-only
Observableinstance for this value
-
observer
- Specified by:
observerin interfaceObservable<T>- Returns:
- an
Observernotified each time the observed value may have changed
-
changed
-
locked
Description copied from interface:ValueLocking a value prevents it from being changed, it does not prevent it from being set.
Note that locking a value does not prevent linked values from being changed.
A locked value in a linked value chain, may cause it to go out of sync, since any subsequent linked values will not be updated after a locked value is encountered.
- Specified by:
lockedin interfaceValue<T>- Returns:
- the
Value.Lockedinstance controlling whether this value is locked
-
isNullable
public final boolean isNullable()Description copied from interface:ObservableIf false then get() is guaranteed to never return null.- Specified by:
isNullablein interfaceObservable<T>- Returns:
- true if this observable can be null
-
link
Description copied from interface:ValueCreates a bidirectional link between this and the given original value, so that changes in one are reflected in the other. Note that after a call to this method this value is the same asoriginalValue. -
unlink
Description copied from interface:ValueUnlinks this value from the given original value -
link
Description copied from interface:ValueCreates a unidirectional link between this value and the given observable, so that changes in the observable are reflected in this one. Note that after a call to this method the value of this value is the same as the observable. -
unlink
Description copied from interface:ValueUnlinks this value from the given observable -
addValidator
Description copied from interface:ValueAdds a validator to thisValue. Adding the same validator again has no effect.- Specified by:
addValidatorin interfaceValue<T>- Parameters:
validator- the validator- Returns:
- true if this value did not already contain the specified validator
-
removeValidator
Description copied from interface:ValueRemoves the given validator from this value- Specified by:
removeValidatorin interfaceValue<T>- Parameters:
validator- the validator- Returns:
- true if this value contained the specified validator
-
validate
Description copied from interface:ValueValidate the given value using all validators -
notifyObserver
protected final void notifyObserver()Notifies the underlying observer that the underlying value has changed or at least that it may have changed -
createObservable
- Returns:
- a new
Observableinstance representing this value
-