// 
// 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 IdentifiedRegion extends ASN1Object implements ASN1Choice, RegionInterface
{
    public static final int countryOnly = 0;
    public static final int countryAndRegions = 1;
    public static final int countryAndSubregions = 2;
    private final int choice;
    private final ASN1Encodable identifiedRegion;
    
    public IdentifiedRegion(final int choice, final ASN1Encodable identifiedRegion) {
        this.choice = choice;
        this.identifiedRegion = identifiedRegion;
    }
    
    private IdentifiedRegion(final ASN1TaggedObject asn1TaggedObject) {
        switch (this.choice = asn1TaggedObject.getTagNo()) {
            case 0: {
                this.identifiedRegion = CountryOnly.getInstance(asn1TaggedObject.getExplicitBaseObject());
                break;
            }
            case 1: {
                this.identifiedRegion = CountryAndRegions.getInstance(asn1TaggedObject.getExplicitBaseObject());
                break;
            }
            case 2: {
                this.identifiedRegion = CountryAndSubregions.getInstance(asn1TaggedObject.getExplicitBaseObject());
                break;
            }
            default: {
                throw new IllegalArgumentException("invalid choice value " + this.choice);
            }
        }
    }
    
    public static IdentifiedRegion countryOnly(final CountryOnly countryOnly) {
        return new IdentifiedRegion(0, countryOnly);
    }
    
    public static IdentifiedRegion countryAndRegions(final CountryAndRegions countryAndRegions) {
        return new IdentifiedRegion(1, countryAndRegions);
    }
    
    public static IdentifiedRegion countryAndSubregions(final CountryAndSubregions countryAndSubregions) {
        return new IdentifiedRegion(2, countryAndSubregions);
    }
    
    public static IdentifiedRegion getInstance(final Object o) {
        if (o instanceof IdentifiedRegion) {
            return (IdentifiedRegion)o;
        }
        if (o != null) {
            return new IdentifiedRegion(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getIdentifiedRegion() {
        return this.identifiedRegion;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.identifiedRegion);
    }
}
