Class Property<T>


  • public abstract class Property<T>
    extends Object

    Describes and helps manipulating a property of a given value. As such it is like a more concrete version of a PropertyDescriptor that supports undo (see setUndoable(Object, Object)).

    E.g. a class has a property called name. Use this interface to implement a class that calls getName() to get the value of the property or setName(String) to set a new value.

    Author:
    Hendrik Schreiber
    • Constructor Detail

      • Property

        public Property()
    • Method Detail

      • get

        public abstract T get​(Object o)
        Returns a property value.
        Parameters:
        o - object
        Returns:
        the value of the property
      • set

        public abstract void set​(Object o,
                                 T value)
        Sets a property value.
        Parameters:
        o - object
        value - value to set
      • getName

        public abstract String getName()
        Name of the property.
        Returns:
        property name
      • getSQLName

        public String getSQLName()
        SQL name of the property, i.e., the column name.
        Returns:
        column name
      • getObjectPath

        public String getObjectPath()
        Object path to this property. E.g., if the property belongs directly to a Song object, it's "song". If it belongs to SongAnnotation, it's "song.songAnnotation"
        Returns:
        by default this returns "song".
      • getFullyQualifiedName

        public final String getFullyQualifiedName()

        Returns the fully qualified name, that can be used in HQL queries, which use song as alias for the Song table. E.g. the fully qualified name for "artist" is "song.artist". Any properties that are persisted in SongAnnotation follow the pattern "song.songAnnotation.PROPERTY_NAME". E.g. "song.songAnnotation.custom1".

        The fully qualified name always consists of getObjectPath() + "." + getName().

        Returns:
        fully qualified name
      • setUndoable

        public Property.PropertyUndoableEdit<T> setUndoable​(Object object,
                                                            T newValue)
        Sets the value of the property in an undoable way.
        Parameters:
        object - object
        newValue - value
        Returns:
        an UndoableEdit that allows reversal of this call. Note that the presentation name is not localized and must be adjusted, if it should be used in a localized context.
      • getValueClass

        public abstract Class<? extends T> getValueClass()
        Class values are in.
        Returns:
        class
      • getInstance

        public static <T> Property<T> getInstance​(String propertyName)
        Get property instance based on a name. The name can be either simple ("artist") or fully qualified ("song.songAnnotation.custom1").
        Type Parameters:
        T - type of the property
        Parameters:
        propertyName - name
        Returns:
        property object or null, if not found.