Joda System API

org.joda.property.impl.type
Class DefaultDecimalProperty

java.lang.Object
  |
  +--org.joda.property.impl.AbstractModelElement
        |
        +--org.joda.property.impl.AbstractProperty
              |
              +--org.joda.property.impl.type.AbstractNumericProperty
                    |
                    +--org.joda.property.impl.type.DefaultDecimalProperty
All Implemented Interfaces:
java.lang.Comparable, DataProperty, DecimalProperty, InitializableProperty, ModelElement, NumericProperty, Property, Property.Internal, java.io.Serializable

public class DefaultDecimalProperty
extends AbstractNumericProperty
implements DecimalProperty

Default implementation of a Decimal property.

Data is stored in the associated PropertyData object as a BigDecimal object. This is immutable so can be directly returned.

Author:
Stephen Colebourne
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.joda.property.Property
Property.Internal
 
Field Summary
 
Fields inherited from interface org.joda.property.type.DecimalProperty
DEFAULT_TYPE
 
Constructor Summary
DefaultDecimalProperty()
          Constructor
 
Method Summary
protected  void add(java.math.BigDecimal amount)
          Add an amount to the decimal
 void add(double amount)
          Add to the property's value
 void add(long amount)
          Add to the property's value
 void add(java.lang.Object amount)
          Add to the property's value
 int compareTo(java.lang.Object object)
           
protected  java.math.BigDecimal convertObjectToBigDecimal(java.lang.Object object)
          Convert an Object to a typecast BigDecimal, throwing an exception if unable to convert.
protected  void divideBy(java.math.BigDecimal amount)
          Divide the decimal by an amount
 void divideBy(double amount)
          Divide the property's value by the specified argument
 void divideBy(long amount)
          Divide the property's value by the specified argument
 void divideBy(java.lang.Object amount)
          Divide the property's value by the specified argument
 java.math.BigDecimal get()
          Get the value as a BigDecimal
 java.lang.Class getPropertyType()
          Get the type of the property.
protected  void multiplyBy(java.math.BigDecimal amount)
          Multiply the decimal by an amount
 void multiplyBy(double amount)
          Multiply the property's value by the specified argument
 void multiplyBy(long amount)
          Multiply the property's value by the specified argument
 void multiplyBy(java.lang.Object amount)
          Multiply the property's value by the specified argument
 void negate()
          Negate the current value of the property.
 void set(double propertyValue)
          Set the property's value.
 void set(long propertyValue)
          Set the property's value.
 void set(java.lang.Object propertyValue)
          Set the property's value as an object.
 void subtract(double amount)
          Subtract from the property's value
 void subtract(long amount)
          Subtract from the property's value
 void subtract(java.lang.Object amount)
          Subtract from the property's value
 java.math.BigDecimal toBigDecimal()
          Get the value as a BigDecimal
 
Methods inherited from class org.joda.property.impl.type.AbstractNumericProperty
compareTo, compareTo, doubleValue, equals, equals, floatValue, getInternal, intValue, isGreaterThan, isGreaterThan, isGreaterThan, isLessThan, isLessThan, isLessThan, longValue, setInternal, toDouble, toFloat, toInteger, toLong, toNumber, toObject
 
Methods inherited from class org.joda.property.impl.AbstractProperty
addPropertyChangeListener, bean, checkArgumentNotNull, checkModifiable, checkValueNotNull, checkValueNotNull, cloneDeep, convertObject, createClonedProperty, data, equals, equalsValue, firePropertyChange, firePropertyChange, getContentName, getContentType, getPropertyName, getThis, hashCode, initBeanCreated, initPropertyCreated, isModifiable, isNull, isReadOnly, populateClonedProperty, removePropertyChangeListener, setModifiable, setReadOnly, toDataString, toString
 
Methods inherited from class org.joda.property.impl.AbstractModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.property.type.NumericProperty
compareTo, compareTo, doubleValue, equals, equals, floatValue, intValue, isGreaterThan, isGreaterThan, isGreaterThan, isLessThan, isLessThan, isLessThan, longValue, toDouble, toFloat, toInteger, toLong, toNumber
 
Methods inherited from interface org.joda.property.type.DataProperty
toDataString
 
Methods inherited from interface org.joda.property.Property
addPropertyChangeListener, bean, equals, equalsValue, firePropertyChange, getContentName, getContentType, getPropertyName, hashCode, isModifiable, isNull, isReadOnly, removePropertyChangeListener, setModifiable, setReadOnly, toObject, toString
 
Methods inherited from interface org.joda.property.ModelElement
getAttribute, getAttributeCount, getAttributeMap, setAttribute
 

Constructor Detail

DefaultDecimalProperty

public DefaultDecimalProperty()
Constructor

Method Detail

getPropertyType

public java.lang.Class getPropertyType()
Get the type of the property. A method String getFoo() has a property type of String.class.

Specified by:
getPropertyType in interface Property
Returns:
the property type

toBigDecimal

public java.math.BigDecimal toBigDecimal()
Get the value as a BigDecimal

Specified by:
toBigDecimal in interface NumericProperty
Returns:
the property value

get

