public final class BasisPoints extends Object implements Comparable<BasisPoints>
A number has three standard representations in finance:
| Modifier and Type | Field and Description |
|---|---|
static BasisPoints |
ZERO
A basis points of zero.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(BasisPoints other)
Compares this instance to another.
|
boolean |
equals(Object obj)
Checks if this instance equals another.
|
static BasisPoints |
fromDecimalForm(Decimal decimal)
Obtains an instance from mathematical decimal form, where 0.007 will create an instance representing 70bps.
|
static BasisPoints |
fromDecimalForm(double decimal)
Obtains an instance from mathematical decimal form, where 0.007 will create an instance representing 70bps.
|
static BasisPoints |
fromPercentage(Percentage percentage)
Obtains an instance from a percentage, where 0.7% will create an instance representing 70bps.
|
int |
hashCode()
Returns a suitable hash code.
|
BasisPoints |
map(UnaryOperator<Decimal> mapper)
Applies an operation to the value.
|
BasisPoints |
minus(BasisPoints other)
Returns a basis points equal to the this basis points minus the other one.
|
static BasisPoints |
of(Decimal basisPoints)
Obtains an instance from a basis points value.
|
static BasisPoints |
of(double basisPoints)
Obtains an instance from a basis points value.
|
static BasisPoints |
parse(String str)
Parses a percentage.
|
BasisPoints |
plus(BasisPoints other)
Returns a basis points equal to the this basis points plus the other one.
|
Decimal |
toDecimalForm()
Converts this basis points to mathematical decimal form.
|
Percentage |
toPercentage()
Converts this basis points to the equivalent percentage.
|
String |
toString()
Returns the formal string representation, '{value}bps'.
|
Decimal |
valueBasisPoints()
Gets the value in basis points form as a
Decimal. |
public static final BasisPoints ZERO
public static BasisPoints of(double basisPoints)
basisPoints - the basis points valuepublic static BasisPoints of(Decimal basisPoints)
basisPoints - the basis points valuepublic static BasisPoints fromDecimalForm(double decimal)
decimal - the mathematical decimal valuepublic static BasisPoints fromDecimalForm(Decimal decimal)
decimal - the mathematical decimal valuepublic static BasisPoints fromPercentage(Percentage percentage)
percentage - the percentagepublic static BasisPoints parse(String str)
The percentage may be suffixed by 'bps'.
str - the basis points stringpublic Decimal valueBasisPoints()
Decimal.
A value of 150bps will return 150.
public Decimal toDecimalForm()
A value of 150bps will return 0.015.
public Percentage toPercentage()
A value of 150bps will return 1.5%.
public BasisPoints plus(BasisPoints other)
other - the other basis pointspublic BasisPoints minus(BasisPoints other)
other - the other basis pointspublic BasisPoints map(UnaryOperator<Decimal> mapper)
This is generally used to apply a mathematical operation to the value. For example, the operator could multiply the value by a constant, or take the inverse.
abs = base.map(value -> value.abs());
mapper - the operator to be applied to the amountpublic int compareTo(BasisPoints other)
compareTo in interface Comparable<BasisPoints>other - the other instancepublic boolean equals(Object obj)
public int hashCode()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.