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

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

import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;

public class BasePublicEncryptionKey extends ASN1Object implements ASN1Choice
{
    public static final int eciesNistP256 = 0;
    public static final int eciesBrainpoolP256r1 = 1;
    private final int choice;
    private final ASN1Encodable basePublicEncryptionKey;
    
    private BasePublicEncryptionKey(final ASN1TaggedObject asn1TaggedObject) {
        switch (this.choice = asn1TaggedObject.getTagNo()) {
            case 0:
            case 1: {
                this.basePublicEncryptionKey = EccP256CurvePoint.getInstance(asn1TaggedObject.getExplicitBaseObject());
                return;
            }
            default: {
                throw new IllegalArgumentException("invalid choice value " + asn1TaggedObject.getTagNo());
            }
        }
    }
    
    public BasePublicEncryptionKey(final int choice, final ASN1Encodable basePublicEncryptionKey) {
        this.choice = choice;
        this.basePublicEncryptionKey = basePublicEncryptionKey;
    }
    
    public static BasePublicEncryptionKey getInstance(final Object o) {
        if (o instanceof BasePublicEncryptionKey) {
            return (BasePublicEncryptionKey)o;
        }
        if (o != null) {
            return new BasePublicEncryptionKey(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public static BasePublicEncryptionKey eciesNistP256(final EccP256CurvePoint eccP256CurvePoint) {
        return new BasePublicEncryptionKey(0, eccP256CurvePoint);
    }
    
    public static BasePublicEncryptionKey eciesBrainpoolP256r1(final EccP256CurvePoint eccP256CurvePoint) {
        return new BasePublicEncryptionKey(1, eccP256CurvePoint);
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getBasePublicEncryptionKey() {
        return this.basePublicEncryptionKey;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.basePublicEncryptionKey);
    }
    
    public static class Builder
    {
        private int choice;
        private ASN1Encodable value;
        
        public Builder setChoice(final int choice) {
            this.choice = choice;
            return this;
        }
        
        public Builder setValue(final EccCurvePoint value) {
            this.value = value;
            return this;
        }
        
        public BasePublicEncryptionKey createBasePublicEncryptionKey() {
            return new BasePublicEncryptionKey(this.choice, this.value);
        }
    }
}
