Module storm

Class MetamodelImpl<T extends Record,E>

java.lang.Object
st.orm.template.impl.MetamodelImpl<T,E>
Type Parameters:
T - the primary table type.
E - the record component type of the designated element.
All Implemented Interfaces:
Metamodel<T,E>

public class MetamodelImpl<T extends Record,E> extends Object implements Metamodel<T,E>
Implementation that is used by the generated models.
Since:
1.2
  • Constructor Details

    • MetamodelImpl

      public MetamodelImpl(@Nonnull Class<E> componentType)
    • MetamodelImpl

      public MetamodelImpl(@Nonnull Class<E> componentType, @Nonnull String path)
    • MetamodelImpl

      public MetamodelImpl(@Nonnull Class<E> componentType, @Nonnull String path, @Nonnull String component, boolean inline, @Nullable Metamodel<T,?> parent)
  • Method Details

    • of

      public static <T extends Record> Metamodel<T,T> of(@Nonnull Class<T> table)
      Creates a new metamodel for the given record type.
      Type Parameters:
      T - the root table type.
      Parameters:
      table - the root table to create the metamodel for.
      Returns:
      a new metamodel for the given record type.
    • of

      public static <T extends Record, E> Metamodel<T,E> of(@Nonnull Class<T> rootTable, @Nonnull String path)
      Creates a new metamodel for the given root rootTable and path.

      This method is typically used to manually create a metamodel for a component of a record, which can be useful in cases where the metamodel can not be generated automatically, for example local records.

      Type Parameters:
      T - the root rootTable type.
      E - the record component type of the designated component.
      Parameters:
      rootTable - the root rootTable to create the metamodel for.
      path - a dot separated path starting from the root rootTable.
      Returns:
      a new metamodel for the given root rootTable and path.
      Throws:
      PersistenceException - if the metamodel cannot be created for the root rootTable and path.
    • isColumn

      public boolean isColumn()
      Returns true if the metamodel corresponds to a database column, returns false otherwise, for example if the metamodel refers to the root metamodel or an inline record.
      Specified by:
      isColumn in interface Metamodel<T extends Record,E>
      Returns:
      true if this metamodel maps to a column, false otherwise.
    • root

      public Class<T> root()
      Returns the root metamodel. This is typically the table specified in the FROM clause of a query.
      Specified by:
      root in interface Metamodel<T extends Record,E>
      Returns:
      the root metamodel.
    • table

      public Metamodel<T,? extends Record> table()
      Returns the table that holds the column to which this metamodel is pointing. If the metamodel points to an inline record, the table is the parent table of the inline record. If the metamodel is a root metamodel, the root table is returned.
      Specified by:
      table in interface Metamodel<T extends Record,E>
      Returns:
      the table that holds the column to which this metamodel is pointing.
    • componentType

      public Class<E> componentType()
      Returns the component type of the designated element.
      Specified by:
      componentType in interface Metamodel<T extends Record,E>
      Returns:
      the component type of the designated element.
    • path

      public String path()
      Returns the path to the database table.
      Specified by:
      path in interface Metamodel<T extends Record,E>
      Returns:
      path to the database table.
    • component

      public String component()
      Returns the component path.
      Specified by:
      component in interface Metamodel<T extends Record,E>
      Returns:
      component path.
    • toString

      public String toString()
      Overrides:
      toString in class Object