public boolean equals(Amount amt) { return equalValue(amt) && currency.equals(amt.currency) && (isNative() || issuer.equals(amt.issuer)); }
public Amount(BigDecimal value, String currency) { isNative = false; this.currency = Currency.fromString(currency); this.setAndCheckValue(value); }
public STObject executed(STObject finalFields) { // where `this` is an AffectedNode nodeAsPrevious STObject executed = new STObject(); executed.put(Amount.TakerPays, finalFields.get(Amount.TakerPays).subtract(takerPays())); executed.put(Amount.TakerGets, finalFields.get(Amount.TakerGets).subtract(takerGets())); return executed; }
public JSONObject toJSONObject() { JSONObject object = new JSONObject(); object.put("type", getType()); if (hasAccount()) object.put("account", account.toJSON()); if (hasIssuer()) object.put("issuer", issuer.toJSON()); if (hasCurrency()) object.put("currency", currency.toJSON()); return object; } }
public Amount roundedAmount(BigDecimal amount) { return amount(Amount.roundValue(amount, isNative())); } }
/** * See {@link com.ripple.core.fields.Field#TakerGetsCurrency} * See {@link com.ripple.core.fields.Field#TakerGetsIssuer} * * TODO: better handling of Taker(Gets|Pays)(Issuer|Curency) * maybe special subclasses of AccountID / Currency * respectively? */ public static Issue from160s(Hash160 currency, Hash160 issuer) { return new Issue(new Currency(currency.bytes()), new AccountID(issuer.toBytes())); }
public Issue issue(String code) { return new Issue(Currency.fromString(code), this); }
/** * @return A String representation as used by ripple json format */ public String stringRepr() { if (isNative()) { return toDropsString(); } else { return iouTextFull(); } }
public String toTextFull() { if (isNative()) { return nativeText(); } else { return iouTextFull(); } }
public boolean hasNativeSource() { for (Alternative alt : this) { if (alt.sourceAmount.isNative()) { return true; } } return false; }
@Override public Amount fromString(String s) { // We need to use the full dotted.path here, otherwise // we get confused with the AmountField Amount return com.ripple.core.coretypes.Amount.fromString(s); }
@Override public void toBytesSink(BytesSink to) { for (STObject stObject : this) { stObject.toBytesSink(to); } }