br.com.objectos.way.etc.CopyTo Maven / Gradle / Ivy
The newest version!
/*
* CopyTo.java criado em 15/12/2013
*
* Propriedade de Objectos Fábrica de Software LTDA.
* Reprodução parcial ou total proibida.
*/
package br.com.objectos.way.etc;
import java.util.List;
import java.util.Set;
import br.com.objectos.way.core.io.Directory;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
/**
* @author [email protected] (Marcio Endo)
*/
class CopyTo {
final ResourceSet set;
final Directory targetDir;
public CopyTo(ResourceSet set, Directory targetDir) {
this.set = set;
this.targetDir = targetDir;
}
public void execute() {
Set resources;
resources = set.getResources();
Iterable copies;
copies = Iterables.transform(resources, new ToResourceCopy());
Iterable> listzes;
listzes = Iterables.transform(copies, new Copier());
Iterable _exceptions;
_exceptions = Iterables.concat(listzes);
List exceptions;
exceptions = ImmutableList.copyOf(_exceptions);
for (Exception exception : exceptions) {
exception.printStackTrace();
}
}
ResourceCopy resourceCopy(Resource resource) {
return ResourceCopy.copyTo(set, resource);
}
private class ToResourceCopy implements Function {
@Override
public ResourceCopy apply(Resource resource) {
return resourceCopy(resource);
}
}
private class Copier implements Function> {
@Override
public List apply(ResourceCopy copy) {
return copy.copyTo(targetDir);
}
}
}