Class TypeWrapper<T>

java.lang.Object
org.evrete.util.TypeWrapper<T>
Type Parameters:
T - The Java type associated with this type.
All Implemented Interfaces:
Copyable<Type<T>>, Named, Type<T>

public class TypeWrapper<T> extends Object implements Type<T>
A wrapper class that implements the Type interface and delegates the calls to another Type implementation.
  • Constructor Details

    • TypeWrapper

      public TypeWrapper(Type<T> delegate)
  • Method Details

    • getDelegate

      public final Type<T> getDelegate()
    • getId

      public final int getId()
      Description copied from interface: Type

      Each type is assigned a unique auto-increment int identifier which developers can use in SPI implementations, for example in sharding/partitioning data collections.

      Specified by:
      getId in interface Type<T>
      Returns:
      unique type identifier.
    • getJavaType

      public final String getJavaType()
      Description copied from interface: Type

      There can be only one Type with the given name, but there could be many types associated with a specific Java Class. This method returns the associated Java type.

      Specified by:
      getJavaType in interface Type<T>
      Returns:
      name of the Java Class associated with the type.
    • resolveJavaType

      public Class<T> resolveJavaType()
      Specified by:
      resolveJavaType in interface Type<T>
    • getName

      public final String getName()
      Specified by:
      getName in interface Named
    • getDeclaredFields

      public Collection<TypeField> getDeclaredFields()
      Description copied from interface: Type

      Method returns ALL known fields, both explicitly declared and resolved.

      Specified by:
      getDeclaredFields in interface Type<T>
      Returns:
      Collection of declared fields
      See Also:
    • getField

      public TypeField getField(String name)
      Description copied from interface: Type

      Returns a declared field with the given name. If no such field was explicitly declared, an attempt will be made to resolve the respective field/getter of the declared Java class. If no such field or getter is found, the method will throw IllegalArgumentException

      Empty field name has a special meaning of the "this" value, i.e. such field's values represent the type's instances themself.

      Specified by:
      getField in interface Type<T>
      Parameters:
      name - field name or empty string if the field denotes the type's this value
      Returns:
      declared or resolved field
    • declareField

      public <V> TypeField declareField(String name, Class<V> type, Function<T,V> function)
      Description copied from interface: Type

      Field declaration with a Function as value reader.

      Specified by:
      declareField in interface Type<T>
      Type Parameters:
      V - field value generic type
      Parameters:
      name - field name
      type - field value class
      function - the function that will be used to read field's value
      Returns:
      a newly created field or an existing one if already declared/resolved
    • copyOf

      public Type<T> copyOf()
      Specified by:
      copyOf in interface Copyable<T>
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object