Package org.apache.velocity.util
Class DuckType
- java.lang.Object
-
- org.apache.velocity.util.DuckType
-
public class DuckType extends Object
Support for getAs<java.lang.reflect.Type>() convention for rendering (String), evaluating (Boolean) or doing math with (Number) references.- Since:
- 2.0
- Author:
- Nathan Bubna
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDuckType.Types
-
Constructor Summary
Constructors Constructor Description DuckType()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanasBoolean(Object value, boolean coerceType)static booleanasEmpty(Object value)static booleanasNull(Object value)static NumberasNumber(Object value)static NumberasNumber(Object value, boolean coerceType)static StringasString(Object value)static StringasString(Object value, boolean coerceType)static voidclearCache()Clears the internal cache of all the underlying Types.protected static MethodfindMethod(Class<?> c, DuckType.Types type)protected static Objectget(Object value, DuckType.Types type)
-
-
-
Field Detail
-
NO_METHOD
protected static final Object NO_METHOD
-
-
Method Detail
-
clearCache
public static void clearCache()
Clears the internal cache of all the underlying Types.
-
asNull
public static boolean asNull(Object value)
-
asBoolean
public static boolean asBoolean(Object value, boolean coerceType)
-
asEmpty
public static boolean asEmpty(Object value)
-
get
protected static Object get(Object value, DuckType.Types type)
-
findMethod
protected static Method findMethod(Class<?> c, DuckType.Types type)
-
-