public abstract class ConverterHelper extends Helper
Constructor and Description |
---|
ConverterHelper() |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<java.lang.Class<?>> |
addObjectClass(java.util.List<java.lang.Class<?>> objectClasses,
java.lang.Class<?> objectClass)
Adds an object class to the given list.
|
protected java.util.List<VariantInfo> |
addVariant(java.util.List<VariantInfo> variants,
VariantInfo userVariant)
Adds a variant to the given list.
|
java.util.List<VariantInfo> |
addVariants(java.lang.Class<?> sourceClass,
Variant targetVariant,
java.util.List<VariantInfo> variants)
Returns the list of variants that can be converted from a given object
class.
|
abstract java.util.List<java.lang.Class<?>> |
getObjectClasses(Variant source)
Returns the list of object classes that can be converted from a given
variant.
|
abstract java.util.List<VariantInfo> |
getVariants(java.lang.Class<?> source)
Returns the list of variants that can be converted from a given object
class.
|
java.util.List<VariantInfo> |
getVariants(java.lang.Class<?> sourceClass,
Variant targetVariant)
Returns the list of variants that can be converted from a given object
class by a specific converter helper.
|
abstract float |
score(java.lang.Object source,
Variant target,
Resource resource)
Scores the affinity of this helper with the source class.
|
abstract <T> float |
score(Representation source,
java.lang.Class<T> target,
Resource resource)
Scores the affinity of this helper with the source class.
|
abstract <T> T |
toObject(Representation source,
java.lang.Class<T> target,
Resource resource)
Converts a Representation into a regular Java object.
|
abstract Representation |
toRepresentation(java.lang.Object source,
Variant target,
Resource resource)
Converts a regular Java object into a Representation.
|
<T> void |
updatePreferences(java.util.List<Preference<MediaType>> preferences,
java.lang.Class<T> entity)
Updates the preferences of the given
ClientInfo object with
conversion capabilities for the given entity class. |
void |
updatePreferences(java.util.List<Preference<MediaType>> preferences,
MediaType mediaType,
float score)
Updates the preferences of the given
ClientInfo object with
conversion capabilities for the given entity class. |
protected java.util.List<java.lang.Class<?>> addObjectClass(java.util.List<java.lang.Class<?>> objectClasses, java.lang.Class<?> objectClass)
objectClasses
- The object classes list to update or null.objectClass
- The object class to add.protected java.util.List<VariantInfo> addVariant(java.util.List<VariantInfo> variants, VariantInfo userVariant)
variants
- The variants list to update or null.userVariant
- The variant to add if not null.public java.util.List<VariantInfo> addVariants(java.lang.Class<?> sourceClass, Variant targetVariant, java.util.List<VariantInfo> variants) throws java.io.IOException
sourceClass
- The source class.targetVariant
- The expected representation metadata.variants
- The variants list to update.java.io.IOException
public abstract java.util.List<java.lang.Class<?>> getObjectClasses(Variant source)
source
- The source variant.public abstract java.util.List<VariantInfo> getVariants(java.lang.Class<?> source) throws java.io.IOException
source
- The source object class.java.io.IOException
public java.util.List<VariantInfo> getVariants(java.lang.Class<?> sourceClass, Variant targetVariant) throws java.io.IOException
sourceClass
- The source class.targetVariant
- The expected representation metadata.java.io.IOException
public abstract float score(java.lang.Object source, Variant target, Resource resource)
source
- The source object to convert.target
- The expected representation metadata.resource
- The calling resource.public abstract <T> float score(Representation source, java.lang.Class<T> target, Resource resource)
source
- The source representation to convert.target
- The expected class of the Java object.resource
- The calling resource.public abstract <T> T toObject(Representation source, java.lang.Class<T> target, Resource resource) throws java.io.IOException
T
- The expected class of the Java object.source
- The source representation to convert.target
- The expected class of the Java object.resource
- The calling resource.java.io.IOException
public abstract Representation toRepresentation(java.lang.Object source, Variant target, Resource resource) throws java.io.IOException
source
- The source object to convert.target
- The expected representation metadata.resource
- The calling resource.java.io.IOException
public <T> void updatePreferences(java.util.List<Preference<MediaType>> preferences, java.lang.Class<T> entity)
ClientInfo
object with
conversion capabilities for the given entity class.preferences
- The media type preferences.entity
- The entity class to convert.public void updatePreferences(java.util.List<Preference<MediaType>> preferences, MediaType mediaType, float score)
ClientInfo
object with
conversion capabilities for the given entity class.preferences
- The media type preferences.mediaType
- The media type to update to add to the preferences.score
- The media type score to use as a quality score.Copyright © 2005-2020 Restlet.