Class SchemaValidator

java.lang.Object
com.northconcepts.datapipeline.foundations.schema.SchemaValidator

public class SchemaValidator extends Object
Static checks used by the schema definitions to add a SchemaProblem to a list for each issue found.
  • Constructor Details

    • SchemaValidator

      public SchemaValidator()
  • Method Details

    • checkValidIdentifier

      public static void checkValidIdentifier(List<SchemaProblem> problems, SchemaPart schemaPart, String identifierName, String identifier)
      Adds a problem if the identifier is empty or does not start with a letter, underscore, at sign or dollar sign.
    • checkParentExists

      public static <T> void checkParentExists(List<SchemaProblem> problems, SchemaPart schemaPart, String parentIdentifierName, SchemaObject parent)
    • checkChildren

      public static <T extends SchemaProblemsSupplier> void checkChildren(List<SchemaProblem> problems, List<T> children, boolean incudeDescendants)
      Adds each child's problems, including those of its descendants if requested; a null list is ignored.
    • checkIndexHasFields

      public static <T extends SchemaProblemsSupplier> void checkIndexHasFields(List<SchemaProblem> problems, SchemaPart schemaPart, List<T> children, boolean includeChildren, String entityDefQualifiedName)
      Adds a problem if the index has no fields (children is null or empty).
    • checkUniqueChildNames

      public static <T> void checkUniqueChildNames(List<SchemaProblem> problems, SchemaPart schemaPart, String childIdentifierName, List<T> children, Function<T,String> nameExtractor)
      Adds a problem for each non-empty name shared by more than one child, comparing names case-sensitively.
    • checkPrimaryKeyPositions

      public static void checkPrimaryKeyPositions(List<SchemaProblem> problems, EntityDef entityDef)
      Adds a problem if the entity's primary key positions are not the consecutive 0-based sequence 0, 1, 2 and so on.
    • checkFieldExists

      public static void checkFieldExists(List<SchemaProblem> problems, SchemaPart schemaPart, EntityDef entity, String fieldRole, String fieldName)
      Adds a problem if the entity is not null and neither it nor its super entities have a field with the given name.
    • checkFieldsExists

      public static void checkFieldsExists(List<SchemaProblem> problems, SchemaPart schemaPart, EntityDef entity, String fieldRole, List<String> fieldNames)
      Adds a problem for each name with no matching field in the entity or its super entities; nothing is checked when the entity or the list is null.
    • checkEntityExistsInRelationship

      public static void checkEntityExistsInRelationship(List<SchemaProblem> problems, SchemaDef schema, SchemaPart schemaPart, String entityRole, String entityName)
      Adds a problem if the entity name is empty or the schema, when not null, has no entity with that name.
    • checkEntityExists

      public static void checkEntityExists(List<SchemaProblem> problems, SchemaDef schema, SchemaPart schemaPart, String entityRole, String entityName)
      Adds a problem if the schema is not null and has no entity with the given name.
    • checkEntitiesExists

      public static void checkEntitiesExists(List<SchemaProblem> problems, SchemaDef schema, SchemaPart schemaPart, String entityRole, List<String> entityNames)
      Adds a problem for each name with no matching entity in the schema; nothing is checked when the schema or the list is null.
    • checkEntityRelationshipKeys

      public static void checkEntityRelationshipKeys(List<SchemaProblem> problems, EntityRelationshipDef entityRelationship)
      Adds a problem if the primary entity has no primary key or the foreign key fields differ from it in count, existence or type. Nothing is checked when the primary entity cannot be found.
    • checkEntityRelationshipCardinality

      public static void checkEntityRelationshipCardinality(List<SchemaProblem> problems, EntityRelationshipDef entityRelationship)
      Adds a problem if the relationship has no cardinality or its foreign key fields contradict it, such as a one-to-one foreign key field that is not part of the foreign entity's primary key.
    • checkNegativeValue

      public static void checkNegativeValue(List<SchemaProblem> problems, SchemaPart schemaPart, Number value, String name)
    • checkMinimumAndMaximumValues

      public static void checkMinimumAndMaximumValues(List<SchemaProblem> problems, SchemaPart schemaPart, Number minimum, Number maximum, String minimumFieldName, String maximumFieldName)
      Adds the same problems as the overload taking negativeNumberAllowed, with negative numbers disallowed.
    • checkMinimumAndMaximumValues

      public static void checkMinimumAndMaximumValues(List<SchemaProblem> problems, SchemaPart schemaPart, Number minimum, Number maximum, String minimumFieldName, String maximumFieldName, boolean negativeNumberAllowed)
      Adds a problem if both values are set and their classes differ, the minimum exceeds the maximum or, unless negativeNumberAllowed is true, either is a negative Integer or Long.
    • checkPrecisionAndScale

      public static void checkPrecisionAndScale(List<SchemaProblem> problems, SchemaPart schemaPart, Integer precision, Integer scale, FieldType fieldType)
      Adds a problem if the precision is negative, an integer type has a positive scale or the absolute scale exceeds the precision.
    • checkMinimumAndMaximumValues

      public static void checkMinimumAndMaximumValues(List<SchemaProblem> problems, SchemaPart schemaPart, TemporalAccessor minimum, TemporalAccessor maximum, String minimumFieldName, String maximumFieldName)
      Adds a problem if both values are set but of different classes; the minimum is not compared to the maximum.
    • checkCyclicalFieldDependency

      public static void checkCyclicalFieldDependency(List<SchemaProblem> problems, RecordFieldDef recordFieldDef)
      Adds a problem if the entity referenced by the record field refers back to itself, directly or through other record fields.
    • checkUniqueIndexFieldNames

      public static void checkUniqueIndexFieldNames(List<SchemaProblem> problems, SchemaPart schemaPart, List<IndexDef> indexes)
      Adds a problem for each list of field names, in the same order, shared by more than one index.