Class EntityFact


public final class EntityFact extends Object
A fact that encapsulates an Entity.

The backed entity can be queried for values (and related values, like `relA.relB.label`) and can be used to add new `EntityFact`s that are obtained via relation resolving.

The fact carries a map of `state` values. This can be used to add rule results, which is normally modelled by an java bean property. Since this is a generalized fact, the results can be arbitary objects. The `states` map defines a key of type EntityFact.Key which also carries type information about the value may be associated. The association, however, does only depend on the name of the key. Thus a key `Key("name1", String.class)` can be used to override a previously defined mapping from a key `Key("name1", Boolean.class)`. On getStatus(Key) the value is only returned, if the type of the given key is assignable from the type of the value associated to the name of the key.

  • Constructor Details

  • Method Details

    • toString

      public String toString()
      toString in class Object
    • where

      public boolean where(String q)
    • field

      @Nullable public @Nullable Object field(String path)
    • entity

      @Nullable public @Nullable EntityFact entity(String relationPath, @Nullable @Nullable String conditions)
    • entity

      @Nullable public @Nullable EntityFact entity(String relationPath)
    • resolve

      public QueryBuilder resolve(String path)
    • getModel

      public String getModel()
    • key

      @Nullable public @Nullable Object key()
    • primaryKey

      @Nullable public @Nullable PrimaryKey primaryKey()
    • getEntity

      public Entity getEntity()
    • entityState

      public Entity.State entityState()
    • setStatus

      public <T> void setStatus(EntityFact.Key<T> key, T value)
    • setStatus

      public <T> void setStatus(String name, Class<T> type, T value)
    • setStatus

      public void setStatus(String name, String value)
    • setStatus

      public void setStatus(String name, boolean value)
    • setStatus

      public void setStatus(String name, int value)
    • setStatus

      public void setStatus(String name, long value)
    • getStatus

      public <T> Optional<T> getStatus(EntityFact.Key<T> key)
    • hasStatus

      public boolean hasStatus(String name)
    • remove

      public void remove(EntityFact.Key<?> key)
    • clearStates

      public void clearStates()
    • hasStates

      public boolean hasStates()
    • noStates

      public boolean noStates()
    • state

      @Nullable public @Nullable Object state(String name)
      Returns a state object for the given key name. This is meant to be used from within drools rules. Otherwise, the getStatus(Key) is preferred.
    • equals

      public boolean equals(Object o)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • key

      public static <T> EntityFact.Key<T> key(String name,<T> type)
    • key

      public static <T> EntityFact.Key<T> key(String name, Class<T> type)