![JAR search and dependency download from the Maven repository](/logo.png)
com.github.geekonjava.reflection.Phanton Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Purify4J Show documentation
Show all versions of Purify4J Show documentation
Simple library for use to refine the Java Collection Objects
The newest version!
package com.github.geekonjava.reflection;
import java.lang.reflect.Field;
public class Phanton {
private final T target;
private Class> clazz;
private Phanton(T target) {
this.target = target;
clazz = target.getClass();
}
public static Phanton from(T target) {
return new Phanton(target);
}
public Object call(String name) {
return invoke(name);
}
private Object invoke(String name) {
for (final Field field : clazz.getDeclaredFields()) {
try {
if (name.equals(field.getName())) {
field.setAccessible(Boolean.TRUE);
return field.get(target);
}
} catch (final IllegalAccessException e) {
throw new RuntimeException(e);
}
}
throw new RuntimeException("No such property with name " + name);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy