Package omero.gateway.util
Class PojoMapper
- java.lang.Object
-
- omero.gateway.util.PojoMapper
-
public class PojoMapper extends java.lang.ObjectHelper methods to convertIObjects into their correspondingDataObjects.- 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 eachelementof the collection into its correspondingDataObject.static DataObjectasDataObject(omero.model.IObject object)Converts the specifiedIObjectinto 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.MapasDataObjects(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 eachelementof the collection into its correspondingDataObject.static java.lang.StringconvertTypeForSearch(java.lang.Class nodeType)Converts the specified type to its corresponding type for search.static java.lang.StringgetGraphType(java.lang.Class<? extends DataObject> dataType)Returns the name of the data type which has to used for Graph actions, seeRequestsstatic java.lang.StringgetHQLEntityName(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 anIObjectclass (Reverse ofgetModelType(Class))
-
-
-
Method Detail
-
asDataObject
public static DataObject asDataObject(omero.model.IObject object)
Converts the specifiedIObjectinto its correspondingDataObject.- Parameters:
object- The object to convert.- Returns:
- See above.
- Throws:
java.lang.IllegalArgumentException- If the object is null or if the typeIObjectis unknown.
-
convertToDataObjects
public static <T extends DataObject> java.util.Collection<T> convertToDataObjects(java.util.Collection objects)
Converts eachelementof the collection into its correspondingDataObject.- Parameters:
objects- The set of objects to convert.- Returns:
- A set of
DataObjects. - Throws:
java.lang.IllegalArgumentException- If the set isnull, doesn't containIObjector if the typeIObjectis unknown.
-
asCastedDataObjects
public static <T extends DataObject> java.util.Collection<T> asCastedDataObjects(java.util.List objects)
Converts eachelementof the collection into its correspondingDataObject.- Parameters:
objects- The set of objects to convert.- Returns:
- A set of
DataObjects. - Throws:
java.lang.IllegalArgumentException- If the set isnull, doesn't containIObjector if the typeIObjectis 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.NoSuchMethodExceptionjava.lang.SecurityExceptionjava.lang.reflect.InvocationTargetExceptionjava.lang.IllegalAccessExceptionjava.lang.IllegalArgumentExceptionjava.lang.IllegalArgumentException- If the map isnullor if the typeIObjectis 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 isnullor if the typeIObjectis unknown.
-
getPojoType
public static java.lang.Class<? extends DataObject> getPojoType(java.lang.Class<? extends omero.model.IObject> modelType)
Get the pojo type for a anIObjectclass (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
IObjectclass.
-
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
IObjectclass.
-
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
-
-