# com.beasys.commerce.axiom.units
UnitPriceImpl Class

public class UnitPriceImpl
extends `BelongingImpl`
implements `Cloneable`, `UnitPrice`

Combines a unit and a price to provide a mechanism for recording pricing and pricing strategies. It also provides features for converting prices between units.

Related Topics

``UnitPrice``
``UnitPriceHome``

Hierarchy
  `Object`
  `BelongingImpl`
  `UnitPriceImpl`

All Implemented Interfaces
  `Belonging`, `BusinessSmartComponent`, `Cloneable`, `Comparable`, `RelationalReference`, `Serializable`, `UnitPrice`

## Field Summary

`public `Price`` | `price` The price component of the UnitPrice.
`public `Unit`` | `unit` The unit component of the UnitPrice.

Fields from com.beasys.commerce.foundation`.`BelongingImpl``
``__classIdentifier`, `__containingBelonging`, `__containingEntity`, `__mapKey`, `__sequenceNumber`, `_isDirty``

## Constructor Summary

UnitPriceImpl()

## Method Summary

`public int` | `compareTo`(`Object` o) Compare this belonging to another
`public `UnitPrice`` | `convert`(`Unit` newUnit) Return a new UnitPrice that maintains the Price/Unit ratio with the newly specified unit.
`public void` | `convertInPlace`(`Unit` newUnit) Translate the UnitPrice into the new Units maintaining the Price/Unit ratio.
`public `Price`` | `getPrice`() Get the value of price
`public `Unit`` | `getUnit`() Get the value of unit
`public `String`` | `interfaceName`() interfaceName() returns the unqualified name of the interface from the UML model
`public void` | `setByValue`(`Belonging` value) It is possible to call set-by-value with a superclass.
`public void` | `setPrice`(`Price` price) Set the value of price
`public void` | `setUnit`(`Unit` unit) Set the value of unit
`public `Belonging`` | `value`() value() is a more typesafe implementation of clone()

Methods from `com.beasys.commerce.foundation.`BelongingImpl``
``clearRelationalBinding`, `clearRelationalBinding`, `clearRelationalBinding`, `clearRelationalBinding`, `clone`, `doRelationalBinding`, `doRelationalBinding`, `doRelationalBindingOnElement`, `doRelationalBindingOnElement`, `doRelationalBindingOnElement`, `doRelationalBindingOnSingleton`, `doRelationalBindingOnSingleton`, `doRelationalBindingOnSingleton`, `doRelationalBindingWithMapKey`, `doRelationalBindingWithMapKey`, `doRelationalBindingWithMapKey`, `enumerateRelationalBinding`, `enumerateRelationalBinding`, `equals`, `get__classIdentifier`, `get__containingBelonging`, `get__containingEntity`, `get__containingEntityReference`, `get__mapKey`, `get__sequenceNumber`, `getPersistenceHelperPlugin`, `hashCode`, `set__classIdentifier`, `set__containingBelonging`, `set__containingEntity`, `set__containingEntityReference`, `set__mapKey`, `toString``

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `com.beasys.commerce.foundation.`Belonging``
``clone`, `equals`, `interfaceName`, `setByValue`, `value``

Methods from interface `java.lang.`Comparable``
`compareTo`

Methods from interface `com.beasys.commerce.foundation.`RelationalReference``
``get__classIdentifier`, `get__containingBelonging`, `get__containingEntity`, `get__mapKey`, `get__sequenceNumber`, `set__containingBelonging`, `set__containingEntity`, `set__mapKey``

Methods from interface `com.beasys.commerce.axiom.units.`UnitPrice``
``convert`, `convertInPlace`, `getPrice`, `getUnit`, `setPrice`, `setUnit``

## Field Detail

### price

    public Price price

  The price component of the UnitPrice.
  - Containment: By Value
  - Multiplicity: 1:1

### unit

    public Unit unit

  The unit component of the UnitPrice.
  - Containment: By Value
  - Multiplicity: 1:1

## Constructor Detail

### UnitPriceImpl

    public UnitPriceImpl()

## Method Detail

### compareTo(Object) Method

    public int compareTo(Object o)

Compare this belonging to another

Overrides
  `BelongingImpl.compareTo(Object)`

#### Parameters

o
  target object for comparision

#### Returns

0 objects are equal

### convert(Unit) Method

    public UnitPrice convert(Unit newUnit)
         throws InvalidUnitException

Return a new UnitPrice that maintains the Price/Unit ratio with the newly specified unit.

#### Exceptions

``InvalidUnitException``

### convertInPlace(Unit) Method

    public void convertInPlace(Unit newUnit)
         throws InvalidUnitException

Translate the UnitPrice into the new Units maintaining the Price/Unit ratio.

#### Exceptions

``InvalidUnitException``

### getPrice() Method

    public Price getPrice()

Get the value of price

#### Returns

price.

### getUnit() Method

    public Unit getUnit()

Get the value of unit

#### Returns

unit.

### interfaceName() Method

    public String interfaceName()

interfaceName() returns the unqualified name of the interface from the UML model

#### Returns

the unqualified name of the belonging interface from the UML model

### setByValue(Belonging) Method

    public void setByValue(Belonging value)

It is possible to call set-by-value with a superclass. If that is the case, only the fields in the superclass will be set in this instance. The remaining fields get the default values.

It is also possible to call set-by-value with a subclass. In this case, the specialized fields in the subclass will be ignored. The overridden fields in the subclass will be populated.

Overrides
  `BelongingImpl.setByValue(Belonging)`

#### Parameters

value
  The `Belonging` to use for initialization.

### setPrice(Price) Method

    public void setPrice(Price price)

Set the value of price

#### Parameters

price
  price to be added

### setUnit(Unit) Method

    public void setUnit(Unit unit)

Set the value of unit

#### Parameters

unit
  unit to be added

### value() Method

    public Belonging value()

value() is a more typesafe implementation of clone()

#### Returns

a clone of this instance