Top Description Fields Constructors Methods
org.javamoney.moneta

pack-priv final Class BuildableCurrencyUnit

extends Object
implements CurrencyUnit, Comparable<CurrencyUnit>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Comparable, javax.money.CurrencyUnit
Imports
org.javamoney.moneta.spi.ConfigurableCurrencyUnitProvider, javax.money.CurrencyContext, .CurrencyUnit, .MonetaryException, java.io.Serializable, java.util.Objects

Implementation of javax.money.CurrencyUnit that allows to of new instances using a fluent API. Instances created also can be added to the ConfigurableCurrencyUnitProvider singleton, which publishes the instances, so they are visible from the javax.money.Monetary singleton.

Field Summary

Modifier and TypeField and Description
private String
currencyCode

The unique currency code.

private CurrencyContext
currencyContext

THe currency's context.

private int
defaultFractionDigits

The default fraction digits.

private int
numericCode

The (optional) numeric code.

private static final long
serialVersionUID

serialVersionUID.

Constructor Summary

AccessConstructor and Description
pack-priv
BuildableCurrencyUnit(CurrencyUnitBuilder
the builder, never null.
builder
)

Constructor, called from the Builder.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(CurrencyUnit o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public CurrencyContext
public String
getCurrencyCode()

Implements javax.money.CurrencyUnit.getCurrencyCode.

Gets the unique currency code, the effective code depends on the currency.

public int
getDefaultFractionDigits()

Implements javax.money.CurrencyUnit.getDefaultFractionDigits.

Gets the number of fractional digits typically used by this currency.

public int
getNumericCode()

Implements javax.money.CurrencyUnit.getNumericCode.

Gets a numeric currency code.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

currencyCodeback to summary
private String currencyCode

The unique currency code.

currencyContextback to summary
private CurrencyContext currencyContext

THe currency's context.

defaultFractionDigitsback to summary
private int defaultFractionDigits

The default fraction digits.

numericCodeback to summary
private int numericCode

The (optional) numeric code.

serialVersionUIDback to summary
private static final long serialVersionUID

serialVersionUID.

Constructor Detail

BuildableCurrencyUnitback to summary
pack-priv BuildableCurrencyUnit(CurrencyUnitBuilder builder)

Constructor, called from the Builder.

Parameters
builder:CurrencyUnitBuilder

the builder, never null.

Method Detail

compareToback to summary
public int compareTo(CurrencyUnit o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getContextback to summary
public CurrencyContext getContext()

Implements javax.money.CurrencyUnit.getContext.

Doc from javax.money.CurrencyUnit.getContext.

Returns the javax.money.CurrencyContext of a currency. This context contains additional information about the type and capabilities of a CurrencyUnit, e.g. its provider and more.

Annotations
@Override
getCurrencyCodeback to summary
public String getCurrencyCode()

Implements javax.money.CurrencyUnit.getCurrencyCode.

Doc from javax.money.CurrencyUnit.getCurrencyCode.

Gets the unique currency code, the effective code depends on the currency.

Since each currency is identified by this code, the currency code is required to be defined for every CurrencyUnit and not null or empty.

For ISO codes the 3-letter ISO code should be returned. For non ISO currencies no constraints are defined.

Annotations
@Override
getDefaultFractionDigitsback to summary
public int getDefaultFractionDigits()

Implements javax.money.CurrencyUnit.getDefaultFractionDigits.

Doc from javax.money.CurrencyUnit.getDefaultFractionDigits.

Gets the number of fractional digits typically used by this currency.

Different currencies have different numbers of fractional digits by default. For example, 'GBP' has 2 fractional digits, but 'JPY' has zero. virtual currencies or those with no applicable fractional are indicated by -1.

This method matches the API of java.util.Currency.

Annotations
@Override
getNumericCodeback to summary
public int getNumericCode()

Implements javax.money.CurrencyUnit.getNumericCode.

Doc from javax.money.CurrencyUnit.getNumericCode.

Gets a numeric currency code. within the ISO-4217 name space, this equals to the ISO numeric code. In other currency name spaces this number may be different, or even undefined (-1).

The numeric code is an optional alternative to the standard currency code. If defined, the numeric code is required to be unique.

This method matches the API of java.util.Currency.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override