Enum Class Primitive

java.lang.Object
java.lang.Enum<Primitive>
dk.mada.jaxrs.model.types.Primitive
All Implemented Interfaces:
Type, Serializable, Comparable<Primitive>, Constable

public enum Primitive extends Enum<Primitive> implements Type
Primitive types of the java language (plus String). There is https://swagger.io/specification/#data-types and there is https://spec.openapis.org/registry/format/ But Quarkus/smallrye-open-api implements formatted numbers as integers. https://github.com/smallrye/smallrye-open-api/pull/2128 So three combatants...
  • Enum Constant Details

    • BOOLEAN

      public static final Primitive BOOLEAN
      The boolean.
    • NOFORMAT_INT

      public static final Primitive NOFORMAT_INT
      An integer of unknown format. Generator decides how to render this.
      See Also:
    • BYTE

      public static final Primitive BYTE
      The byte via (legacy) https://swagger.io/specification/#data-types.
    • BYTE_INT

      public static final Primitive BYTE_INT
      The byte via smallrye #2128.
    • BYTE_NUMBER

      public static final Primitive BYTE_NUMBER
      The byte via https://spec.openapis.org/registry/format/.
    • SHORT

      public static final Primitive SHORT
      The short - not mapped in legacy https://swagger.io/specification/#data-types.
    • SHORT_INT

      public static final Primitive SHORT_INT
      The short via smallrye #2128.
    • SHORT_NUMBER

      public static final Primitive SHORT_NUMBER
      The byte via https://spec.openapis.org/registry/format/.
    • INT

      public static final Primitive INT
      The integer.
    • LONG

      public static final Primitive LONG
      The long.
    • FLOAT

      public static final Primitive FLOAT
      The float.
    • DOUBLE

      public static final Primitive DOUBLE
      The double.
    • STRING

      public static final Primitive STRING
      The string (not a primitive, but basically).
  • Method Details

    • values

      public static Primitive[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Primitive valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • setNoformatIntTypes

      public void setNoformatIntTypes(Primitive wantedNoformatIntPrimitive)
      Sets the primitive to use in place of integers without format. This gets set by the generator, so technically changes the constant'ness of the type. Not sure how to do it better without affecting all the call sites.
      Parameters:
      wantedNoformatIntPrimitive - the type to use for integers without format
    • getResolvedPrimitive

      public Primitive getResolvedPrimitive()
      Returns the resolved primitive for this instance. This will replace noformat-int with the actual type selected by the user.
      Returns:
      the resolved primitive for this instance
    • typeName

      public TypeName typeName()
      Returns the type name of this type.
      Specified by:
      typeName in interface Type
      Returns:
      the type name of this type
    • wrapperTypeName

      public TypeName wrapperTypeName()
      Returns the type name of the wrapper of this type.
      Specified by:
      wrapperTypeName in interface Type
      Returns:
      the type name of the wrapper of this type
    • openapiTypeFormat

      public String openapiTypeFormat()
      Returns the OpenApi type:format of this primitive.
      Returns:
      the OpenApi type:format of this primitive
    • find

      public static @Nullable Primitive find(TypeName tn)
      Finds a primitive type matching the given type name.
      Parameters:
      tn - the type name to look for
      Returns:
      the matching primitive, or null if no matches found
    • isPrimitive

      public boolean isPrimitive(Primitive primitive)
      Description copied from interface: Type
      Return true if this type is the given primitive.
      Specified by:
      isPrimitive in interface Type
      Parameters:
      primitive - the primitive to compare against
      Returns:
      true if the same primitive, otherwise false
    • isPrimitive

      public boolean isPrimitive()
      Description copied from interface: Type
      Returns true if this type is a Java primitive.
      Specified by:
      isPrimitive in interface Type
      Returns:
      true if this type is a Java primitive
    • isNumber

      public boolean isNumber()
      Returns true if this primitive is a OpenApi number. Note that there is an overlap with integer.
      Returns:
      true if this primitive is a OpenApi number