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.

public class Property<T,G extends HasProperties> extends Object
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 Details

    • name

      private final String name
      The property's label
    • valueSupplier

      private final Supplier<T> valueSupplier
      How the property should be retrieved. A supplier in case it changes.
    • constant

      private boolean constant
      Whether the value can be edited or not, much like an id
    • description

      private String description
      The property's description
    • newValue

      private Consumer<T> newValue
      How to apply a new value to this property.
    • panel

      private JPanel panel
    • propertyProvider

      private final Class<G extends HasProperties> propertyProvider
      The class which defined this property. e.g. GTri may provide it's Vector3 normal, which is provided by itself, but it's id, colour or pivot, are provided by its super class GObject. This is so when multiple objects are selected, only the properties from the same propertyProvider get shown and can be edited in bulk.
    • holds

      private Class<T> holds
  • Constructor Details

    • Property

      public Property(String name, Supplier<T> value, Class<G> providerClass)
      Constructs a new Property instance.
      Parameters:
      name - The display name or label of the property.
      value - A Supplier that provides the current value of the property.
      providerClass - The class that "owns" or provides this property.
  • Method Details

    • holds

      public Property<T,G> holds(Class<T> clazz)
    • constant

      public Property<T,G> 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

      public Property<T,G> setDescription(String description)
      Sets a descriptive text for this property.
      Parameters:
      description - A string explaining what the property represents.
      Returns:
      This Property instance for method chaining.
    • setNewValueConsumer

      public Property<T,G> setNewValueConsumer(Consumer<T> newValue)
      Sets a Consumer that 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 - A Consumer that accepts a new value of type T and applies it.
      Returns:
      This Property instance for method chaining.
    • getName

      public String getName()
      Returns the name (label) of this property.
      Returns:
      The property's name.
    • getValueSupplier

      public Supplier<T> getValueSupplier()
      Returns the Supplier responsible 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:
      true if the property is constant, false otherwise.
    • getDescription

      public String getDescription()
      Returns the description of this property.
      Returns:
      The property's description, or null if not set.
    • getNewValueConsumer

      public Consumer<T> getNewValueConsumer()
      Returns the Consumer used to set new values for this property.
      Returns:
      The new value consumer, or null if not set.
    • getPropertyProvider

      public Class<G> getPropertyProvider()
      Returns the class that is considered the provider or owner of this property.
      Returns:
      The class of the property provider.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getKey

      public PropertyKey<T,G> getKey()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getPropertyType

      public Class<T> getPropertyType()