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

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

import org.bouncycastle.oer.its.ItsUtils;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Object;

public class CountryAndRegions extends ASN1Object implements RegionInterface
{
    private final CountryOnly countryOnly;
    private final SequenceOfUint8 regions;
    
    public CountryAndRegions(final CountryOnly countryOnly, final SequenceOfUint8 sequenceOfUint8) {
        this.countryOnly = countryOnly;
        this.regions = SequenceOfUint8.getInstance(sequenceOfUint8);
    }
    
    private CountryAndRegions(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 2) {
            throw new IllegalArgumentException("expected sequence size of 2");
        }
        this.countryOnly = CountryOnly.getInstance(asn1Sequence.getObjectAt(0));
        this.regions = SequenceOfUint8.getInstance(asn1Sequence.getObjectAt(1));
    }
    
    public static CountryAndRegions getInstance(final Object o) {
        if (o instanceof CountryAndRegions) {
            return (CountryAndRegions)o;
        }
        if (o != null) {
            return new CountryAndRegions(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return ItsUtils.toSequence(this.countryOnly, this.regions);
    }
    
    public CountryOnly getCountryOnly() {
        return this.countryOnly;
    }
    
    public SequenceOfUint8 getRegions() {
        return this.regions;
    }
    
    public static class Builder
    {
        private SequenceOfUint8 regionList;
        private CountryOnly countryOnly;
        
        public Builder setCountryOnly(final CountryOnly countryOnly) {
            this.countryOnly = countryOnly;
            return this;
        }
        
        public Builder setRegions(final SequenceOfUint8 regionList) {
            this.regionList = regionList;
            return this;
        }
        
        public CountryAndRegions createCountryAndRegions() {
            return new CountryAndRegions(this.countryOnly, this.regionList);
        }
    }
}
