Class 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 Detail

      • AttributeCollector

        public AttributeCollector​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Constructor accepting the object mapper to use.
        Parameters:
        objectMapper - object mapper
    • Method Detail

      • collectFieldAttributes

        public static com.fasterxml.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 com.fasterxml.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 com.fasterxml.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​(com.fasterxml.jackson.databind.node.ObjectNode targetNode,
                                                  com.fasterxml.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​(com.fasterxml.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​(com.fasterxml.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

        public AttributeCollector setTitle​(com.fasterxml.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

        public AttributeCollector setDescription​(com.fasterxml.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

        public AttributeCollector setDefault​(com.fasterxml.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)
      • setReadOnly

        public AttributeCollector setReadOnly​(com.fasterxml.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​(com.fasterxml.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​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                          com.fasterxml.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​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                       Map<String,​com.fasterxml.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

        public AttributeCollector setStringMinLength​(com.fasterxml.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

        public AttributeCollector setStringMaxLength​(com.fasterxml.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

        public AttributeCollector setStringFormat​(com.fasterxml.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

        public AttributeCollector setStringPattern​(com.fasterxml.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

        public AttributeCollector setNumberInclusiveMinimum​(com.fasterxml.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

        public AttributeCollector setNumberExclusiveMinimum​(com.fasterxml.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

        public AttributeCollector setNumberInclusiveMaximum​(com.fasterxml.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

        public AttributeCollector setNumberExclusiveMaximum​(com.fasterxml.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

        public AttributeCollector setNumberMultipleOf​(com.fasterxml.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

        public AttributeCollector setArrayMinItems​(com.fasterxml.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

        public AttributeCollector setArrayMaxItems​(com.fasterxml.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

        public AttributeCollector setArrayUniqueItems​(com.fasterxml.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)