org.gradle.compile.daemon.ParallelCompilerDaemonIntegrationTest.shared.GroovyClass.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/**
* An immutable classpath.
*/
public class GroovyClass implements Serializable {
private final List files;
public GroovyClass(Iterable files) {
this.files = new ArrayList();
for (File file : files) {
this.files.add(file);
}
}
public GroovyClass(File... files) {
this(Arrays.asList(files));
}
@Override
public String toString() {
return files.toString();
}
public boolean isEmpty() {
return files.isEmpty();
}
public Collection getAsURIs() {
List urls = new ArrayList();
for (File file : files) {
urls.add(file.toURI());
}
return urls;
}
public Collection getAsFiles() {
return files;
}
public URL[] getAsURLArray() {
Collection result = getAsURLs();
return result.toArray(new URL[result.size()]);
}
public Collection getAsURLs() {
List urls = new ArrayList();
for (File file : files) {
try {
urls.add(file.toURI().toURL());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
return urls;
}
public GroovyClass plus(GroovyClass other) {
if (files.isEmpty()) {
return other;
}
if (other.isEmpty()) {
return this;
}
return new GroovyClass(concat(files, other.getAsFiles()));
}
public GroovyClass plus(Collection other) {
if (other.isEmpty()) {
return this;
}
return new GroovyClass(concat(files, other));
}
private Iterable concat(List files1, Collection files2) {
List result = new ArrayList();
result.addAll(files1);
result.addAll(files2);
return result;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != getClass()) {
return false;
}
GroovyClass other = (GroovyClass) obj;
return files.equals(other.files);
}
@Override
public int hashCode() {
return files.hashCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy