| java.lang.Object it.biobytes.ammentos.fieldtypes.FactoryType
FactoryType | public class FactoryType implements FieldType(Code) | | Simple field type is one that adheres to the following API. It needs to
support the valueOf(String) static factory method.
The method is static and thus could not be specified as an interface; therefore
this method is checked for and accessed using the java reflection API.
Usage:
- Add
valueOf( extends Object>) factory method to class you wish to
persist as a field.
public class MyClass {
... // Class implementation methods using the normal Ammentos persistance pattern
//
// Factory method to instantiate a new MyClass object from a byte[].
// Any number of valueOf( extends Object> ) can be declared, they will all be checked
// in sequence until value is returned and no Exception are thrown.
//
public static MyClass valueOf(byte[] data) {
// Use private constructor to instatiate.
return new MyClass(data);
}
}
- In your persistant class where we wish to use MyClass defined above, we simply annotate it
with @PersistentField and leave the default type as AUTO and let Ammentos check if the class
defines the Ammentos FactoryType API. Requires the class to only define valueOf( extends Object>)
static method.
primaryKey="id",
sourceDomain="myDbTable"
}
public class MyPersistentClass {
automatic=true, // Value will be automatically generated
automaticType=EXTERNAL // Generated by external persistor not the frame work. DB in our case.
)
private int id;
author: Mark Bednarczyk |
getSqlType | public int getSqlType()(Code) | | |
isFactoryType | public static boolean isFactoryType(Class mappedClass)(Code) | | Checks if the specified type can be used by FactoryType type.
Parameters: mappedClass - class to check if it supports the required API. true if mappedClass support the required API and can be instantiatedwith FactoryType without throwing and exception. If the required API isnot implemented then false is returned. |
isNumeric | public boolean isNumeric()(Code) | | |
|
|