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

package org.bouncycastle.oer.its.etsi102941;

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 CtlCommand extends ASN1Object implements ASN1Choice
{
    private final int choice;
    private final ASN1Encodable ctlCommand;
    public static final int add = 0;
    public static final int delete = 1;
    
    public CtlCommand(final int choice, final ASN1Encodable ctlCommand) {
        this.choice = choice;
        this.ctlCommand = ctlCommand;
    }
    
    private CtlCommand(final ASN1TaggedObject asn1TaggedObject) {
        switch (this.choice = asn1TaggedObject.getTagNo()) {
            case 0: {
                this.ctlCommand = CtlEntry.getInstance(asn1TaggedObject.getExplicitBaseObject());
                return;
            }
            case 1: {
                this.ctlCommand = CtlDelete.getInstance(asn1TaggedObject.getExplicitBaseObject());
                return;
            }
            default: {
                throw new IllegalArgumentException("invalid choice value " + this.choice);
            }
        }
    }
    
    public static CtlCommand getInstance(final Object o) {
        if (o instanceof CtlCommand) {
            return (CtlCommand)o;
        }
        if (o != null) {
            return new CtlCommand(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public static CtlCommand add(final CtlEntry ctlEntry) {
        return new CtlCommand(0, ctlEntry);
    }
    
    public static CtlCommand delete(final CtlDelete ctlDelete) {
        return new CtlCommand(1, ctlDelete);
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getCtlCommand() {
        return this.ctlCommand;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.ctlCommand);
    }
}
