package be.iminds.ilabt.jfed.groovy_dsl.impl.events;

import be.iminds.ilabt.jfed.groovy_dsl.DSLStreamException;
import be.iminds.ilabt.jfed.groovy_dsl.events.ClosureRefArgument;

import java.io.IOException;
import java.io.Writer;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * User: twalcari
 * Date: 5/18/2015
 * Time: 14:48
 */
public class ClosureRefArgumentImpl extends FunctionArgumentImpl implements ClosureRefArgument {

    private final String ref;

    public ClosureRefArgumentImpl(String ... parts){
        this.ref = Arrays.stream(parts).collect(Collectors.joining("."));
    }

    @Override
    public void write(Writer writer) throws DSLStreamException {
        try {
            writer.write(ref);
        } catch (IOException e) {
            throw new DSLStreamException(e);
        }
    }
}
