Package org.spdx.library.model
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 Summary
Constructors Constructor Description ModelStorageClassConverter() -
Method Summary
Modifier and Type Method Description static Class<?>modelClassToStoredClass(Class<?> clazz)Convert the class to the approrpriate stored classstatic ObjectmodelObjectToStoredObject(Object value, String stDocumentUri, IModelStore stModelStore, ModelCopyManager copyManager)Converts a stored object to it's appropriate model object typestatic Optional<Object>optionalStoredObjectToModelObject(Optional<Object> value, String stDocumentUri, IModelStore stModelStore, ModelCopyManager copyManager)Converts any typed value or IndividualValue objects to a ModelObject, returning an existing ModelObject if it exists or creates a new ModelObjectstatic voidreset()static ObjectstoredObjectToModelObject(Object value, String documentUri, IModelStore modelStore, ModelCopyManager copyManager)Converts any typed value or individual value objects to a ModelObject, returning an existing ModelObject if it exists or creates a new ModelObject
-
Constructor Details
-
ModelStorageClassConverter
public ModelStorageClassConverter()
-
-
Method Details
-
reset
public static void reset() -
storedObjectToModelObject
public static Object storedObjectToModelObject(Object value, String documentUri, IModelStore modelStore, ModelCopyManager copyManager) throws InvalidSPDXAnalysisExceptionConverts 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 TypedValuedocumentUri- Document URI to use when converting a typedValuemodelStore- ModelStore to use in fetching or creatingcopyManager- 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 InvalidSPDXAnalysisExceptionConverts 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 TypedValuestDocumentUri- Document URI to use when converting a typedValuestModelStore- ModelStore to use in fetching or creatingcopyManager- 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 InvalidSPDXAnalysisExceptionConverts 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
Convert the class to the approrpriate stored class- Parameters:
clazz- Model class- Returns:
- class compatible with stored classes
-