Helius
2021-02-02 c4aabe264e8f2a6002116a20b3f0b27db99c0afd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
        }
    }
}