Class Schema<T>

java.lang.Object
tech.ydb.yoj.databind.schema.Schema<T>
Direct Known Subclasses:
ObjectSchema

public abstract class Schema<T> extends Object
  • Field Details

  • Constructor Details

    • Schema

      protected Schema(@NonNull @NonNull Class<T> type)
    • Schema

      protected Schema(@NonNull @NonNull Class<T> type, @NonNull @NonNull NamingStrategy namingStrategy)
    • Schema

      protected Schema(@NonNull @NonNull Class<T> type, @NonNull @NonNull Reflector reflector)
    • Schema

      protected Schema(@NonNull @NonNull Class<T> type, @NonNull @NonNull NamingStrategy namingStrategy, @NonNull @NonNull Reflector reflector)
    • Schema

      protected Schema(@NonNull @NonNull SchemaRegistry.SchemaKey<T> key, @NonNull @NonNull Reflector reflector)
    • Schema

      protected Schema(Schema<?> schema, String subSchemaFieldPath)
  • Method Details

    • isFlattenable

      protected boolean isFlattenable(ReflectField field)
      Parameters:
      field - composite field
      Returns:
      true if the composite field can be flattened to a single field; false otherwise
    • getType

      public final Class<T> getType()
    • getNamingStrategy

      public final NamingStrategy getNamingStrategy()
    • getName

      public final String getName()
      Returns the name of the table for data binding.

      If the Table annotation is present, the field name should be used to specify the table name.

      Returns:
      the table name for data binding
    • isDynamic

      public final boolean isDynamic()
    • flattenFields

      public final List<Schema.JavaField> flattenFields()
    • flattenFieldNames

      public final List<String> flattenFieldNames()
    • flatten

      public final Map<String,Object> flatten(T t)
    • flattenOneField

      public final Map<String,Object> flattenOneField(String fieldPath, Object fieldValue)
    • flattenToList

      public final List<Schema.JavaFieldValue> flattenToList(T t)
    • newInstance

      public final T newInstance(Map<String,Object> cells) throws ConstructionException
      Creates a new object having the specified field values.
      Parameters:
      cells - field value map: field name -> field value
      Returns:
      object with the specified field values
      Throws:
      ConstructionException - could not construct object from cells
    • getField

      public final Schema.JavaField getField(String path)
      Parameters:
      path - dot-separated field path, e.g. vm.status for the status field inside the vm field of the top-level entity
      Returns:
      entity field
      Throws:
      IllegalArgumentException - no such field exists
    • findField

      public final Optional<Schema.JavaField> findField(String path)
      Parameters:
      path - dot-separated field path, e.g. vm.status for the status field inside the vm field of the top-level entity
      Returns:
      Optional representing the field found, if it exists; an empty Optional otherwise
    • hashCode

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

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

      public final String toString()
      Overrides:
      toString in class Object