use of dyvil.collection.mutable.ArrayList in project Dyvil by Dyvil.
the class FileUtils method readLines.
@DyvilModifiers(Modifiers.INFIX)
@NonNull
public static List<@NonNull String> readLines(@NonNull File file) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(file.toPath())) {
final List<String> result = new ArrayList<>();
for (; ; ) {
String line = reader.readLine();
if (line == null) {
break;
}
result.add(line);
}
return result;
}
}
use of dyvil.collection.mutable.ArrayList in project Dyvil by Dyvil.
the class TestThread method getCommand.
public String[] getCommand() {
final List<Library> libraries = this.compiler.config.libraries;
StringBuilder classpath = new StringBuilder();
classpath.append(this.compiler.config.getOutputDir());
for (Library library : libraries) {
classpath.append(':').append(library.getFile());
}
final List<String> command = new ArrayList<>();
command.add("java");
command.add("-cp");
command.add(classpath.toString());
command.add(this.compiler.config.getMainType());
command.addAll(this.compiler.config.getMainArgs());
return command.toArray(String.class);
}
use of dyvil.collection.mutable.ArrayList in project Dyvil by Dyvil.
the class CodeMethod method checkDuplicates.
private void checkDuplicates(MarkerList markers) {
final Collection<IMethod> candidates = new ArrayList<>();
this.enclosingClass.addMethods(candidates);
if (candidates.isEmpty()) {
return;
}
final String internalName = this.getInternalName();
final String descriptor = this.getDescriptor();
final int parameterCount = this.parameters.size();
for (IMethod method : candidates) {
if (// exclude this method
method != this && // optimization
method.getParameters().size() == parameterCount && method.getInternalName().equals(internalName) && method.getDescriptor().equals(descriptor)) {
final Marker marker = Markers.semanticError(this.position, "method.duplicate", this.name, this.internalName, descriptor);
markers.add(marker);
}
}
}
use of dyvil.collection.mutable.ArrayList in project Dyvil by Dyvil.
the class FieldReflection method getObjects.
@NonNull
public static <T> T[] getObjects(@NonNull Class clazz, Object instance, @NonNull Class<T> fieldType, boolean subtypes) {
List list = new ArrayList();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
try {
Class c = field.getType();
Object o = field.get(instance);
if (c == fieldType || subtypes && fieldType.isAssignableFrom(c)) {
list.add(o);
}
} catch (Exception ex) {
}
}
return (T[]) list.toArray();
}
Aggregations