Package org.somda.sdc.common.util
Class JaxbUtilImpl
java.lang.Object
org.somda.sdc.common.util.JaxbUtilImpl
- All Implemented Interfaces:
JaxbUtil
Default implementation of JaxbUtil.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>extractElement(Object element, Class<T> typeClass) Tries to cast the element to given type object and returns it as an Optional.<T> Optional<T>extractElement(Object element, QName elementType) Tries to cast the element to a JAXBElement object with given QName type and returns it as an Optional.<T> Optional<T>extractElement(Object element, QName elementType, Class<T> typeClass) Same asJaxbUtil.extractElement(Object, QName)but with QName JAXB type class in addition.<T> Optional<T>extractFirstElementFromAny(List<Object> anyList, Class<T> typeClass) Same asJaxbUtil.extractFirstElementFromAny(List, QName, Class), but without comparing QName in advance.<T> Optional<T>extractFirstElementFromAny(List<Object> anyList, QName elementType, Class<T> typeClass) From a list ofJAXBElementobjects, this function retrieves the first element in the list
-
Constructor Details
-
JaxbUtilImpl
public JaxbUtilImpl()
-
-
Method Details
-
extractElement
Description copied from interface:JaxbUtilSame asJaxbUtil.extractElement(Object, QName)but with QName JAXB type class in addition.- Specified by:
extractElementin interfaceJaxbUtil- Type Parameters:
T- the generic type to cast to.- Parameters:
element- the element to inspect.elementType- the QName type specification.typeClass- Java JAXB class that matches elementType.- Returns:
- JAXBElement.getValue() or Optional.empty() on error.
-
extractElement
Description copied from interface:JaxbUtilTries to cast the element to given type object and returns it as an Optional.- Specified by:
extractElementin interfaceJaxbUtil- Type Parameters:
T- the casted generic type.- Parameters:
element- the element to inspect.typeClass- the QName type specification.- Returns:
- JAXBElement.getValue() or Optional.empty() on error.
-
extractElement
Description copied from interface:JaxbUtilTries to cast the element to a JAXBElement object with given QName type and returns it as an Optional.- Specified by:
extractElementin interfaceJaxbUtil- Type Parameters:
T- the generic type to cast to.- Parameters:
element- the element to inspect.elementType- the QName type specification.- Returns:
- JAXBElement.getValue() or Optional.empty() on error.
-
extractFirstElementFromAny
public <T> Optional<T> extractFirstElementFromAny(List<Object> anyList, QName elementType, Class<T> typeClass) Description copied from interface:JaxbUtilFrom a list ofJAXBElementobjects, this function retrieves the first element in the listAdditionally, it tries to cast it to the QName type given by elementType.
- Specified by:
extractFirstElementFromAnyin interfaceJaxbUtil- Type Parameters:
T- the generic type to cast to.- Parameters:
anyList- a list ofJAXBElementobjects.elementType- the QName type specification.typeClass- Java JAXB class that matches elementType.- Returns:
- Optional of the first element's
JAXBElement.getValue()orOptional.empty()if the list is empty or an error occurred.
-
extractFirstElementFromAny
Description copied from interface:JaxbUtilSame asJaxbUtil.extractFirstElementFromAny(List, QName, Class), but without comparing QName in advance.- Specified by:
extractFirstElementFromAnyin interfaceJaxbUtil- Type Parameters:
T- the generic type to cast to.- Parameters:
anyList- a list ofJAXBElementobjects.typeClass- Java JAXB class that matches elementType.- Returns:
- Optional of the first element's
JAXBElement.getValue()orOptional.empty()if the list is empty or an error occurred.
-