Class Property<T,K>

java.lang.Object
com.codename1.properties.PropertyBase<T,K>
com.codename1.properties.Property<T,K>
Direct Known Subclasses:
BooleanProperty, NumericProperty

public class Property<T,K> extends PropertyBase<T,K>
Base class for a property, it can store a generic value of any type and broadcast change events to external listeners
  • Constructor Details

    • Property

      public Property(String name, T value)

      Constructs a property with the given name and value

      Parameters
      • name: the name of the property

      • value: the default value for the property

    • Property

      public Property(String name, Class genericType, T value)

      Constructs a property with the given name and value

      Parameters
      • name: the name of the property

      • genericType: the type of the property

      • value: the default value for the property

    • Property

      public Property(String name)

      Constructs a property with null value

      Parameters
      • name: the name of the property
    • Property

      public Property(String name, Class genericType)

      Constructs a property with null value

      Parameters
      • genericType: the type of the property

      • name: the name of the property

  • Method Details

    • get

      public T get()

      Gets the property value

      Returns

      the property value

    • set

      public K set(T value)

      Sets the property value and potentially fires a change event

      Parameters
      • value: the new value
    • equals

      public boolean equals(Object obj)

      Compares this property to another property

      Parameters
      • obj: the other property
      Returns

      true if they are equal in name and value

      Overrides:
      equals in class PropertyBase<T,K>
    • hashCode

      public int hashCode()

      Returns the internal hashcode or 0 for null property

      Returns

      the hashcode value

      Overrides:
      hashCode in class PropertyBase<T,K>
    • toString

      public String toString()
      Description copied from class: PropertyBase

      Default toString that provides easier debug information

      Returns

      a formatted representation of the property for debugging

      Overrides:
      toString in class PropertyBase<T,K>