Class Property

java.lang.Object
eu.mihosoft.vmf.runtime.core.Property

public final class Property
extends java.lang.Object
Gives reflective access to an objects/types property. Property objects can be used to set and unset properties as well as acquire type information as well as annotations. Additionally, one can register change listeners.
See Also:
Tutorial on Custom Default Values for Properties
  • Method Summary

    Modifier and Type Method Description
    vjavax.observer.Subscription addChangeListener​(ChangeListener l)
    Adds the specified change listener to this property.
    java.util.Optional<Annotation> annotationByKey​(java.lang.String key)
    Returns the annotation specified by key.
    java.util.List<Annotation> annotations()
    Returns the list of annotations of this object.
    java.lang.Object get()
    Returns the value of this property.
    java.lang.Object getDefault()
    Returns the default value of this property.
    java.lang.String getName()
    Returns the name of this property.
    Type getType()
    Returns the type of this property.
    boolean isSet()
    Indicates whether this property is set.
    static Property newInstance​(VObjectInternal parent, java.lang.String name, boolean staticOnly)
    Deprecated.
    void set​(java.lang.Object o)
    Sets this property to the specified object.
    void setDefault​(java.lang.Object value)
    Deprecated.
    void unset()
    Unsets this property, i.e., resets it to the specified default values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newInstance

      @Deprecated public static Property newInstance​(VObjectInternal parent, java.lang.String name, boolean staticOnly)
      Deprecated.
    • isSet

      public boolean isSet()
      Indicates whether this property is set. A property is defined as being set if the current value differs from the default value, i.e., Objects.equals(property.get(),property.getDefault()).
      Returns:
      true if this property is set; false otherwise
    • set

      public void set​(java.lang.Object o)
      Sets this property to the specified object.
      Parameters:
      o - object to set
      See Also:
      isSet()
    • unset

      public void unset()
      Unsets this property, i.e., resets it to the specified default values.
      See Also:
      isSet()
    • get

      public java.lang.Object get()
      Returns the value of this property.
      Returns:
      value of this property
    • setDefault

      @Deprecated public void setDefault​(java.lang.Object value)
      Deprecated.
    • getDefault

      public java.lang.Object getDefault()
      Returns the default value of this property.
      Returns:
      default value of this property
      See Also:
      unset(), isSet()
    • getType

      public Type getType()
      Returns the type of this property.
      Returns:
      type of this property
    • getName

      public java.lang.String getName()
      Returns the name of this property.
      Returns:
      name of this property
    • annotations

      public java.util.List<Annotation> annotations()
      Returns the list of annotations of this object.
      Returns:
      the list of annotations of this object
    • annotationByKey

      public java.util.Optional<Annotation> annotationByKey​(java.lang.String key)
      Returns the annotation specified by key.
      Parameters:
      key - the key of the annotation to return
      Returns:
      the annotation specified by key
    • addChangeListener

      public vjavax.observer.Subscription addChangeListener​(ChangeListener l)
      Adds the specified change listener to this property. Listeners will be notified about changes regardless of whether change recording is enabled. This allows to react to and/or undo specific changes without the overhead of storing all previous events in a collection. The listener registers with this property only.
      Parameters:
      l - the listener to add
      Returns:
      a subscription which allows to unsubscribe the specified listener