Interface Entity

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  Entity.Key
      A class representing a primary key.
    • Method Detail

      • getEntityId

        String getEntityId()
        Returns:
        the entity ID
      • getKey

        Entity.Key getKey()
        Returns the primary key of this entity. If the entity has no primary key properties defined, this key contains not values.
        Returns:
        the primary key of this entity
      • getOriginalKey

        Entity.Key getOriginalKey()
        Returns the primary key of this entity, in its original state. If the entity has no primary key properties defined, this key contains not values.
        Returns:
        the primary key of this entity in its original state
      • get

        Object get​(String propertyId)
        Returns the value associated with the property identified by propertyId.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the given property
      • getOriginal

        Object getOriginal​(String propertyId)
        Returns the original value associated with the property identified by propertyId.
        Parameters:
        propertyId - the ID of the property for which to retrieve the original value
        Returns:
        the original value of the given property
      • getString

        String getString​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a String.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a String
        Throws:
        ClassCastException - if the value is not a String instance
      • getInteger

        Integer getInteger​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is an Integer.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is an Integer
        Throws:
        ClassCastException - if the value is not a Integer instance
      • getLong

        Long getLong​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a Long.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a Long
        Throws:
        ClassCastException - if the value is not a Integer instance
      • getCharacter

        Character getCharacter​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a Character.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a Character
        Throws:
        ClassCastException - if the value is not a Character instance
      • getDouble

        Double getDouble​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a Double.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a Double.
        Throws:
        ClassCastException - if the value is not a Double instance
        See Also:
        Property.getMaximumFractionDigits()
      • getBigDecimal

        BigDecimal getBigDecimal​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a BigDecimal.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a BigDecimal.
        Throws:
        ClassCastException - if the value is not a BigDecimal instance
        See Also:
        Property.getMaximumFractionDigits()
      • getTime

        LocalTime getTime​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a LocalTime.
        Parameters:
        propertyId - the ID of the date property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a LocalTime
        Throws:
        ClassCastException - if the value is not a LocalTime instance
      • getDate

        LocalDate getDate​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a LocalDate.
        Parameters:
        propertyId - the ID of the date property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a LocalDate
        Throws:
        ClassCastException - if the value is not a LocalDate instance
      • getTimestamp

        LocalDateTime getTimestamp​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a LocalDateTime.
        Parameters:
        propertyId - the ID of the date property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a LocalDatetime
        Throws:
        ClassCastException - if the value is not a LocalDateTime instance
      • getBoolean

        Boolean getBoolean​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a Boolean.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a Boolean
        Throws:
        ClassCastException - if the value is not a Boolean instance
      • getBlob

        byte[] getBlob​(String propertyId)
        Returns the value associated with the property identified by propertyId, assuming it is a byte array.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is a byte array
        Throws:
        ClassCastException - if the value is not a byte array instance
      • getFormatted

        String getFormatted​(String propertyId,
                            Format format)
        Returns the value associated with the property identified by propertyId, formatted with the given Format.
        Parameters:
        propertyId - the ID of the property for which to retrieve the formatted value
        format - the format object
        Returns:
        the value of the property identified by propertyId, formatted with format
      • getFormatted

        String getFormatted​(Property property,
                            Format format)
        Returns the value associated with the given property, formatted with the given Format.
        Parameters:
        property - the property for which to retrieve the formatted value
        format - the format object
        Returns:
        the value of the given property, formatted with format
      • getAsString

        String getAsString​(String propertyId)
        This method returns a String representation of the value associated with the given property, if the property has a format it is used.
        Parameters:
        propertyId - the ID of the property for which to retrieve the value
        Returns:
        a String representation of the value of property
        See Also:
        getFormatted(Property, java.text.Format)
      • getAsString

        String getAsString​(Property property)
        Retrieves a string representation of the value mapped to the given property, an empty string is returned in case of null values.
        Parameters:
        property - the property
        Returns:
        the value mapped to the given property as a string, an empty string if null
      • getForeignKey

        Entity getForeignKey​(String foreignKeyPropertyId)
        Returns the Entity instance referenced by the given foreign key property. If the underlying reference property contains a value, that is, a foreign key value exists but the actual referenced entity has not been loaded, an "empty" entity is returned, containing only the primary key value. Null is returned only if the actual reference property is null.
        Parameters:
        foreignKeyPropertyId - the ID of the property for which to retrieve the value
        Returns:
        the value of the property identified by propertyId, assuming it is an Entity
        Throws:
        IllegalArgumentException - if the property is not a foreign key property
        See Also:
        isLoaded(String)
      • getForeignKey

        Entity getForeignKey​(ForeignKeyProperty foreignKeyProperty)
        Returns the Entity instance referenced by the given foreign key property. If the underlying reference property contains a value, that is, a foreign key value exists but the actual referenced entity has not been loaded, an "empty" entity is returned, containing only the primary key value. Null is returned only if the actual reference property is null.
        Parameters:
        foreignKeyProperty - the foreign key property for which to retrieve the value
        Returns:
        the value of the foreign key property
        See Also:
        isLoaded(String)
      • getReferencedKey

        Entity.Key getReferencedKey​(ForeignKeyProperty foreignKeyProperty)
        Returns the primary key of the entity referenced by the given ForeignKeyProperty, if the reference is null this method returns null.
        Parameters:
        foreignKeyProperty - the foreign key property for which to retrieve the underlying Entity.Key
        Returns:
        the primary key of the underlying entity, null if no entity is referenced
      • isForeignKeyNull

        boolean isForeignKeyNull​(ForeignKeyProperty foreignKeyProperty)
        Returns true if the value of the given foreign key is null, in case of composite foreign keys a single null value of a non-null property is enough.
        Parameters:
        foreignKeyProperty - the foreign key property
        Returns:
        true if the foreign key value is null
      • put

        Object put​(String propertyId,
                   Object value)
        Sets the value of the given property
        Parameters:
        propertyId - the ID of the property
        value - the value
        Returns:
        the previous value
        Throws:
        IllegalArgumentException - in case the value type does not fit the property
      • isModified

        boolean isModified​(String propertyId)
        Parameters:
        propertyId - the propertyId
        Returns:
        true if the value associated with the given property has been modified
      • clearKeyValues

        void clearKeyValues()
        Clears the primary key values from this entity, current as well as original values if any
      • is

        boolean is​(String entityId)
        Parameters:
        entityId - the entityId
        Returns:
        true if this entity is of the given type
      • valuesEqual

        boolean valuesEqual​(Entity entity)
        Parameters:
        entity - the entity to compare to
        Returns:
        true if all ColumnProperty values are equal
      • isLoaded

        boolean isLoaded​(String foreignKeyPropertyId)
        Returns true if the entity referenced via the given foreign key property has been loaded
        Parameters:
        foreignKeyPropertyId - the property id
        Returns:
        true if the reference entity has been loaded
      • getColor

        Object getColor​(Property property)
        Parameters:
        property - the property for which to retrieve the color
        Returns:
        the color to use when displaying this property in a table
      • revert

        void revert​(String propertyId)
        Reverts the value associated with the given property to its original value. If the value has not been modified then calling this method has no effect.
        Parameters:
        propertyId - the ID of the property for which to revert the value
      • save

        void save​(String propertyId)
        Saves the value associated with the given key, that is, removes the original value. If no original value exists calling this method has no effect.
        Parameters:
        propertyId - the ID of the property for which to save the value
      • isNull

        boolean isNull​(String propertyId)
        Returns true if a null value is mapped to the given property or if no mapping is found. In case of foreign key properties the value of the underlying reference property is checked.
        Parameters:
        propertyId - the ID of the property
        Returns:
        true if the value mapped to the given property is null or no value is mapped
      • isNotNull

        boolean isNotNull​(String propertyId)
        Returns true if a this Entity contains a non-null value mapped to the given property In case of foreign key properties the value of the underlying reference property is checked.
        Parameters:
        propertyId - the ID of the property
        Returns:
        true if a non-null value is mapped to the given property
      • containsKey

        boolean containsKey​(String propertyId)
        Returns true if this Entity contains a value for the given property, that value can be null.
        Parameters:
        propertyId - the propertyId
        Returns:
        true if a value is mapped to this property
      • remove

        Object remove​(String propertyId)
        Removes the given property and value from this Entity along with the original value if any. If no value is mapped to the given property, this method has no effect.
        Parameters:
        propertyId - the ID of the property to remove
        Returns:
        the previous value mapped to the given key
      • addValueListener

        void addValueListener​(EventDataListener<ValueChange> valueListener)
        Adds a listener notified each time a value changes Adding the same listener multiple times has no effect.
        Parameters:
        valueListener - the listener
        See Also:
        ValueChange
      • removeValueListener

        void removeValueListener​(EventDataListener<ValueChange> valueListener)
        Removes the given value listener if it has been registered with this Entity.
        Parameters:
        valueListener - the listener to remove