Class ModelStorageClassConverter

java.lang.Object
org.spdx.library.model.ModelStorageClassConverter

public class ModelStorageClassConverter
extends Object
This static helper class converts objects used in the model to and from objects used by the SPI / storage class. The storage SPI supports the following types: String Boolean TypedValue - this class is used to store most (if not all) of the ModelStore classes IndividualUriValue - this interface type represents a value which can be stored as a unique value. It is used to represent Enum types in the model and the ExternalSpdxElement model object. Note that IndividualUriValues can not have any properties associated with them.
Author:
Gary O'Neall
  • Constructor Details

  • Method Details

    • reset

      public static void reset()
    • storedObjectToModelObject

      public static Object storedObjectToModelObject​(Object value, String documentUri, IModelStore modelStore, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException
      Converts any typed value or individual value objects to a ModelObject, returning an existing ModelObject if it exists or creates a new ModelObject
      Parameters:
      value - Value which may be a TypedValue
      documentUri - Document URI to use when converting a typedValue
      modelStore - ModelStore to use in fetching or creating
      copyManager - if not null, copy any referenced ID's outside of this document/model store
      Returns:
      the object itself unless it is a TypedValue, in which case a ModelObject is returned
      Throws:
      InvalidSPDXAnalysisException
    • optionalStoredObjectToModelObject

      public static Optional<Object> optionalStoredObjectToModelObject​(Optional<Object> value, String stDocumentUri, IModelStore stModelStore, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException
      Converts any typed value or IndividualValue objects to a ModelObject, returning an existing ModelObject if it exists or creates a new ModelObject
      Parameters:
      value - Value which may be a TypedValue
      stDocumentUri - Document URI to use when converting a typedValue
      stModelStore - ModelStore to use in fetching or creating
      copyManager - if not null, copy any referenced ID's outside of this document/model store
      Returns:
      the object itself unless it is a TypedValue, in which case a ModelObject is returned
      Throws:
      InvalidSPDXAnalysisException
    • modelObjectToStoredObject

      public static Object modelObjectToStoredObject​(Object value, String stDocumentUri, IModelStore stModelStore, ModelCopyManager copyManager) throws InvalidSPDXAnalysisException
      Converts a stored object to it's appropriate model object type
      Parameters:
      value -
      stDocumentUri -
      stModelStore -
      copyManager - if not null, copy any referenced ID's outside of this document/model store
      Returns:
      Model Object appropriate type
      Throws:
      InvalidSPDXAnalysisException
    • modelClassToStoredClass

      public static Class<?> modelClassToStoredClass​(Class<?> clazz)
      Convert the class to the approrpriate stored class
      Parameters:
      clazz - Model class
      Returns:
      class compatible with stored classes