package com.ripple.core.types;

import java.math.BigDecimal;

/**
 * Represents a currency/issuer pair
 */
public class Issue {
    public static final Issue XRP = fromString("XRP");
    Currency currency;
    AccountID issuer;

    public Issue(Currency currency, AccountID issuer) {
        this.currency = currency;
        this.issuer = issuer;
    }

    public static Issue fromString(String pair) {
        String[] split = pair.split("/");
        return getIssue(split);
    }

    public static Issue getIssue(String[] split) {
        if (split.length == 2) {
            return new Issue(Currency.fromString(split[0]), AccountID.fromString(split[1]));
        }
        else if (split[0].equals("XRP")) {
            return new Issue(Currency.XRP, AccountID.ZERO);
        }  else {
            throw new RuntimeException("Issue string must be XRP or $currency/$issuer");
        }
    }

    public Currency currency() {
        return currency;
    }

    public AccountID issuer() {
        return issuer;
    }

    public Amount amount(BigDecimal value) {
        return new Amount(value, currency, issuer, nativeCurrency());
    }

    private boolean nativeCurrency() {
        return this == XRP || currency.equals(Currency.XRP);
    }

    public Amount amount(Number value) {
        return new Amount(BigDecimal.valueOf(value.longValue()), currency, issuer, nativeCurrency());
    }
}

@@ -1113,38 +1113,32 @@
 cy, issuer, 
-n
+isN
 ative
-Currency
 ());%0A    %7D%0A%0A
@@ -1157,30 +1157,24 @@
 boolean 
-n
+isN
 ative
-Currency
 () %7B%0A   
@@ -1366,22 +1366,16 @@
 er, 
-n
+isN
 ative
-Currency
 ());

Fix determination of native Issue