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 enum`
`DuckType.Types`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final Object`
`NO_METHOD`

## Constructor Summary

Constructors
Constructor
Description
`DuckType()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`asBoolean(Object value, boolean coerceType)`
`static boolean`
`asEmpty(Object value)`
`static boolean`
`asNull(Object value)`
`static Number`
`asNumber(Object value)`
`static Number`
`asNumber(Object value, boolean coerceType)`
`static String`
`asString(Object value)`
`static String`
`asString(Object value, boolean coerceType)`
`static void`
`clearCache()`
Clears the internal cache of all the underlying Types.
`protected static Method`
`findMethod(Class<?> c, DuckType.Types type)`
`protected static Object`
`get(Object value, DuckType.Types type)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### NO_METHOD

protected static final Object NO_METHOD

## Constructor Details

### DuckType

public DuckType()

## Method Details

### clearCache

public static void clearCache()
Clears the internal cache of all the underlying Types.

### asString

public static String asString(Object value)

### asString

public static String asString(Object value, boolean coerceType)

### asNull

public static boolean asNull(Object value)

### asBoolean

public static boolean asBoolean(Object value, boolean coerceType)

### asEmpty

public static boolean asEmpty(Object value)

### asNumber

public static Number asNumber(Object value)

### asNumber

public static Number asNumber(Object value, boolean coerceType)

### get

protected static Object get(Object value, DuckType.Types type)

### findMethod

protected static Method findMethod(Class<?> c, DuckType.Types type)