java.lang.Object
org.refcodes.web.JsonMediaTypeFactory
- All Implemented Interfaces:
org.refcodes.factory.MarshalFactory<String>
,org.refcodes.factory.MarshalFactory.MarshalFactoryComplement<InputStream>
,org.refcodes.factory.MarshalFactory.MarshalFactoryComposite<String,
,InputStream> org.refcodes.factory.UnmarshalFactory<String>
,org.refcodes.factory.UnmarshalFactory.UnmarshalFactoryComplement<InputStream>
,org.refcodes.factory.UnmarshalFactory.UnmarshalFactoryComposite<String,
,InputStream> MediaTypeFactory
,MediaTypesAccessor
Implements the
MediaTypeFactory
for Media-Type "application/json" (
MediaType.APPLICATION_JSON
). CAUTION: This implementation uses field
resolution instead of getter/setter property resolution as of the used
marshaling API.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.factory.MarshalFactory
org.refcodes.factory.MarshalFactory.MarshalFactoryComplement<C extends Object>, org.refcodes.factory.MarshalFactory.MarshalFactoryComposite<T extends Object,
C extends Object> Nested classes/interfaces inherited from interface org.refcodes.web.MediaTypesAccessor
MediaTypesAccessor.MediaTypesBuilder<B extends MediaTypesAccessor.MediaTypesBuilder<B>>, MediaTypesAccessor.MediaTypesMutator, MediaTypesAccessor.MediaTypesProperty
-
Field Summary
Fields inherited from interface org.refcodes.web.MediaTypeFactory
ARRAY_SELECTOR, COLLECTION_SELECTOR, TYPE_ANNOTATION, VALUE_SELECTOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the Media-Types from the Media-Types property.protected String
toElementName
(Class<?> aClass) Creates an element name for the class.toMarshaled
(Object aObject) protected String
toPlainJson
(String aJson) Removes any prefixed variable declaration.protected String
Unboxes any enveloped JSON.<T> T
toUnmarshaled
(String aHttpBody, Class<T> aType) protected String
toVariableDeclaration
(Class<?> aClass) Returns the JSON specific assignment declaration for the given class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.factory.MarshalFactory
toMarshaled
Methods inherited from interface org.refcodes.web.MediaTypeFactory
fromMarshaled, fromMarshaled, fromMarshaled, fromMarshaled, fromUnmarshaled, fromUnmarshaled
Methods inherited from interface org.refcodes.factory.UnmarshalFactory
toUnmarshaled, toUnmarshaled, toUnmarshaled
-
Constructor Details
-
JsonMediaTypeFactory
public JsonMediaTypeFactory()Constructs theJsonMediaTypeFactory
.
-
-
Method Details
-
getMediaTypes
Retrieves the Media-Types from the Media-Types property.- Specified by:
getMediaTypes
in interfaceMediaTypesAccessor
- Returns:
- The Media-Types stored by the Media-Types property.
-
toMarshaled
- Specified by:
toMarshaled
in interfaceorg.refcodes.factory.MarshalFactory<String>
- Throws:
org.refcodes.exception.MarshalException
-
toUnmarshaled
public <T> T toUnmarshaled(String aHttpBody, Class<T> aType) throws org.refcodes.exception.UnmarshalException - Specified by:
toUnmarshaled
in interfaceorg.refcodes.factory.UnmarshalFactory<String>
- Throws:
org.refcodes.exception.UnmarshalException
-
toPlainJson
Removes any prefixed variable declaration.- Parameters:
aJson
- The JSON from which to remove any prefixed variable declaration.- Returns:
- The JSON without any prefixed variable declaration.
-
toUnboxed
Unboxes any enveloped JSON.- Parameters:
aJson
- The JSON to be unboxed.- Returns:
- The unboxed JSON.
-
toElementName
Creates an element name for the class.- Parameters:
aClass
- The class from which to retrieve the element name.- Returns:
- The element name for the class.
-
toVariableDeclaration
Returns the JSON specific assignment declaration for the given class.- Parameters:
aClass
- The class for which to construct the assignment declaration.- Returns:
- The according assignment declaration.
-