package com.xcong.excoin.rabbit.pricequeue; import java.math.BigDecimal; import java.math.RoundingMode; /** * 正序的 从小到大 头元素最小 */ public class AscBigDecimal implements Comparable{ private BigDecimal value; public AscBigDecimal(String val) { this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP); } public AscBigDecimal(double val){ this.value = new BigDecimal(val).setScale(8, RoundingMode.HALF_UP); } public BigDecimal getValue() { return value; } public void setValue(BigDecimal value) { this.value = value; } @Override public int compareTo(Object o) { if(o==null){ return -1; } AscBigDecimal val = (AscBigDecimal)o; if(this.value.compareTo(val.getValue())>0){ return 1; }else if(this.value.compareTo(val.getValue())<0){ return -1; }else { return 0; } } }