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

package org.bouncycastle.oer.its.etsi102941;

import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.oer.its.ieee1609dot2.basetypes.Time32;
import org.bouncycastle.oer.its.etsi102941.basetypes.Version;
import org.bouncycastle.asn1.ASN1Object;

public class ToBeSignedCrl extends ASN1Object
{
    private final Version version;
    private final Time32 thisUpdate;
    private final Time32 nextUpdate;
    private final SequenceOfCrlEntry entries;
    
    public ToBeSignedCrl(final Version version, final Time32 thisUpdate, final Time32 nextUpdate, final SequenceOfCrlEntry entries) {
        this.version = version;
        this.thisUpdate = thisUpdate;
        this.nextUpdate = nextUpdate;
        this.entries = entries;
    }
    
    private ToBeSignedCrl(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 4) {
            throw new IllegalArgumentException("expected sequence size of 4");
        }
        this.version = Version.getInstance(asn1Sequence.getObjectAt(0));
        this.thisUpdate = Time32.getInstance(asn1Sequence.getObjectAt(1));
        this.nextUpdate = Time32.getInstance(asn1Sequence.getObjectAt(2));
        this.entries = SequenceOfCrlEntry.getInstance(asn1Sequence.getObjectAt(3));
    }
    
    public static ToBeSignedCrl getInstance(final Object o) {
        if (o instanceof ToBeSignedCrl) {
            return (ToBeSignedCrl)o;
        }
        if (o != null) {
            return new ToBeSignedCrl(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public Version getVersion() {
        return this.version;
    }
    
    public Time32 getThisUpdate() {
        return this.thisUpdate;
    }
    
    public Time32 getNextUpdate() {
        return this.nextUpdate;
    }
    
    public SequenceOfCrlEntry getEntries() {
        return this.entries;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(new ASN1Encodable[] { this.version, this.thisUpdate, this.nextUpdate, this.entries });
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder
    {
        private Version version;
        private Time32 thisUpdate;
        private Time32 nextUpdate;
        private SequenceOfCrlEntry entries;
        
        public Builder setVersion(final Version version) {
            this.version = version;
            return this;
        }
        
        public Builder setThisUpdate(final Time32 thisUpdate) {
            this.thisUpdate = thisUpdate;
            return this;
        }
        
        public Builder setNextUpdate(final Time32 nextUpdate) {
            this.nextUpdate = nextUpdate;
            return this;
        }
        
        public Builder setEntries(final SequenceOfCrlEntry entries) {
            this.entries = entries;
            return this;
        }
        
        public ToBeSignedCrl createToBeSignedCrl() {
            return new ToBeSignedCrl(this.version, this.thisUpdate, this.nextUpdate, this.entries);
        }
    }
}
