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

package org.bouncycastle.oer.its.etsi103097.extension;

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

public class ExtId extends ASN1Object
{
    private final BigInteger extId;
    private static final BigInteger MAX;
    
    public ExtId(final long val) {
        this(BigInteger.valueOf(val));
    }
    
    public ExtId(final BigInteger bigInteger) {
        if (bigInteger.signum() < 0 || bigInteger.compareTo(ExtId.MAX) > 0) {
            throw new IllegalArgumentException("value " + bigInteger + " outside of range 0...255");
        }
        this.extId = bigInteger;
    }
    
    public ExtId(final byte[] val) {
        this(new BigInteger(val));
    }
    
    private ExtId(final ASN1Integer asn1Integer) {
        this(asn1Integer.getValue());
    }
    
    public BigInteger getExtId() {
        return this.extId;
    }
    
    public static ExtId getInstance(final Object o) {
        if (o instanceof ExtId) {
            return (ExtId)o;
        }
        if (o != null) {
            return new ExtId(ASN1Integer.getInstance(o));
        }
        return null;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new ASN1Integer(this.extId);
    }
    
    static {
        MAX = BigInteger.valueOf(255L);
    }
}
