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

package org.bouncycastle.oer.its.ieee1609dot2;

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

public class PduFunctionalType extends ASN1Object
{
    private static final BigInteger MAX;
    public static final PduFunctionalType tlsHandshake;
    public static final PduFunctionalType iso21177ExtendedAuth;
    private final BigInteger functionalType;
    
    public PduFunctionalType(final long val) {
        this(BigInteger.valueOf(val));
    }
    
    public PduFunctionalType(final BigInteger bigInteger) {
        this.functionalType = assertValue(bigInteger);
    }
    
    public PduFunctionalType(final byte[] val) {
        this(new BigInteger(val));
    }
    
    private PduFunctionalType(final ASN1Integer asn1Integer) {
        this(asn1Integer.getValue());
    }
    
    public static PduFunctionalType getInstance(final Object o) {
        if (o instanceof PduFunctionalType) {
            return (PduFunctionalType)o;
        }
        if (o != null) {
            return new PduFunctionalType(ASN1Integer.getInstance(o));
        }
        return null;
    }
    
    public BigInteger getFunctionalType() {
        return this.functionalType;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new ASN1Integer(this.functionalType);
    }
    
    private static BigInteger assertValue(final BigInteger bigInteger) {
        if (bigInteger.signum() < 0) {
            throw new IllegalArgumentException("value less than 0");
        }
        if (bigInteger.compareTo(PduFunctionalType.MAX) > 0) {
            throw new IllegalArgumentException("value exceeds " + PduFunctionalType.MAX);
        }
        return bigInteger;
    }
    
    static {
        MAX = BigInteger.valueOf(255L);
        tlsHandshake = new PduFunctionalType(1L);
        iso21177ExtendedAuth = new PduFunctionalType(2L);
    }
}
