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

package org.bouncycastle.oer.its.etsi103097.extension;

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

public class Extension extends ASN1Object
{
    public static final ExtId etsiTs102941CrlRequestId;
    public static final ExtId etsiTs102941DeltaCtlRequestId;
    private final ExtId id;
    private final ASN1Encodable content;
    
    protected Extension(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 2) {
            throw new IllegalArgumentException("expected sequence size of 2");
        }
        this.id = ExtId.getInstance(asn1Sequence.getObjectAt(0));
        if (this.id.equals(Extension.etsiTs102941CrlRequestId)) {
            this.content = EtsiTs102941CrlRequest.getInstance(asn1Sequence.getObjectAt(1));
        }
        else {
            if (!this.id.equals(Extension.etsiTs102941DeltaCtlRequestId)) {
                throw new IllegalArgumentException("id not 1 (EtsiTs102941CrlRequest) or 2 (EtsiTs102941DeltaCtlRequest)");
            }
            this.content = EtsiTs102941DeltaCtlRequest.getInstance(asn1Sequence.getObjectAt(1));
        }
    }
    
    public Extension(final ExtId id, final ASN1Encodable content) {
        this.id = id;
        if (id.getExtId().intValue() != 1 && id.getExtId().intValue() != 2) {
            throw new IllegalArgumentException("id not 1 (EtsiTs102941CrlRequest) or 2 (EtsiTs102941DeltaCtlRequest)");
        }
        this.content = content;
    }
    
    public static Extension etsiTs102941CrlRequest(final EtsiTs102941CrlRequest etsiTs102941CrlRequest) {
        return new Extension(Extension.etsiTs102941CrlRequestId, etsiTs102941CrlRequest);
    }
    
    public static Extension etsiTs102941DeltaCtlRequest(final EtsiTs102941DeltaCtlRequest etsiTs102941DeltaCtlRequest) {
        return new Extension(Extension.etsiTs102941DeltaCtlRequestId, etsiTs102941DeltaCtlRequest);
    }
    
    public static Extension getInstance(final Object o) {
        if (o instanceof Extension) {
            return (Extension)o;
        }
        if (o != null) {
            return new Extension(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(new ASN1Encodable[] { this.id, this.content });
    }
    
    public ExtId getId() {
        return this.id;
    }
    
    public ASN1Encodable getContent() {
        return this.content;
    }
    
    static {
        etsiTs102941CrlRequestId = new ExtId(1L);
        etsiTs102941DeltaCtlRequestId = new ExtId(2L);
    }
}
