net.sf.ezmorph.object

Class NumberMorpher

public final class NumberMorpher extends AbstractObjectMorpher

Morphs to a subclass of Number.
Supported types are - Byte, Short, Integer, Long, Float, BigInteger, BigtDecimal.

Author: Andres Almiray

Constructor Summary
NumberMorpher(Class type)
Creates a new morpher for the target type.
NumberMorpher(Class type, Number defaultValue)
Creates a new morpher for the target type with a default value.
The defaultValue should be of the same class as the target type.
Method Summary
booleanequals(Object obj)
NumbergetDefaultValue()
Returns the default value for this Morpher.
inthashCode()
Objectmorph(Object value)
ClassmorphsTo()
voidsetDefaultValue(Number defaultValue)
Sets the defaultValue to use if the value to be morphed is null.
The defaultValue should be of the same class as the type this morpher returns with morphsTo().

Constructor Detail

NumberMorpher

public NumberMorpher(Class type)
Creates a new morpher for the target type.

Parameters: type must be a primitive or wrapper type. BigDecimal and BigInteger are also supported.

NumberMorpher

public NumberMorpher(Class type, Number defaultValue)
Creates a new morpher for the target type with a default value.
The defaultValue should be of the same class as the target type.

Parameters: type must be a primitive or wrapper type. BigDecimal and BigInteger are also supported. defaultValue return value if the value to be morphed is null

Method Detail

equals

public boolean equals(Object obj)

getDefaultValue

public Number getDefaultValue()
Returns the default value for this Morpher.

hashCode

public int hashCode()

morph

public Object morph(Object value)

morphsTo

public Class morphsTo()

setDefaultValue

public void setDefaultValue(Number defaultValue)
Sets the defaultValue to use if the value to be morphed is null.
The defaultValue should be of the same class as the type this morpher returns with morphsTo().

Parameters: defaultValue return value if the value to be morphed is null

Copyright © 2006-2010. All Rights Reserved.