T - the type of value this property mirrorspublic class PropertyMirror<T> extends java.lang.Object implements Property<T>
Property that delegates all operations to another.
This can be used in conjunction with config builders to easily setup a configuration without reflection. For example:
public final PropertyMirror<Integer> diamondsDropped = new PropertyMirror<>();
private final Node config = ConfigNode.builder()
.beginValue("diamondsDropped", Integer.class)
.beginConstraints().atLeast(1).finishConstraints()
.finishValue(diamondsDropped::mirror)
.build();
| Constructor and Description |
|---|
PropertyMirror() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(T value)
Returns
true if this property can be set to the given value. |
java.lang.Class<T> |
getType()
Returns the class of the type of the value being held
|
T |
getValue()
Returns the value being held
|
void |
mirror(Property<T> delegate)
Sets a property to mirror.
|
boolean |
setValue(T value)
Sets the value of this property.
|
public void mirror(Property<T> delegate)
After calling this method with a valid delegate,
every property method will redirect to delegate.
delegate - a property to mirrorpublic boolean setValue(T value)
Property This can fail and return false if, for example, the value did not satisfy the constraints of the property.
setValue in interface Property<T>value - the new value this property should receivetrue if this property changed as a result of the callProperty.accepts(Object)public boolean accepts(T value)
Propertytrue if this property can be set to the given value.accepts in interface Property<T>value - the value to checktrue if this property accepts the given value, false otherwise.Property.setValue(Object)public T getValue()
HasValue