org.bitcoinj.core.Monetary Java Examples

The following examples show how to use org.bitcoinj.core.Monetary. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MonetaryWrapper.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean equals(final Object o) {
    if (o == this)
        return true;
    if (o == null || o.getClass() != getClass())
        return false;
    final Monetary otherMonetary = ((MonetaryWrapper) o).getMonetary();
    return monetary.getValue() == otherMonetary.getValue();
}
 
Example #2
Source File: Price.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public Coin getAmountByVolume(Volume volume) {
    Monetary monetary = volume.getMonetary();
    if (monetary instanceof Fiat && this.monetary instanceof Fiat)
        return new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary);
    else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin)
        return new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary);
    else
        return Coin.ZERO;
}
 
Example #3
Source File: BSFormatter.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) {
    if (volume != null) {
        Monetary monetary = volume.getMonetary();
        if (monetary instanceof Fiat)
            return formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode);
        else
            return formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode);
    } else {
        return "";
    }
}
 
Example #4
Source File: BSFormatter.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public String formatPrice(Price price, MonetaryFormat fiatPriceFormat, boolean appendCurrencyCode) {
    if (price != null) {
        Monetary monetary = price.getMonetary();
        if (monetary instanceof Fiat)
            return formatFiat((Fiat) monetary, fiatPriceFormat, appendCurrencyCode);
        else
            return formatAltcoin((Altcoin) monetary, appendCurrencyCode);
    } else {
        return Res.get("shared.na");
    }
}
 
Example #5
Source File: DisplayUtils.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private static String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) {
    if (volume != null) {
        Monetary monetary = volume.getMonetary();
        if (monetary instanceof Fiat)
            return FormattingUtils.formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode);
        else
            return FormattingUtils.formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode);
    } else {
        return "";
    }
}
 
Example #6
Source File: MonetaryWrapper.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean equals(final Object o) {
    if (o == this)
        return true;
    if (o == null || o.getClass() != getClass())
        return false;
    final Monetary otherMonetary = ((MonetaryWrapper) o).getMonetary();
    return monetary.getValue() == otherMonetary.getValue();
}
 
Example #7
Source File: Price.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public Coin getAmountByVolume(Volume volume) {
    Monetary monetary = volume.getMonetary();
    if (monetary instanceof Fiat && this.monetary instanceof Fiat)
        return new ExchangeRate((Fiat) this.monetary).fiatToCoin((Fiat) monetary);
    else if (monetary instanceof Altcoin && this.monetary instanceof Altcoin)
        return new AltcoinExchangeRate((Altcoin) this.monetary).altcoinToCoin((Altcoin) monetary);
    else
        return Coin.ZERO;
}
 
Example #8
Source File: FormattingUtils.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String formatPrice(Price price, MonetaryFormat fiatPriceFormat, boolean appendCurrencyCode) {
    if (price != null) {
        Monetary monetary = price.getMonetary();
        if (monetary instanceof Fiat)
            return formatFiat((Fiat) monetary, fiatPriceFormat, appendCurrencyCode);
        else
            return formatAltcoin((Altcoin) monetary, appendCurrencyCode);
    } else {
        return Res.get("shared.na");
    }
}
 
Example #9
Source File: MonetaryWrapper.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public MonetaryWrapper(Monetary monetary) {
    this.monetary = monetary;
}
 
Example #10
Source File: MonetaryWrapper.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public Monetary getMonetary() {
    return monetary;
}
 
Example #11
Source File: Volume.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public Volume(Monetary monetary) {
    super(monetary);
}
 
Example #12
Source File: MonetaryWrapper.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public MonetaryWrapper(Monetary monetary) {
    this.monetary = monetary;
}
 
Example #13
Source File: MonetaryWrapper.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public Monetary getMonetary() {
    return monetary;
}
 
Example #14
Source File: Volume.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public Volume(Monetary monetary) {
    super(monetary);
}
 
Example #15
Source File: Price.java    From bisq-core with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Create a new {@code Price} from specified {@code Monetary}.
 *
 * @param monetary
 */
public Price(Monetary monetary) {
    super(monetary);
}
 
Example #16
Source File: Price.java    From bisq with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Create a new {@code Price} from specified {@code Monetary}.
 *
 * @param monetary
 */
public Price(Monetary monetary) {
    super(monetary);
}