Module is.codion.swing.common.ui
Class AbstractTextComponentValue<C extends JTextComponent,T>
java.lang.Object
is.codion.common.reactive.value.AbstractValue<T>
is.codion.swing.common.ui.component.value.AbstractComponentValue<C,T>
is.codion.swing.common.ui.component.text.AbstractTextComponentValue<C,T>
- Type Parameters:
C- the component typeT- the value type
- All Implemented Interfaces:
Observable<T>,Observer<T>,Value<T>,ComponentValue<C,T>
public abstract class AbstractTextComponentValue<C extends JTextComponent,T>
extends AbstractComponentValue<C,T>
An abstract
ComponentValue implementation for a text component.
Handles value notification.-
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
ConstructorsModifierConstructorDescriptionprotectedAbstractTextComponentValue(C component) Instantiates a newAbstractTextComponentValue, with theUpdateOn.VALUE_CHANGEupdate on policy and no null value.protectedAbstractTextComponentValue(C component, @Nullable T nullValue) Instantiates a newAbstractTextComponentValue, with theUpdateOn.VALUE_CHANGEupdate on policy.protectedAbstractTextComponentValue(C component, @Nullable T nullValue, UpdateOn updateOn) Instantiates a newAbstractComponentValue -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanaddValidator(Value.Validator<? super T> validator) Adds a validator to thisValue.final Observer<ValueChange<T>> changed()protected Observable<T> final 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 valuefinal 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.swing.common.ui.component.value.AbstractComponentValue
component, getComponentValue, getValue, setComponentValue, setValueMethods 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
-
AbstractTextComponentValue
Instantiates a newAbstractTextComponentValue, with theUpdateOn.VALUE_CHANGEupdate on policy and no null value.- Parameters:
component- the component
-
AbstractTextComponentValue
Instantiates a newAbstractTextComponentValue, with theUpdateOn.VALUE_CHANGEupdate on policy.- Parameters:
component- the componentnullValue- the value to use instead of null
-
AbstractTextComponentValue
Instantiates a newAbstractComponentValue- Parameters:
component- the componentnullValue- the value to use instead of nullupdateOn- the update on policy- Throws:
NullPointerException- in case component is null
-
-
Method Details
-
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
-