getPersistenceDelegate
Returns the persistence delegate for the given type. The persistence delegate is calculated by applying the following rules in order:
- If a persistence delegate is associated with the given type by using the
setPersistenceDelegate(java.lang.Class<?>, java.beans.PersistenceDelegate) method it is returned.
- A persistence delegate is then looked up by the name composed of the fully qualified name of the given type and the "PersistenceDelegate" postfix. For example, a persistence delegate for the
Bean class should be named BeanPersistenceDelegate and located in the same package.
public class Bean { ... }
public class BeanPersistenceDelegate { ... } The instance of the BeanPersistenceDelegate class is returned for the Bean class.
- If the type is
null , a shared internal persistence delegate is returned that encodes null value.
- If the type is an
enum declaration, a shared internal persistence delegate is returned that encodes constants of this enumeration by their names.
- If the type is a primitive type or the corresponding wrapper, a shared internal persistence delegate is returned that encodes values of the given type.
- If the type is an array, a shared internal persistence delegate is returned that encodes an array of the appropriate type and length, and each of its elements as if they are properties.
- If the type is a proxy, a shared internal persistence delegate is returned that encodes a proxy instance by using the
Proxy.newProxyInstance(java.lang.ClassLoader, java.lang.Class<?>[], java.lang.reflect.InvocationHandler) method.
- If the
BeanInfo for this type has a BeanDescriptor which defined a "persistenceDelegate" attribute, the value of this named attribute is returned.
- In all other cases the default persistence delegate is returned. The default persistence delegate assumes the type is a JavaBean, implying that it has a default constructor and that its state may be characterized by the matching pairs of "setter" and "getter" methods returned by the
Introspector class. The default constructor is the constructor with the greatest number of parameters that has the ConstructorProperties annotation. If none of the constructors has the ConstructorProperties annotation, then the nullary constructor (constructor with no parameters) will be used. For example, in the following code fragment, the nullary constructor for the Foo class will be used, while the two-parameter constructor for the Bar class will be used.
public class Foo {
public Foo() { ... }
public Foo(int x) { ... }
}
public class Bar {
public Bar() { ... }
@ConstructorProperties({"x"})
public Bar(int x) { ... }
@ConstructorProperties({"x", "y"})
public Bar(int x, int y) { ... }
}
- Parameters:
-
type - the class of the objects
- Returns:
- the persistence delegate for the given type
- See Also:
-
|
|