Class Schema

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, org.refcodes.exception.ExceptionAccessor<Throwable>, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.ChildrenAccessor<Schema[]>, org.refcodes.mixin.DescriptionAccessor, org.refcodes.mixin.HashAccessor, org.refcodes.mixin.IdentifierAccessor, org.refcodes.mixin.KeyAccessor<String>, org.refcodes.mixin.StereotypeAccessor<String>, org.refcodes.mixin.TypeAccessor, org.refcodes.mixin.ValueAccessor<Object>

public class Schema extends HashMap<String,Object> implements org.refcodes.mixin.ChildrenAccessor<Schema[]>, org.refcodes.mixin.IdentifierAccessor, org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.TypeAccessor, org.refcodes.mixin.HashAccessor, org.refcodes.mixin.DescriptionAccessor, org.refcodes.mixin.KeyAccessor<String>, org.refcodes.mixin.StereotypeAccessor<String>, org.refcodes.exception.ExceptionAccessor<Throwable>, org.refcodes.mixin.ValueAccessor<Object>
A Schema describes a nested data structure (having 0..n Schema children) whilst not being the data structure itself. A documentation in JSON or XML notation can be produced from a Schema instance for debugging or diagnostic purposes (see JsonVisitor as well as XmlVisitor) by invoking the visit(SchemaVisitor) method (also custom SchemaVisitor classes my be programmed).For description purposes, any descriptive attribute can be added as a key with the according value, as a Schema extends the Map interface. The Schema is a useful base class when implementing a package's Schema type. By default it's toString() method produces a JSON alike String representation of this Schema instances alongside its children by uses the JsonVisitor type applied to the visit(SchemaVisitor) method.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 

    Nested classes/interfaces inherited from class AbstractMap

    AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor

    org.refcodes.mixin.AliasAccessor.AliasBuilder<B>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.ChildrenAccessor

    org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T,B>, org.refcodes.mixin.ChildrenAccessor.ChildrenMutator<T>, org.refcodes.mixin.ChildrenAccessor.ChildrenProperty<T>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.DescriptionAccessor

    org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B>, org.refcodes.mixin.DescriptionAccessor.DescriptionMutator, org.refcodes.mixin.DescriptionAccessor.DescriptionProperty

    Nested classes/interfaces inherited from interface org.refcodes.exception.ExceptionAccessor

    org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC,B>, org.refcodes.exception.ExceptionAccessor.ExceptionMutator<EXC>, org.refcodes.exception.ExceptionAccessor.ExceptionProperty<EXC>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.HashAccessor

    org.refcodes.mixin.HashAccessor.HashBuilder<B>, org.refcodes.mixin.HashAccessor.HashMutator, org.refcodes.mixin.HashAccessor.HashProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.IdentifierAccessor

    org.refcodes.mixin.IdentifierAccessor.IdentifierBuilder<B>, org.refcodes.mixin.IdentifierAccessor.IdentifierMutator, org.refcodes.mixin.IdentifierAccessor.IdentifierProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.KeyAccessor

    org.refcodes.mixin.KeyAccessor.KeyBuilder<K,B>, org.refcodes.mixin.KeyAccessor.KeyMutator<K>, org.refcodes.mixin.KeyAccessor.KeyProperty<K>

    Nested classes/interfaces inherited from interface Map

    Map.Entry<K,V>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.StereotypeAccessor

    org.refcodes.mixin.StereotypeAccessor.StereotypeBuilder<T,B>, org.refcodes.mixin.StereotypeAccessor.StereotypeMutator<T>, org.refcodes.mixin.StereotypeAccessor.StereotypeProperty<T>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor

    org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B>, org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor

    org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>, org.refcodes.mixin.ValueAccessor.ValueMutator<V>, org.refcodes.mixin.ValueAccessor.ValueProperty<V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Schema[]
     
    static final String
    This key labels the short name of a Schema.
    static final String
    This key labels a child's parent's association in terms of UML.
    static final String
    This key labels the description a Schema.
    static final String
    This key labels an exception related to a Schema.
    static final String
    This key labels the hash of an object described by a Schema.
    static final char
    This separator is used to separate the hash code form on object's name.
    static final String
    This key labels the unique identifier of a Schema.
    static final String
    This key labels a child's parent key of a Schema.
    static final String
    This key labels a stereotype (category) in terms of UML.
    static final String
    This key labels the type described by a Schema.
    static final String
    This key labels the value described by a Schema.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
     
    Schema(String aIdentifier, String aAlias, String aKey, Class<?> aType, Integer aHash, String aStereotype, Object aValue, Throwable aException, String aDescription, Schema aSchema, Schema[] aChildren)
    Constructs a Schema with the provided arguments.
    protected
    Instantiates a new schema.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates builder to build Schema.
    int
    protected void
    init(String aAlias, String aIdentifier, Class<?> aType)
     
    Determines the label for this Schema by evaluating the identifier till the last @ character (if any), the alias, the key and the type (it's simple name).
    Creates a Schema's notation String by invoking the provided SchemaNotation visitor which traverses this Schema instance and its children recursively whilst producing the according notation.
    protected static String
     
    protected static String
     
    Uses the JsonVisitor type applied to the visit(SchemaVisitor) method to produce a JSON alike String representation of this Schema instances alongside its children.
    <T> T
    visit(SchemaVisitor<T> aVisitor)
    Visits this Schema instance, the provided SchemaVisitor visitor is invoked with this Schema instance and traverses its children recursively.

    Methods inherited from class AbstractMap

    equals, hashCode

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Map

    equals, hashCode

    Methods inherited from interface org.refcodes.mixin.ValueAccessor

    getValueOr
  • Field Details

  • Constructor Details

    • Schema

      protected Schema()
    • Schema

      protected Schema(Schema.Builder aBuilder)
      Instantiates a new schema.
      Parameters:
      aBuilder - the builder
    • Schema

      public Schema(String aIdentifier, String aAlias, String aKey, Class<?> aType, Integer aHash, String aStereotype, Object aValue, Throwable aException, String aDescription, Schema aSchema, Schema[] aChildren)
      Constructs a Schema with the provided arguments.
      Parameters:
      aIdentifier - The identifier being the label for the Schema, when null the alias, the key or the type's simple name prefixed with the @ character alongside the hash (or this instance's identity has code when null).
      aAlias - The alias (name) describing this Schema, when null, then the alias is extrapolated from the identifier's portion till the last @ character (if any).
      aKey - The key (of a value) provided with this Schema
      aType - The type described by this Schema.
      aHash - The hash if the instance described by this Schema.
      aStereotype - The stereotype related with this Schema.
      aValue - The value representing this Schema.
      aException - The Throwable related with this Schema.
      aDescription - The description for this Schema.
      aSchema - The Schema from which to copy from (in case of not being explicitly set by the arguments).
      aChildren - The Schema's children (aggregation structure).
  • Method Details

    • init

      protected void init(String aAlias, String aIdentifier, Class<?> aType)
    • getIdentifier

      public String getIdentifier()
      Specified by:
      getIdentifier in interface org.refcodes.mixin.IdentifierAccessor
    • getAlias

      public String getAlias()
      Specified by:
      getAlias in interface org.refcodes.mixin.AliasAccessor
    • getKey

      public String getKey()
      Specified by:
      getKey in interface org.refcodes.mixin.KeyAccessor<String>
    • getType

      public Class<?> getType()
      Specified by:
      getType in interface org.refcodes.mixin.TypeAccessor
    • getValue

      public Object getValue()
      Specified by:
      getValue in interface org.refcodes.mixin.ValueAccessor<Object>
    • getHash

      public int getHash()
      Specified by:
      getHash in interface org.refcodes.mixin.HashAccessor
    • getStereotype

      public String getStereotype()
      Specified by:
      getStereotype in interface org.refcodes.mixin.StereotypeAccessor<String>
    • getException

      public Throwable getException()
      Specified by:
      getException in interface org.refcodes.exception.ExceptionAccessor<Throwable>
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface org.refcodes.mixin.DescriptionAccessor
    • getChildren

      public Schema[] getChildren()
      Specified by:
      getChildren in interface org.refcodes.mixin.ChildrenAccessor<Schema[]>
    • toLabel

      public String toLabel()
      Determines the label for this Schema by evaluating the identifier till the last @ character (if any), the alias, the key and the type (it's simple name).
      Returns:
      The determined label.
    • visit

      public <T> T visit(SchemaVisitor<T> aVisitor)
      Visits this Schema instance, the provided SchemaVisitor visitor is invoked with this Schema instance and traverses its children recursively.
      Type Parameters:
      T - The type of the value which the visitor produces.
      Parameters:
      aVisitor - The SchemaVisitor visitor to traverse this Schema instance.
      Returns:
      The according result produced by the SchemaVisitor instance.
    • toNotation

      public String toNotation(SchemaNotation aNotation)
      Creates a Schema's notation String by invoking the provided SchemaNotation visitor which traverses this Schema instance and its children recursively whilst producing the according notation.
      Parameters:
      aNotation - The SchemaNotation visitor to create the according notation.
      Returns:
      The according String notation produced by the SchemaNotation instance.
    • toString

      public String toString()
      Uses the JsonVisitor type applied to the visit(SchemaVisitor) method to produce a JSON alike String representation of this Schema instances alongside its children.
      Overrides:
      toString in class AbstractMap<String,Object>
    • builder

      public static Schema.Builder builder()
      Creates builder to build Schema.
      Returns:
      created builder
    • toObjectId

      protected static String toObjectId(Object aObj)
    • toSimpleObjectId

      protected static String toSimpleObjectId(Object aObj)