public enum PayReceive extends Enum<PayReceive> implements NamedEnum
Specifies the direction of payments. For example, a swap typically has two legs, a pay leg, where payments are made to the counterparty, and a receive leg, where payments are received.
| Modifier and Type | Method and Description |
|---|---|
boolean |
isPay()
Checks if the type is 'Pay'.
|
boolean |
isReceive()
Checks if the type is 'Receive'.
|
BigMoney |
normalize(BigMoney amount)
Normalizes the specified
BigMoney amount using this pay/receive rule. |
CurrencyAmount |
normalize(CurrencyAmount amount)
Normalizes the specified amount using this pay/receive rule.
|
Decimal |
normalize(Decimal amount)
Normalizes the specified notional amount using this pay/receive rule.
|
double |
normalize(double amount)
Normalizes the specified notional amount using this pay/receive rule.
|
static PayReceive |
of(String name)
Obtains an instance from the specified name.
|
static PayReceive |
ofPay(boolean isPay)
Converts a boolean "is pay" flag to the enum value.
|
static PayReceive |
ofSignedAmount(double amount)
Converts a signed amount to the enum value.
|
PayReceive |
opposite()
Supplies the opposite of this value.
|
String |
toString()
Returns the formatted name of the type.
|
static PayReceive |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static PayReceive[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PayReceive PAY
public static final PayReceive RECEIVE
public static PayReceive[] values()
for (PayReceive c : PayReceive.values()) System.out.println(c);
public static PayReceive valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static PayReceive of(String name)
Parsing handles the mixed case form produced by toString() and
the upper and lower case variants of the enum constant name.
name - the name to parseIllegalArgumentException - if the name is not knownpublic static PayReceive ofPay(boolean isPay)
isPay - the pay flag, true for pay, false for receivepublic static PayReceive ofSignedAmount(double amount)
A negative value will return 'Pay'.
A positive value will return 'Receive'.
This effectively parses the result of normalize(double).
amount - the amount to checkpublic double normalize(double amount)
This returns a negative signed amount if this is 'Pay', and a positive signed amount if this is 'Receive'. This effectively normalizes the input notional to the pay/receive sign conventions of this library. The negative form of zero will never be returned.
amount - the amount to adjustpublic Decimal normalize(Decimal amount)
This returns a negative signed amount if this is 'Pay', and a positive signed amount if this is 'Receive'. This effectively normalizes the input notional to the pay/receive sign conventions of this library.
amount - the amount to adjustpublic CurrencyAmount normalize(CurrencyAmount amount)
This returns a negative signed amount if this is 'Pay', and a positive signed amount if this is 'Receive'. This effectively normalizes the input notional to the pay/receive sign conventions of this library. The negative form of zero will never be returned.
amount - the amount to adjustpublic BigMoney normalize(BigMoney amount)
BigMoney amount using this pay/receive rule.
This returns a negative signed amount if this is 'Pay', and a positive signed amount if this is 'Receive'. This effectively normalizes the input notional to the pay/receive sign conventions of this library.
amount - the amount to adjustpublic boolean isPay()
public boolean isReceive()
public PayReceive opposite()
public String toString()
toString in class Enum<PayReceive>Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.