// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.oer.its.ieee1609dot2.basetypes;

import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Integer;
import java.math.BigInteger;
import org.bouncycastle.asn1.ASN1Object;

public class NinetyDegreeInt extends ASN1Object
{
    private static final BigInteger loweBound;
    private static final BigInteger upperBound;
    private static final BigInteger unknown;
    private final BigInteger value;
    
    public NinetyDegreeInt(final long val) {
        this(BigInteger.valueOf(val));
    }
    
    public NinetyDegreeInt(final BigInteger value) {
        if (!value.equals(NinetyDegreeInt.unknown)) {
            if (value.compareTo(NinetyDegreeInt.loweBound) < 0) {
                throw new IllegalStateException("ninety degree int cannot be less than -900000000");
            }
            if (value.compareTo(NinetyDegreeInt.upperBound) > 0) {
                throw new IllegalStateException("ninety degree int cannot be greater than 900000000");
            }
        }
        this.value = value;
    }
    
    private NinetyDegreeInt(final ASN1Integer asn1Integer) {
        this(asn1Integer.getValue());
    }
    
    public BigInteger getValue() {
        return this.value;
    }
    
    public static NinetyDegreeInt getInstance(final Object o) {
        if (o instanceof NinetyDegreeInt) {
            return (NinetyDegreeInt)o;
        }
        if (o != null) {
            return new NinetyDegreeInt(ASN1Integer.getInstance(o));
        }
        return null;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new ASN1Integer(this.value);
    }
    
    static {
        loweBound = new BigInteger("-900000000");
        upperBound = new BigInteger("900000000");
        unknown = new BigInteger("900000001");
    }
}
