Package com.j3d.gen.properties
Class Property<T,G extends HasProperties>
java.lang.Object
com.j3d.gen.properties.Property<T,G>
- Type Parameters:
T- The type of the property (allowed types given above)G- The type of the property provider, this is the class itself which is defining this property.
Defines a singular property of some object which implements
HasProperties.
While this is intended to have a converter (used by UI), this is designed in a way to take in generic types. But each type give should follow command parser rules. hence the following values are allowed:
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether the value can be edited or not, much like an idprivate StringThe property's descriptionprivate final StringThe property's labelHow to apply a new value to this property.private JPanelThe class which defined this property. e.g.How the property should be retrieved. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconstant()Marks this property as constant, meaning its value cannot be changed.booleanReturns the description of this property.getKey()getName()Returns the name (label) of this property.Returns theConsumerused to set new values for this property.Returns the class that is considered the provider or owner of this property.Returns theSupplierresponsible for retrieving the current value of this property.inthashCode()booleanChecks if this property is marked as constant (uneditable).setDescription(String description) Sets a descriptive text for this property.setNewValueConsumer(Consumer<T> newValue) Sets aConsumerthat will be used to apply new values to this property.
-
Field Details
-
name
The property's label -
valueSupplier
How the property should be retrieved. A supplier in case it changes. -
constant
private boolean constantWhether the value can be edited or not, much like an id -
description
The property's description -
newValue
How to apply a new value to this property. -
panel
-
propertyProvider
The class which defined this property. e.g.GTrimay provide it's Vector3 normal, which is provided by itself, but it's id, colour or pivot, are provided by its super classGObject. This is so when multiple objects are selected, only the properties from the same propertyProvider get shown and can be edited in bulk. -
holds
-
-
Constructor Details
-
Property
Constructs a new Property instance.- Parameters:
name- The display name or label of the property.value- ASupplierthat provides the current value of the property.providerClass- The class that "owns" or provides this property.
-
-
Method Details
-
holds
-
constant
Marks this property as constant, meaning its value cannot be changed. This is useful for properties like IDs.- Returns:
- This Property instance for method chaining.
-
setDescription
Sets a descriptive text for this property.- Parameters:
description- A string explaining what the property represents.- Returns:
- This Property instance for method chaining.
-
setNewValueConsumer
Sets aConsumerthat will be used to apply new values to this property. If no consumer is set, the property is effectively read-only (unless it's constant, in which case it's always read-only).- Parameters:
newValue- AConsumerthat accepts a new value of type T and applies it.- Returns:
- This Property instance for method chaining.
-
getName
Returns the name (label) of this property.- Returns:
- The property's name.
-
getValueSupplier
Returns theSupplierresponsible for retrieving the current value of this property.- Returns:
- The value supplier.
-
isConstant
public boolean isConstant()Checks if this property is marked as constant (uneditable).- Returns:
trueif the property is constant,falseotherwise.
-
getDescription
Returns the description of this property.- Returns:
- The property's description, or
nullif not set.
-
getNewValueConsumer
Returns theConsumerused to set new values for this property.- Returns:
- The new value consumer, or
nullif not set.
-
getPropertyProvider
Returns the class that is considered the provider or owner of this property.- Returns:
- The class of the property provider.
-
equals
-
getKey
-
hashCode
public int hashCode() -
getPropertyType
-