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

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

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

public class IValue extends ASN1Object
{
    private final BigInteger value;
    
    private IValue(final ASN1Integer asn1Integer) {
        final int intValueExact = BigIntegers.intValueExact(asn1Integer.getValue());
        if (intValueExact < 0 || intValueExact > 65535) {
            throw new IllegalArgumentException("value out of range");
        }
        this.value = asn1Integer.getValue();
    }
    
    public static IValue getInstance(final Object o) {
        if (o instanceof IValue) {
            return (IValue)o;
        }
        if (o != null) {
            return new IValue(ASN1Integer.getInstance(o));
        }
        return null;
    }
    
    public BigInteger getValue() {
        return this.value;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new ASN1Integer(this.value);
    }
}
