Package org.zkoss.bind.proxy
Class ProxyHelper
- java.lang.Object
-
- org.zkoss.bind.proxy.ProxyHelper
-
public class ProxyHelper extends java.lang.Object
A proxy helper class to create a proxy cache mechanism for Set, List, Collection, Map, and POJO.- Since:
- 8.0.0
- Author:
- jumperchen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ProxyHelper.ProxyDecorator
An interface to decorate theProxyObject
for some purposes, like providing custom validation logic or adding extra handler on it.
-
Constructor Summary
Constructors Constructor Description ProxyHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addIgnoredProxyClass(java.lang.Class<?> type)
Adds an ignored proxy class type.static void
addIgnoredSuperProxyClass(java.lang.Class<?> type)
Adds an ignored super proxy class type.static java.lang.String
capitalize(java.lang.String prefix, java.lang.String attr)
Internal use only.static <T> T
createFormProxy(T origin, java.lang.Class<?> type)
Creates a proxy form object from the given origin object, if any.static <T> T
createFormProxy(T origin, java.lang.Class<?> type, java.lang.Class[] interfaces)
Creates a proxy form object from the given origin object, if any.static <T> T
createProxyIfAny(T origin)
Creates a proxy object from the given origin object, if any.static <T> T
createProxyIfAny(T origin, java.lang.annotation.Annotation[] annotations)
Creates a proxy object from the given origin object, if any.static <T> T
getOriginObject(T origin)
Internal use only.static boolean
isAttribute(java.lang.reflect.Method method)
Internal use only.static boolean
isImmutable(java.lang.Object origin)
Returns whether the given origin object is immutable.static java.lang.String
toAttrName(java.lang.reflect.Method method)
Internal use only.static java.lang.String
toAttrName(java.lang.reflect.Method method, int prefix)
Internal use only.static java.lang.String
toGetter(java.lang.String attr)
Internal use only.static java.lang.String
toSetter(java.lang.String attr)
Internal use only.
-
-
-
Method Detail
-
createProxyIfAny
public static <T> T createProxyIfAny(T origin)
Creates a proxy object from the given origin object, if any.
-
createProxyIfAny
public static <T> T createProxyIfAny(T origin, java.lang.annotation.Annotation[] annotations)
Creates a proxy object from the given origin object, if any.- Parameters:
annotations
- the annotations of the caller method to indicate whether the elements of the collection or Map type can proxy deeply, if any. (Optional) LikeImmutableElements
-
addIgnoredProxyClass
public static void addIgnoredProxyClass(java.lang.Class<?> type)
Adds an ignored proxy class type. Once the data binder try to create a proxy object for the form binding, it will check whether the origin class type should be ignored.Default it will apply these classes from the library property
org.zkoss.bind.proxy.IgnoredProxyClasses
-
addIgnoredSuperProxyClass
public static void addIgnoredSuperProxyClass(java.lang.Class<?> type)
Adds an ignored super proxy class type. Once the data binder try to create a proxy object for the form binding, it will check the super classes of the origin class type. If one of the super classes is in the ignored super classes, the origin class type should be ignored.Default it will apply these classes from the library property
org.zkoss.bind.proxy.IgnoredSuperProxyClasses
- Since:
- 8.6.1
-
isImmutable
public static boolean isImmutable(java.lang.Object origin)
Returns whether the given origin object is immutable.
-
getOriginObject
public static <T> T getOriginObject(T origin)
Internal use only.
-
createFormProxy
public static <T> T createFormProxy(T origin, java.lang.Class<?> type)
Creates a proxy form object from the given origin object, if any.- Parameters:
origin
- the origin data objecttype
- the class type of the data object
-
createFormProxy
public static <T> T createFormProxy(T origin, java.lang.Class<?> type, java.lang.Class[] interfaces)
Creates a proxy form object from the given origin object, if any.- Parameters:
origin
- the origin data objecttype
- the class type of the data objectinterfaces
- the interface type of the data object, if any.- Since:
- 8.0.1
-
toSetter
public static java.lang.String toSetter(java.lang.String attr)
Internal use only.
-
toGetter
public static java.lang.String toGetter(java.lang.String attr)
Internal use only.
-
capitalize
public static java.lang.String capitalize(java.lang.String prefix, java.lang.String attr)
Internal use only.
-
isAttribute
public static boolean isAttribute(java.lang.reflect.Method method)
Internal use only.
-
toAttrName
public static java.lang.String toAttrName(java.lang.reflect.Method method, int prefix)
Internal use only.
-
toAttrName
public static java.lang.String toAttrName(java.lang.reflect.Method method)
Internal use only.
-
-