Package org.openehealth.ipf.commons.core
Class ContentMap
- java.lang.Object
-
- org.openehealth.ipf.commons.core.ContentMap
-
-
Constructor Summary
Constructors Constructor Description ContentMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getContent(Class<T> targetType)
Returns document content of the given type.int
getContentsCount()
Returns count of currently available content types in this content map.static TypeConverter
getConversionService()
Returns conversion service for document contents.boolean
hasContent(Class<?> key)
Returnstrue
when this content map already contains an element of the given type.<T> T
removeContent(Class<T> key)
Removes (invalidates) document content of the given type.<T> T
setContent(Class<T> key, T content)
Adds or replaces document content of the given type.static void
setConversionService(TypeConverter conversionService)
Sets conversion service for document contents.
-
-
-
Method Detail
-
getContent
public <T> T getContent(Class<T> targetType)
Returns document content of the given type.- Type Parameters:
T
- inferred desired content type.- Parameters:
targetType
- desired content type.- Returns:
- content of the given type, or
null
when content of the desired type is neither already present nor can be automatically generated from an existing one.
-
setContent
public <T> T setContent(Class<T> key, T content)
Adds or replaces document content of the given type.- Type Parameters:
T
- inferred content type.- Parameters:
key
- content type.content
- content;null
values are not allowed.- Returns:
- the given content, as convenience.
-
removeContent
public <T> T removeContent(Class<T> key)
Removes (invalidates) document content of the given type.- Type Parameters:
T
- inferred content type.- Parameters:
key
- content type.- Returns:
- Obsolete content of the given type, or
null
, when no content of the given type was present.
-
hasContent
public boolean hasContent(Class<?> key)
Returnstrue
when this content map already contains an element of the given type.
-
getContentsCount
public int getContentsCount()
Returns count of currently available content types in this content map.
-
getConversionService
public static TypeConverter getConversionService()
Returns conversion service for document contents.
-
setConversionService
public static void setConversionService(TypeConverter conversionService)
Sets conversion service for document contents.
-
-