protected BaseTemplate(IEnumerable <IToken> fTokens)
     : this(
         new ImmutableMap <TokenKey, IToken>(), ImmutableList.Empty <TokenReference>(), new ImmutableMap <InputKey, IInput>(),
         ProcessingQueue.Empty())
 {
     foreach (var tok in fTokens)
     {
         if (tokenMap.ContainsKey(tok.Key))
         {
             tokenSeq = tokenSeq.ConsLast(new TokenReference(tok.Key));
         }
         else
         {
             foreach (var input in tok.Inputs)
             {
                 if (!inputs.ContainsKey(input.Key))
                 {
                     var newInput = input.Key.Type == InputType.Instance
                                                                 ? (IInput) new UnboundInput(input.Key) : new UnboundStaticInput(input.Key);
                     inputs = inputs.Add(input.Key, newInput);
                 }
             }
             tokenMap = tokenMap.Add(tok.Key, tok);
             tokenSeq = tokenSeq.ConsLast(new TokenReference(tok.Key));
         }
     }
 }
        // the input map is treated as being ordered
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private CalculationParameters(java.util.Map<Class, CalculationParameter> parameters)
        private CalculationParameters(IDictionary <Type, CalculationParameter> parameters)
        {
            JodaBeanUtils.notNull(parameters, "parameters");
            this.parameters = ImmutableMap.copyOf(parameters);
            // find parameters that are super-interfaces of the specified objects
            IDictionary <Type, Type> aliases = new Dictionary <Type, Type>();

            foreach (Type type in parameters.Keys)
            {
                Type[] interfaces = type.GetInterfaces();
                foreach (Type iface in interfaces)
                {
                    if (iface != typeof(CalculationParameter) && iface.IsAssignableFrom(typeof(CalculationParameter)) && !parameters.ContainsKey(iface))
                    {
                        // first registration wins with aliases
                        Type aliasType = iface.asSubclass(typeof(CalculationParameter));
                        if (!aliases.ContainsKey(aliasType))
                        {
                            aliases.Add(aliasType, type);
                        }
                    }
                }
            }
            this.aliases = ImmutableMap.copyOf(aliases);
        }