Package omero.gateway.util
Class PojoMapper
- java.lang.Object
-
- omero.gateway.util.PojoMapper
-
public class PojoMapper extends java.lang.Object
Helper methods to convertIObject
s into their correspondingDataObject
s.- Since:
- OME2.2
-
-
Constructor Summary
Constructors Constructor Description PojoMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends DataObject>
java.util.Collection<T>asCastedDataObjects(java.util.List objects)
Converts eachelement
of the collection into its correspondingDataObject
.static DataObject
asDataObject(omero.model.IObject object)
Converts the specifiedIObject
into its correspondingDataObject
.static <K,V extends DataObject>
java.util.Map<K,V>asDataObjectMap(java.lang.Class<K> keyKlass, java.lang.Class<V> valueKlass, java.lang.String method, java.util.List objects)
Converts each element of the list to a pair (key, value) in the map.static java.util.Map
asDataObjects(java.util.Map objects)
Converts each pair (key, value) of the map.static <T extends DataObject>
java.util.Collection<T>convertToDataObjects(java.util.Collection objects)
Converts eachelement
of the collection into its correspondingDataObject
.static java.lang.String
convertTypeForSearch(java.lang.Class nodeType)
Converts the specified type to its corresponding type for search.static java.lang.String
getGraphType(java.lang.Class<? extends DataObject> dataType)
Returns the name of the data type which has to used for Graph actions, seeRequests
static java.lang.String
getHQLEntityName(java.lang.Class<? extends omero.model.IObject> clazz)
Gets the type of an IObject class as String which can be used in HQL queries.static java.lang.Class<? extends omero.model.IObject>
getModelType(java.lang.Class<? extends DataObject> pojoType)
Converts the specified POJO into the corresponding model class.static java.lang.Class<? extends omero.model.IObject>
getModelType(java.lang.String pojoType)
Converts the specified POJO into the corresponding model class, seegetModelType(Class)
static java.lang.Class<? extends DataObject>
getPojoType(java.lang.Class<? extends omero.model.IObject> modelType)
Get the pojo type for a anIObject
class (Reverse ofgetModelType(Class)
)
-
-
-
Method Detail
-
asDataObject
public static DataObject asDataObject(omero.model.IObject object)
Converts the specifiedIObject
into its correspondingDataObject
.- Parameters:
object
- The object to convert.- Returns:
- See above.
- Throws:
java.lang.IllegalArgumentException
- If the object is null or if the typeIObject
is unknown.
-
convertToDataObjects
public static <T extends DataObject> java.util.Collection<T> convertToDataObjects(java.util.Collection objects)
Converts eachelement
of the collection into its correspondingDataObject
.- Parameters:
objects
- The set of objects to convert.- Returns:
- A set of
DataObject
s. - Throws:
java.lang.IllegalArgumentException
- If the set isnull
, doesn't containIObject
or if the typeIObject
is unknown.
-
asCastedDataObjects
public static <T extends DataObject> java.util.Collection<T> asCastedDataObjects(java.util.List objects)
Converts eachelement
of the collection into its correspondingDataObject
.- Parameters:
objects
- The set of objects to convert.- Returns:
- A set of
DataObject
s. - Throws:
java.lang.IllegalArgumentException
- If the set isnull
, doesn't containIObject
or if the typeIObject
is unknown.
-
asDataObjectMap
public static <K,V extends DataObject> java.util.Map<K,V> asDataObjectMap(java.lang.Class<K> keyKlass, java.lang.Class<V> valueKlass, java.lang.String method, java.util.List objects) throws java.lang.SecurityException, java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Converts each element of the list to a pair (key, value) in the map. The object in the list must be a IObject subclass and the key is the ID of the object.- Parameters:
keyKlass
- The class that will be the key for the mapvalueKlass
- The class that will be the value for the mapmethod
- The method name as a string that, using reflection, will be used to get the key from the object.objects
- The map of objects to convert.- Returns:
- A map of converted objects.
- Throws:
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- If the map isnull
or if the typeIObject
is unknown.
-
asDataObjects
public static java.util.Map asDataObjects(java.util.Map objects)
Converts each pair (key, value) of the map. If the key (resp. value) is anIObject
, the element is converted into its correspondingDataObject
.- Parameters:
objects
- The map of objects to convert.- Returns:
- A map of converted objects.
- Throws:
java.lang.IllegalArgumentException
- If the map isnull
or if the typeIObject
is unknown.
-
getPojoType
public static java.lang.Class<? extends DataObject> getPojoType(java.lang.Class<? extends omero.model.IObject> modelType)
Get the pojo type for a anIObject
class (Reverse ofgetModelType(Class)
)- Parameters:
modelType
- TheIObject
- Returns:
- See above
-
getModelType
public static java.lang.Class<? extends omero.model.IObject> getModelType(java.lang.String pojoType)
Converts the specified POJO into the corresponding model class, seegetModelType(Class)
- Parameters:
pojoType
- The POJO class (Either the simple or the full class name, e. g. omero.gateway.model.DatasetData or DatasetData)- Returns:
- The corresponding
IObject
class.
-
getModelType
public static java.lang.Class<? extends omero.model.IObject> getModelType(java.lang.Class<? extends DataObject> pojoType)
Converts the specified POJO into the corresponding model class. (Reverse ofgetPojoType(Class)
)- Parameters:
pojoType
- The POJO class.- Returns:
- The corresponding
IObject
class.
-
getGraphType
public static java.lang.String getGraphType(java.lang.Class<? extends DataObject> dataType)
Returns the name of the data type which has to used for Graph actions, seeRequests
- Parameters:
dataType
- The pojo type- Returns:
- See above
-
convertTypeForSearch
public static java.lang.String convertTypeForSearch(java.lang.Class nodeType)
Converts the specified type to its corresponding type for search.- Parameters:
nodeType
- The type to convert.- Returns:
- See above.
-
getHQLEntityName
public static java.lang.String getHQLEntityName(java.lang.Class<? extends omero.model.IObject> clazz)
Gets the type of an IObject class as String which can be used in HQL queries.- Parameters:
clazz
- The IObject- Returns:
- See above
-
-