public java.math.BigDecimal get()
Get the value as a BigDecimal

Specified by:
get in interface DecimalProperty
Returns:
the property value

compareTo

public int compareTo(java.lang.Object object)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(Object)

convertObjectToBigDecimal

protected java.math.BigDecimal convertObjectToBigDecimal(java.lang.Object object)
Convert an Object to a typecast BigDecimal, throwing an exception if unable to convert.

Parameters:
object -
Returns:
BigDecimal derived from the object

set

public void set(java.lang.Object propertyValue)
Description copied from interface: Property
Set the property's value as an object. The object type should be appropriate for the type of property. If necessary, the object will be cloned before it is stored internally. Implementations will recognise as many types of object passed in as possible. Null should always be accepted, primitive types will be reset back to zero/false.

If a String is passed in, it can be parsed in various ways. If the results of toDataString() are passed in, it must reconstitute the original value.

Specified by:
set in interface Property
Specified by:
set in class AbstractProperty
Parameters:
propertyValue - an Object to set the property's value to
See Also:
Property#set(Object)

set

public void set(long propertyValue)
Description copied from interface: NumericProperty
Set the property's value.

Specified by:
set in interface NumericProperty
Parameters:
propertyValue - a value to set the property's value to
See Also:
NumericProperty#set(long)

set

public void set(double propertyValue)
Description copied from interface: NumericProperty
Set the property's value.

Specified by:
set in interface NumericProperty
Parameters:
propertyValue - a value to set the property's value to
See Also:
NumericProperty#set(double)

add

protected void add(java.math.BigDecimal amount)
Add an amount to the decimal


add

public void add(long amount)
Description copied from interface: NumericProperty
Add to the property's value

Specified by:
add in interface NumericProperty
Parameters:
amount - an amount to add to the property's value
See Also:
NumericProperty#add(long)

add

public void add(double amount)
Description copied from interface: NumericProperty
Add to the property's value

Specified by:
add in interface NumericProperty
Parameters:
amount - an amount to add to the property's value
See Also:
NumericProperty#add(double)

add

public void add(java.lang.Object amount)
Description copied from interface: NumericProperty
Add to the property's value

Specified by:
add in interface NumericProperty
Parameters:
amount - an amount to add to the property's value
See Also:
NumericProperty#add(Object)

subtract

public void subtract(long amount)
Description copied from interface: NumericProperty
Subtract from the property's value

Specified by:
subtract in interface NumericProperty
Parameters:
amount - an amount to subtract from the property's value
See Also:
NumericProperty#subtract(long)

subtract

public void subtract(double amount)
Description copied from interface: NumericProperty
Subtract from the property's value

Specified by:
subtract in interface NumericProperty
Parameters:
amount - an amount to subtract from the property's value
See Also:
NumericProperty#subtract(double)

subtract

public void subtract(java.lang.Object amount)
Description copied from interface: NumericProperty
Subtract from the property's value

Specified by:
subtract in interface NumericProperty
Parameters:
amount - an amount to subtract from the property's value
See Also:
NumericProperty#subtract(Object)

multiplyBy

protected void multiplyBy(java.math.BigDecimal amount)
Multiply the decimal by an amount


multiplyBy

public void multiplyBy(long amount)
Description copied from interface: NumericProperty
Multiply the property's value by the specified argument

Specified by:
multiplyBy in interface NumericProperty
Parameters:
amount - an amount to multiply the property's value by
See Also:
NumericProperty#multiplyBy(long)

multiplyBy

public void multiplyBy(double amount)
Description copied from interface: NumericProperty
Multiply the property's value by the specified argument

Specified by:
multiplyBy in interface NumericProperty
Parameters:
amount - an amount to multiply the property's value by
See Also:
NumericProperty#multiplyBy(double)

multiplyBy

public void multiplyBy(java.lang.Object amount)
Description copied from interface: NumericProperty
Multiply the property's value by the specified argument

Specified by:
multiplyBy in interface NumericProperty
Parameters:
amount - an amount to multiply the property's value by
See Also:
NumericProperty#multiplyBy(Object)

divideBy

protected void divideBy(java.math.BigDecimal amount)
Divide the decimal by an amount


divideBy

public void divideBy(long amount)
Description copied from interface: NumericProperty
Divide the property's value by the specified argument

Specified by:
divideBy in interface NumericProperty
Parameters:
amount - an amount to divide the property's value by
See Also:
NumericProperty#divideBy(long)

divideBy

public void divideBy(double amount)
Description copied from interface: NumericProperty
Divide the property's value by the specified argument

Specified by:
divideBy in interface NumericProperty
Parameters:
amount - an amount to divide the property's value by
See Also:
NumericProperty#divideBy(double)

divideBy

public void divideBy(java.lang.Object amount)
Description copied from interface: NumericProperty
Divide the property's value by the specified argument

Specified by:
divideBy in interface NumericProperty
Parameters:
amount - an amount to divide the property's value by
See Also:
NumericProperty#divideBy(Object)

negate

public void negate()
Description copied from interface: NumericProperty
Negate the current value of the property.

Specified by:
negate in interface NumericProperty
See Also:
NumericProperty#negate()

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.