Class AttributeCollector

java.lang.Object
com.github.victools.jsonschema.generator.impl.AttributeCollector

public class AttributeCollector extends Object
Helper class for looking-up various attribute values for a field or method via a given configuration instance.
  • Constructor Details

    • AttributeCollector

      public AttributeCollector(tools.jackson.databind.ObjectMapper objectMapper)
      Constructor accepting the object mapper to use.
      Parameters:
      objectMapper - object mapper
  • Method Details

    • collectFieldAttributes

      public static tools.jackson.databind.node.ObjectNode collectFieldAttributes(FieldScope field, SchemaGenerationContext generationContext)
      Collect a field's contextual attributes (i.e. everything not related to the structure).
      Parameters:
      field - the field for which to collect JSON schema attributes
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      node holding all collected attributes (possibly empty)
    • collectMethodAttributes

      public static tools.jackson.databind.node.ObjectNode collectMethodAttributes(MethodScope method, SchemaGenerationContext generationContext)
      Collect a method's contextual attributes (i.e. everything not related to the structure).
      Parameters:
      method - the method for which to collect JSON schema attributes
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      node holding all collected attributes (possibly empty)
    • collectTypeAttributes

      public static tools.jackson.databind.node.ObjectNode collectTypeAttributes(TypeScope scope, SchemaGenerationContext generationContext, Set<String> allowedSchemaTypes)
      Collect a given scope's general type attributes (i.e. everything not related to the structure).
      Parameters:
      scope - the scope/type representation for which to collect JSON schema attributes
      generationContext - generation context, including configuration to apply when looking-up attribute values
      allowedSchemaTypes - declared schema types determining which attributes are meaningful to be included
      Returns:
      node holding all collected attributes (possibly empty)
    • mergeMissingAttributes

      public static void mergeMissingAttributes(tools.jackson.databind.node.ObjectNode targetNode, tools.jackson.databind.node.ObjectNode attributeContainer)
      Merge the second node's attributes into the first, skipping those attributes that are already contained in the first node.
      Parameters:
      targetNode - node to add non-existent attributes to
      attributeContainer - container holding attributes to add to the first node
    • setId

      public AttributeCollector setId(tools.jackson.databind.node.ObjectNode node, String id, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_ID" attribute.
      Parameters:
      node - schema node to set attribute on
      id - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setAnchor

      public AttributeCollector setAnchor(tools.jackson.databind.node.ObjectNode node, String anchor, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_ANCHOR" attribute.
      Parameters:
      node - schema node to set attribute on
      anchor - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setTitle

      @Deprecated public AttributeCollector setTitle(tools.jackson.databind.node.ObjectNode node, String title)
      Setter for "SchemaKeyword.TAG_TITLE" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      title - attribute value to set
      Returns:
      this instance (for chaining)
    • setTitle

      public AttributeCollector setTitle(tools.jackson.databind.node.ObjectNode node, String title, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_TITLE" attribute.
      Parameters:
      node - schema node to set attribute on
      title - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setDescription

      @Deprecated public AttributeCollector setDescription(tools.jackson.databind.node.ObjectNode node, String description)
      Setter for "SchemaKeyword.TAG_DESCRIPTION" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      description - attribute value to set
      Returns:
      this instance (for chaining)
    • setDescription

      public AttributeCollector setDescription(tools.jackson.databind.node.ObjectNode node, String description, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_DESCRIPTION" attribute.
      Parameters:
      node - schema node to set attribute on
      description - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setDefault

      @Deprecated public AttributeCollector setDefault(tools.jackson.databind.node.ObjectNode node, Object defaultValue)
      Setter for "SchemaKeyword.TAG_DEFAULT" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      defaultValue - attribute value to set
      Returns:
      this instance (for chaining)
    • setDefault

      public AttributeCollector setDefault(tools.jackson.databind.node.ObjectNode node, Object defaultValue, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_DEFAULT" attribute.
      Parameters:
      node - schema node to set attribute on
      defaultValue - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setEnum

      @Deprecated public AttributeCollector setEnum(tools.jackson.databind.node.ObjectNode node, Collection<?> enumValues)
      Setter for "SchemaKeyword.TAG_CONST"/"SchemaKeyword.TAG_ENUM" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      enumValues - attribute value to set
      Returns:
      this instance (for chaining)
    • setEnum

      public AttributeCollector setEnum(tools.jackson.databind.node.ObjectNode node, Collection<?> enumValues, SchemaGenerationContext generationContext)
      Parameters:
      node - schema node to set attribute on
      enumValues - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setReadOnly

      public AttributeCollector setReadOnly(tools.jackson.databind.node.ObjectNode node, boolean readOnly, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_READ_ONLY" attribute.
      Parameters:
      node - schema node to set attribute on
      readOnly - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setWriteOnly

      public AttributeCollector setWriteOnly(tools.jackson.databind.node.ObjectNode node, boolean writeOnly, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_WRITE_ONLY" attribute.
      Parameters:
      node - schema node to set attribute on
      writeOnly - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setAdditionalProperties

      public AttributeCollector setAdditionalProperties(tools.jackson.databind.node.ObjectNode node, tools.jackson.databind.JsonNode additionalProperties, SchemaGenerationContext generationContext)
      Parameters:
      node - schema node to set attribute on
      additionalProperties - attribute value to set (sub-schema)
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setPatternProperties

      public AttributeCollector setPatternProperties(tools.jackson.databind.node.ObjectNode node, Map<String,tools.jackson.databind.JsonNode> patternProperties, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_PATTERN_PROPERTIES" attribute.
      Parameters:
      node - schema node to set attribute on
      patternProperties - resolved attribute value to set (sub-schema mapped by respective property name pattern)
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setStringMinLength

      @Deprecated public AttributeCollector setStringMinLength(tools.jackson.databind.node.ObjectNode node, Integer minLength)
      Setter for "SchemaKeyword.TAG_LENGTH_MIN" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      minLength - attribute value to set
      Returns:
      this instance (for chaining)
    • setStringMinLength

      public AttributeCollector setStringMinLength(tools.jackson.databind.node.ObjectNode node, Integer minLength, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_LENGTH_MIN" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      minLength - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setStringMaxLength

      @Deprecated public AttributeCollector setStringMaxLength(tools.jackson.databind.node.ObjectNode node, Integer maxLength)
      Setter for "SchemaKeyword.TAG_LENGTH_MAX" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      maxLength - attribute value to set
      Returns:
      this instance (for chaining)
    • setStringMaxLength

      public AttributeCollector setStringMaxLength(tools.jackson.databind.node.ObjectNode node, Integer maxLength, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_LENGTH_MAX" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      maxLength - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setStringFormat

      @Deprecated public AttributeCollector setStringFormat(tools.jackson.databind.node.ObjectNode node, String format)
      Setter for "SchemaKeyword.TAG_FORMAT" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      format - attribute value to set
      Returns:
      this instance (for chaining)
    • setStringFormat

      public AttributeCollector setStringFormat(tools.jackson.databind.node.ObjectNode node, String format, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_FORMAT" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      format - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setStringPattern

      @Deprecated public AttributeCollector setStringPattern(tools.jackson.databind.node.ObjectNode node, String pattern)
      Setter for "SchemaKeyword.TAG_PATTERN" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      pattern - attribute value to set
      Returns:
      this instance (for chaining)
    • setStringPattern

      public AttributeCollector setStringPattern(tools.jackson.databind.node.ObjectNode node, String pattern, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_PATTERN" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      pattern - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setNumberInclusiveMinimum

      @Deprecated public AttributeCollector setNumberInclusiveMinimum(tools.jackson.databind.node.ObjectNode node, BigDecimal inclusiveMinimum)
      Setter for "SchemaKeyword.TAG_MINIMUM" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      inclusiveMinimum - attribute value to set
      Returns:
      this instance (for chaining)
    • setNumberInclusiveMinimum

      public AttributeCollector setNumberInclusiveMinimum(tools.jackson.databind.node.ObjectNode node, BigDecimal inclusiveMinimum, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_MINIMUM" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      inclusiveMinimum - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setNumberExclusiveMinimum

      @Deprecated public AttributeCollector setNumberExclusiveMinimum(tools.jackson.databind.node.ObjectNode node, BigDecimal exclusiveMinimum)
      Setter for "SchemaKeyword.TAG_MINIMUM_EXCLUSIVE" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      exclusiveMinimum - attribute value to set
      Returns:
      this instance (for chaining)
    • setNumberExclusiveMinimum

      public AttributeCollector setNumberExclusiveMinimum(tools.jackson.databind.node.ObjectNode node, BigDecimal exclusiveMinimum, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_MINIMUM_EXCLUSIVE" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      exclusiveMinimum - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setNumberInclusiveMaximum

      @Deprecated public AttributeCollector setNumberInclusiveMaximum(tools.jackson.databind.node.ObjectNode node, BigDecimal inclusiveMaximum)
      Setter for "SchemaKeyword.TAG_MAXIMUM" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      inclusiveMaximum - attribute value to set
      Returns:
      this instance (for chaining)
    • setNumberInclusiveMaximum

      public AttributeCollector setNumberInclusiveMaximum(tools.jackson.databind.node.ObjectNode node, BigDecimal inclusiveMaximum, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_MAXIMUM" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      inclusiveMaximum - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setNumberExclusiveMaximum

      @Deprecated public AttributeCollector setNumberExclusiveMaximum(tools.jackson.databind.node.ObjectNode node, BigDecimal exclusiveMaximum)
      Setter for "SchemaKeyword.TAG_MAXIMUM_EXCLUSIVE" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      exclusiveMaximum - attribute value to set
      Returns:
      this instance (for chaining)
    • setNumberExclusiveMaximum

      public AttributeCollector setNumberExclusiveMaximum(tools.jackson.databind.node.ObjectNode node, BigDecimal exclusiveMaximum, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_MAXIMUM_EXCLUSIVE" attribute.
      Parameters:
      node - schema node to set attribute on
      exclusiveMaximum - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setNumberMultipleOf

      @Deprecated public AttributeCollector setNumberMultipleOf(tools.jackson.databind.node.ObjectNode node, BigDecimal multipleOf)
      Setter for "SchemaKeyword.TAG_MULTIPLE_OF" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      multipleOf - attribute value to set
      Returns:
      this instance (for chaining)
    • setNumberMultipleOf

      public AttributeCollector setNumberMultipleOf(tools.jackson.databind.node.ObjectNode node, BigDecimal multipleOf, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_MULTIPLE_OF" attribute.
      Parameters:
      node - schema node to set attribute on
      multipleOf - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setArrayMinItems

      @Deprecated public AttributeCollector setArrayMinItems(tools.jackson.databind.node.ObjectNode node, Integer minItemCount)
      Setter for "SchemaKeyword.TAG_ITEMS_MIN" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      minItemCount - attribute value to set
      Returns:
      this instance (for chaining)
    • setArrayMinItems

      public AttributeCollector setArrayMinItems(tools.jackson.databind.node.ObjectNode node, Integer minItemCount, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_ITEMS_MIN" attribute.
      Parameters:
      node - schema node to set attribute on
      minItemCount - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setArrayMaxItems

      @Deprecated public AttributeCollector setArrayMaxItems(tools.jackson.databind.node.ObjectNode node, Integer maxItemCount)
      Setter for "SchemaKeyword.TAG_ITEMS_MAX" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      maxItemCount - attribute value to set
      Returns:
      this instance (for chaining)
    • setArrayMaxItems

      public AttributeCollector setArrayMaxItems(tools.jackson.databind.node.ObjectNode node, Integer maxItemCount, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_ITEMS_MAX" attribute.
      Parameters:
      node - schema node to set attribute on
      maxItemCount - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)
    • setArrayUniqueItems

      @Deprecated public AttributeCollector setArrayUniqueItems(tools.jackson.databind.node.ObjectNode node, Boolean uniqueItems)
      Setter for "SchemaKeyword.TAG_ITEMS_UNIQUE" attribute (considering Draft 7).
      Parameters:
      node - schema node to set attribute on
      uniqueItems - attribute value to set
      Returns:
      this instance (for chaining)
    • setArrayUniqueItems

      public AttributeCollector setArrayUniqueItems(tools.jackson.databind.node.ObjectNode node, Boolean uniqueItems, SchemaGenerationContext generationContext)
      Setter for "SchemaKeyword.TAG_ITEMS_UNIQUE" attribute.
      Parameters:
      node - schema node to set attribute on
      uniqueItems - attribute value to set
      generationContext - generation context, including configuration to apply when looking-up attribute values
      Returns:
      this instance (for chaining)