/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.reflection.impl;

import java.lang.reflect.Parameter;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import net.ranides.assira.collection.maps.OrderedMap;
import net.ranides.assira.collection.query.CQuery;
import net.ranides.assira.collection.query.CQueryBuilder;
import net.ranides.assira.reflection.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class AArguments extends AElements<IArgument> implements IArguments {

    AArguments(IHints hints, CQuery<IArgument> stream) {
        super(hints, stream);
    }
    
    public static IArguments typeinfo(IClass... types) {
        return new AArguments(AHints.EMPTY, CQueryBuilder.fromArray(types).map(CArgument::new));
    }
    
    public static IArguments typeinfo(Class<?>... types) {
        return new AArguments(AHints.EMPTY, CQueryBuilder.fromArray(types).map(CArgument::new));
    }
    
    public static IArguments typeinfo(OrderedMap<String, IClass> arguments) {
        return new AArguments(AHints.EMPTY, CQueryBuilder.fromCollection(arguments.entrySet()).map(CArgument::new));
    }

    @Override
    public List<String> names() {
        return list(IArgument::name);
    }

    @Override
    public IClasses types() {
        return new AClasses(AHints.EMPTY, stream(IArgument::type));
    }
    
    @Override
    public IMethods parent() {
        return new AMethods(AHints.EMPTY, stream(IArgument::parent));
    }

    @Override
    public Map<String, IArgument> map() {
        return stream().collect(Collectors.toMap(IArgument::name, a -> a));
    }

    @Override
    public CQuery<Parameter> reflective() {
        return stream().map(IArgument::reflective);
    }
    
}
