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

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

import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Object;

public class CountryAndSubregions extends ASN1Object
{
    private final CountryOnly country;
    private final SequenceOfRegionAndSubregions regionAndSubregions;
    
    public CountryAndSubregions(final CountryOnly country, final SequenceOfRegionAndSubregions regionAndSubregions) {
        this.country = country;
        this.regionAndSubregions = regionAndSubregions;
    }
    
    private CountryAndSubregions(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 2) {
            throw new IllegalArgumentException("expected sequence size of 2");
        }
        this.country = CountryOnly.getInstance(asn1Sequence.getObjectAt(0));
        this.regionAndSubregions = SequenceOfRegionAndSubregions.getInstance(asn1Sequence.getObjectAt(1));
    }
    
    public static CountryAndSubregions getInstance(final Object o) {
        if (o instanceof CountryAndSubregions) {
            return (CountryAndSubregions)o;
        }
        if (o != null) {
            return new CountryAndSubregions(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public CountryOnly getCountry() {
        return this.country;
    }
    
    public SequenceOfRegionAndSubregions getRegionAndSubregions() {
        return this.regionAndSubregions;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(new ASN1Encodable[] { this.country, this.regionAndSubregions });
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder
    {
        private CountryOnly country;
        private SequenceOfRegionAndSubregions regionAndSubregions;
        
        public Builder setCountry(final CountryOnly country) {
            this.country = country;
            return this;
        }
        
        public Builder setRegionAndSubregions(final SequenceOfRegionAndSubregions regionAndSubregions) {
            this.regionAndSubregions = regionAndSubregions;
            return this;
        }
        
        public CountryAndSubregions createCountryAndSubregions() {
            return new CountryAndSubregions(this.country, this.regionAndSubregions);
        }
    }
}
