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,
                                                                                            SchemaGeneratorConfig config)
        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
        config - 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,
                                                                                             SchemaGeneratorConfig config)
        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
        config - 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,
                                                                                           SchemaGeneratorConfig config)
        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
        config - configuration to apply when looking-up attribute values
        Returns:
        node holding all collected attributes (possibly empty)
      • setTitle

        public AttributeCollector setTitle​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                           String title)
        Setter for ""title"" attribute.
        Parameters:
        node - schema node to set attribute on
        title - attribute value to set
        Returns:
        this instance (for chaining)
      • setDescription

        public AttributeCollector setDescription​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                 String description)
        Setter for ""description"" attribute.
        Parameters:
        node - schema node to set attribute on
        description - attribute value to set
        Returns:
        this instance (for chaining)
      • setDefault

        public AttributeCollector setDefault​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                             Object defaultValue)
        Setter for ""default"" attribute.
        Parameters:
        node - schema node to set attribute on
        defaultValue - attribute value to set
        Returns:
        this instance (for chaining)
      • setEnum

        public AttributeCollector setEnum​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                          Collection<?> enumValues)
        Setter for ""const""/""enum"" attribute.
        Parameters:
        node - schema node to set attribute on
        enumValues - attribute value to set
        Returns:
        this instance (for chaining)
      • setStringMinLength

        public AttributeCollector setStringMinLength​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                     Integer minLength)
        Setter for ""minLength"" attribute.
        Parameters:
        node - schema node to set attribute on
        minLength - attribute value to set
        Returns:
        this instance (for chaining)
      • setStringMaxLength

        public AttributeCollector setStringMaxLength​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                     Integer maxLength)
        Setter for ""maxLength"" attribute.
        Parameters:
        node - schema node to set attribute on
        maxLength - attribute value to set
        Returns:
        this instance (for chaining)
      • setStringFormat

        public AttributeCollector setStringFormat​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                  String format)
        Setter for ""format"" attribute.
        Parameters:
        node - schema node to set attribute on
        format - attribute value to set
        Returns:
        this instance (for chaining)
      • setStringPattern

        public AttributeCollector setStringPattern​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                   String pattern)
        Setter for ""pattern"" attribute.
        Parameters:
        node - schema node to set attribute on
        pattern - attribute value to set
        Returns:
        this instance (for chaining)
      • setNumberInclusiveMinimum

        public AttributeCollector setNumberInclusiveMinimum​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                            BigDecimal inclusiveMinimum)
        Setter for ""minimum"" attribute.
        Parameters:
        node - schema node to set attribute on
        inclusiveMinimum - attribute value to set
        Returns:
        this instance (for chaining)
      • setNumberExclusiveMinimum

        public AttributeCollector setNumberExclusiveMinimum​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                            BigDecimal exclusiveMinimum)
        Setter for ""exclusiveMinimum"" attribute.
        Parameters:
        node - schema node to set attribute on
        exclusiveMinimum - attribute value to set
        Returns:
        this instance (for chaining)
      • setNumberInclusiveMaximum

        public AttributeCollector setNumberInclusiveMaximum​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                            BigDecimal inclusiveMaximum)
        Setter for ""maximum"" attribute.
        Parameters:
        node - schema node to set attribute on
        inclusiveMaximum - attribute value to set
        Returns:
        this instance (for chaining)
      • setNumberExclusiveMaximum

        public AttributeCollector setNumberExclusiveMaximum​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                            BigDecimal exclusiveMaximum)
        Setter for ""exclusiveMaximum"" attribute.
        Parameters:
        node - schema node to set attribute on
        exclusiveMaximum - attribute value to set
        Returns:
        this instance (for chaining)
      • setNumberMultipleOf

        public AttributeCollector setNumberMultipleOf​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                      BigDecimal multipleOf)
        Setter for ""multipleOf"" attribute.
        Parameters:
        node - schema node to set attribute on
        multipleOf - attribute value to set
        Returns:
        this instance (for chaining)
      • setArrayMinItems

        public AttributeCollector setArrayMinItems​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                   Integer minItemCount)
        Setter for ""minItems"" attribute.
        Parameters:
        node - schema node to set attribute on
        minItemCount - attribute value to set
        Returns:
        this instance (for chaining)
      • setArrayMaxItems

        public AttributeCollector setArrayMaxItems​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                   Integer maxItemCount)
        Setter for ""maxItems"" attribute.
        Parameters:
        node - schema node to set attribute on
        maxItemCount - attribute value to set
        Returns:
        this instance (for chaining)
      • setArrayUniqueItems

        public AttributeCollector setArrayUniqueItems​(com.fasterxml.jackson.databind.node.ObjectNode node,
                                                      Boolean uniqueItems)
        Setter for ""uniqueItems"" attribute.
        Parameters:
        node - schema node to set attribute on
        uniqueItems - attribute value to set
        Returns:
        this instance (for chaining)