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

package org.bouncycastle.jcajce.spec;

import java.util.Collections;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.security.spec.AlgorithmParameterSpec;

public class CompositeAlgorithmSpec implements AlgorithmParameterSpec
{
    private final List<String> algorithmNames;
    private final List<AlgorithmParameterSpec> parameterSpecs;
    
    public CompositeAlgorithmSpec(final Builder builder) {
        this.algorithmNames = Collections.unmodifiableList((List<? extends String>)new ArrayList<String>(builder.algorithmNames));
        this.parameterSpecs = Collections.unmodifiableList((List<? extends AlgorithmParameterSpec>)new ArrayList<AlgorithmParameterSpec>(builder.parameterSpecs));
    }
    
    public List<String> getAlgorithmNames() {
        return this.algorithmNames;
    }
    
    public List<AlgorithmParameterSpec> getParameterSpecs() {
        return this.parameterSpecs;
    }
    
    public static class Builder
    {
        private List<String> algorithmNames;
        private List<AlgorithmParameterSpec> parameterSpecs;
        
        public Builder() {
            this.algorithmNames = new ArrayList<String>();
            this.parameterSpecs = new ArrayList<AlgorithmParameterSpec>();
        }
        
        public Builder add(final String s) {
            return this.add(s, null);
        }
        
        public Builder add(final String s, final AlgorithmParameterSpec algorithmParameterSpec) {
            if (!this.algorithmNames.contains(s)) {
                this.algorithmNames.add(s);
                this.parameterSpecs.add(algorithmParameterSpec);
                return this;
            }
            throw new IllegalStateException("cannot build with the same algorithm name added");
        }
        
        public CompositeAlgorithmSpec build() {
            if (this.algorithmNames.isEmpty()) {
                throw new IllegalStateException("cannot call build with no algorithm names added");
            }
            return new CompositeAlgorithmSpec(this);
        }
    }
}
