Interface EntityField<E>

    • Method Detail

      • getName

        String getName()
        Returns name of this field with no spaces where each word starts with a capital letter.
        Returns:
      • getNameCamelCase

        String getNameCamelCase()
      • getNameDashed

        String getNameDashed()
        Returns name of this field in lowercase with words separated by a dash (-).
        Returns:
      • get

        Object get​(E e)
        Returns the value of this field.
        Parameters:
        e - Entity
        Returns:
        Value of the field
      • set

        default <T> void set​(E e,
                             T value)
        Sets the value of this field. Does nothing by default. If you want to have a field set, override this method.
        Type Parameters:
        T -
        Parameters:
        e - Entity
        value - Value of the field
      • collectionAdd

        default <T> void collectionAdd​(E e,
                                       T value)
        Adds an element to the collection stored in this field.
        Parameters:
        e - Entity
        value - Value to be added to the collection
        Throws:
        ClassCastException - If this field is not a collection.
        UnsupportedOperationException - If this collection type is not yet known.
      • collectionRemove

        default <T> Object collectionRemove​(E e,
                                            T value)
        Removes an element from the collection stored in this field.
        Parameters:
        e - Entity
        value - Value to be added to the collection
        Returns:
        Defined by the underlying field. Preferrably it should return deleted object, but it can return true / false indication of removal, or just null.
        Throws:
        ClassCastException - If this field is not a collection.
      • mapGet

        default <K> Object mapGet​(E e,
                                  K key)
        Retrieves a value from the map stored in this field.
        Parameters:
        e - Entity
        key - Requested key
        Returns:
        Object mapped to this key
        Throws:
        ClassCastException - If this field is not a map.
      • mapPut

        default <K,​T> void mapPut​(E e,
                                        K key,
                                        T value)
        Adds a mapping to the map stored in this field.
        Parameters:
        e - Entity
        key - Key to map
        value - Mapped value
        Throws:
        ClassCastException - If this field is not a map.
      • mapRemove

        default <K> Object mapRemove​(E e,
                                     K key)
        Removes a mapping from the map stored in this field.
        Parameters:
        e - Entity
        key - Key to remove
        Returns:
        Object mapped to this key
        Throws:
        ClassCastException - If this field is not a map.
      • getFieldClass

        default Class<?> getFieldClass()
        Returns:
        Returns the most specific type of this field.
      • getCollectionElementClass

        default Class<?> getCollectionElementClass()
        Returns:
        If this field is a collection, returns type of its elements; otherwise returns Void class.
      • getMapKeyClass

        default Class<?> getMapKeyClass()
        Returns:
        If this field is a map, returns type of its keys; otherwise returns Void class.
      • getMapValueClass

        default Class<?> getMapValueClass()
        Returns:
        If this field is a map, returns type of its values; otherwise returns Void class.