Class ModelIO<T,V,A extends V,O extends V,AB,OB>

java.lang.Object
io.smallrye.openapi.runtime.io.ModelIO<T,V,A,O,AB,OB>
All Implemented Interfaces:
JsonIO.PropertyMapper<V,OB>
Direct Known Subclasses:
APIResponsesIO, ComponentsIO, ContactIO, ContentIO, DiscriminatorIO, ExternalDocumentationIO, InfoIO, LicenseIO, MapModelIO, MediaTypeIO, OAuthFlowIO, OAuthFlowsIO, OpenAPIDefinitionIO, OperationIO, PathsIO, SecurityRequirementIO, SecurityRequirementsSetIO, ServerIO, TagIO

public abstract class ModelIO<T,V,A extends V,O extends V,AB,OB> extends Object implements JsonIO.PropertyMapper<V,OB>
  • Field Details

    • annotationName

      protected final org.jboss.jandex.DotName annotationName
    • modelName

      protected final org.jboss.jandex.DotName modelName
  • Constructor Details

    • ModelIO

      protected ModelIO(IOContext<V,A,O,AB,OB> context, org.jboss.jandex.DotName annotationName, org.jboss.jandex.DotName modelName)
  • Method Details

    • ioContext

      public IOContext<V,A,O,AB,OB> ioContext()
    • jsonIO

      public JsonIO<V,A,O,AB,OB> jsonIO()
    • scannerContext

      public AnnotationScannerContext scannerContext()
    • setIfPresent

      protected void setIfPresent(OB object, String key, Optional<? extends V> valueSource)
    • setAllIfPresent

      protected void setAllIfPresent(OB object, Optional<? extends O> valueSource)
    • optionalJsonObject

      protected Optional<OB> optionalJsonObject(Object source)
    • optionalJsonArray

      protected Optional<AB> optionalJsonArray(Object source)
    • entry

      protected static <T> Map.Entry<String,T> entry(String key, T value)
    • value

      protected <P> P value(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
    • value

      protected <P> P value(org.jboss.jandex.AnnotationInstance annotation, String propertyName, P defaultValue)
    • enumValue

      protected <P extends Enum<P>> P enumValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName, Class<P> type)
    • enumValue

      protected <P extends Enum<P>> P enumValue(V value, Class<P> type)
    • getName

      protected Optional<String> getName(org.jboss.jandex.AnnotationInstance annotation, String nameProperty)
    • getName

      protected Optional<String> getName(org.jboss.jandex.AnnotationInstance annotation)
    • not

      protected static <T> Predicate<T> not(Predicate<? super T> predicate)
    • toLinkedMap

      protected static <T> Collector<Map.Entry<String,T>,?,Map<String,T>> toLinkedMap()
      Creates a Collector for a stream of Map.Entry where the entry keys are Strings. Null map entry values are allowed, but duplicate keys will result in an IllegalStateException being thrown. This method is the equivalent of Collectors.toMap(java.util.function.Function, java.util.function.Function) where the given key and value mapping functions are simply Map.Entry.getKey() and Map.Entry.getValue(), and where null values are tolerated.
      Type Parameters:
      T - the type of the map entry values
      Returns:
      a collector allowing null values but forbidding duplicate keys.
    • getAnnotation

      public org.jboss.jandex.AnnotationInstance getAnnotation(org.jboss.jandex.AnnotationTarget target)
    • getRepeatableAnnotations

      public List<org.jboss.jandex.AnnotationInstance> getRepeatableAnnotations(org.jboss.jandex.AnnotationTarget target)
    • hasRepeatableAnnotation

      public boolean hasRepeatableAnnotation(org.jboss.jandex.AnnotationTarget target)
    • read

      public T read(org.jboss.jandex.AnnotationTarget target)
    • read

      public T read(org.jboss.jandex.AnnotationValue annotation)
    • read

      public <C extends org.eclipse.microprofile.openapi.models.Constructible> T read(Class<C> type, org.jboss.jandex.AnnotationInstance annotation)
    • setProperty

      protected boolean setProperty(T model, org.jboss.jandex.AnnotationValue value)
    • read

      public abstract T read(org.jboss.jandex.AnnotationInstance annotation)
    • readObject

      public <C extends org.eclipse.microprofile.openapi.models.Constructible> C readObject(Class<C> type, O node)
    • readJson

      protected Object readJson(V node, DataType desiredType)
    • readValue

      protected Object readValue(V node, Class<?> desiredType)
      Convert JSON value node to an object when we have a desired type

      The JSON value will be converted to the desired type if possible or returned as its native type if not.

      Parameters:
      node - the JSON node
      desiredType - the type that we want to be returned
      Returns:
      an object which represents the JSON node, which may or may not be of the desired type
    • setProperty

      protected boolean setProperty(T model, String name, V value)
    • readValue

      public T readValue(V node)
    • readObject

      public T readObject(O node)
    • write

      public Optional<? extends V> write(T model)
    • mapObject

      public Optional<V> mapObject(BaseModel<?> object)
      Description copied from interface: JsonIO.PropertyMapper
      Optionally convert the entire object to a JSON value. If no value mapping should occur, implementations should return an empty Optional.
      Specified by:
      mapObject in interface JsonIO.PropertyMapper<T,V>
      Parameters:
      object - model object that may be mapped to a JSON value
      Returns:
      an optional JSON value that is mapped from the object
    • mapProperty

      public Optional<V> mapProperty(BaseModel<?> object, String propertyName, Object propertyValue)
      Description copied from interface: JsonIO.PropertyMapper
      Optionally convert the property with given name and value to a JSON value. If no value mapping should occur, implementations should return an empty Optional.
      Specified by:
      mapProperty in interface JsonIO.PropertyMapper<T,V>
    • mapObject

      public void mapObject(BaseModel<?> object, OB nodeBuilder)
      Description copied from interface: JsonIO.PropertyMapper
      Map any additional properties from the given model object to the nodeBuilder that will be the resulting JSON value.
      Specified by:
      mapObject in interface JsonIO.PropertyMapper<T,V>
    • openApiVersion

      public OpenApiVersion openApiVersion()
    • setOpenApiVersion

      public void setOpenApiVersion(OpenApiVersion version)
    • componentsIO

      public ComponentsIO<V,A,O,AB,OB> componentsIO()
    • extDocIO

      public ExternalDocumentationIO<V,A,O,AB,OB> extDocIO()
    • openApiDefinitionIO

      public OpenAPIDefinitionIO<V,A,O,AB,OB> openApiDefinitionIO()
    • operationIO

      public OperationIO<V,A,O,AB,OB> operationIO()
    • pathItemOperationIO

      public PathItemOperationIO<V,A,O,AB,OB> pathItemOperationIO()
    • pathItemIO

      public PathItemIO<V,A,O,AB,OB> pathItemIO()
    • pathsIO

      public PathsIO<V,A,O,AB,OB> pathsIO()
    • callbackIO

      public CallbackIO<V,A,O,AB,OB> callbackIO()
    • callbackOperationIO

      public CallbackOperationIO<V,A,O,AB,OB> callbackOperationIO()
    • extensionIO

      public ExtensionIO<V,A,O,AB,OB> extensionIO()
    • headerIO

      public HeaderIO<V,A,O,AB,OB> headerIO()
    • contactIO

      public ContactIO<V,A,O,AB,OB> contactIO()
    • infoIO

      public InfoIO<V,A,O,AB,OB> infoIO()
    • licenseIO

      public LicenseIO<V,A,O,AB,OB> licenseIO()
    • linkIO

      public LinkIO<V,A,O,AB,OB> linkIO()
    • linkParameterIO

      public LinkParameterIO<V,A,O,AB,OB> linkParameterIO()
    • contentIO

      public ContentIO<V,A,O,AB,OB> contentIO()
    • discriminatorIO

      public DiscriminatorIO<V,A,O,AB,OB> discriminatorIO()
    • encodingIO

      public EncodingIO<V,A,O,AB,OB> encodingIO()
    • exampleObjectIO

      public ExampleObjectIO<V,A,O,AB,OB> exampleObjectIO()
    • mediaTypeIO

      public MediaTypeIO<V,A,O,AB,OB> mediaTypeIO()
    • schemaIO

      public SchemaIO<V,A,O,AB,OB> schemaIO()
    • parameterIO

      public ParameterIO<V,A,O,AB,OB> parameterIO()
    • requestBodyIO

      public RequestBodyIO<V,A,O,AB,OB> requestBodyIO()
    • apiResponseIO

      public APIResponseIO<V,A,O,AB,OB> apiResponseIO()
    • apiResponsesIO

      public APIResponsesIO<V,A,O,AB,OB> apiResponsesIO()
    • oauthFlowIO

      public OAuthFlowIO<V,A,O,AB,OB> oauthFlowIO()
    • oauthFlowsIO

      public OAuthFlowsIO<V,A,O,AB,OB> oauthFlowsIO()
    • oauthScopeIO

      public OAuthScopeIO<V,A,O,AB,OB> oauthScopeIO()
    • securityIO

      public SecurityIO<V,A,O,AB,OB> securityIO()
    • securityRequirementIO

      public SecurityRequirementIO<V,A,O,AB,OB> securityRequirementIO()
    • securityRequirementsSetIO

      public SecurityRequirementsSetIO<V,A,O,AB,OB> securityRequirementsSetIO()
    • securitySchemeIO

      public SecuritySchemeIO<V,A,O,AB,OB> securitySchemeIO()
    • serverIO

      public ServerIO<V,A,O,AB,OB> serverIO()
    • serverVariableIO

      public ServerVariableIO<V,A,O,AB,OB> serverVariableIO()
    • tagIO

      public TagIO<V,A,O,AB,OB> tagIO()