net.serenitybdd.jbehave.reflection.Extract Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-jbehave Show documentation
Show all versions of serenity-jbehave Show documentation
Serenity JBehave integration
package net.serenitybdd.jbehave.reflection;
import java.lang.reflect.Field;
public class Extract {
private final String fieldName;
private Extract(String fieldName) {
this.fieldName = fieldName;
}
public static Extract field(String fieldName) {
return new Extract(fieldName);
}
public Object from(Object object) {
try {
Field field = object.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
return field.get(object);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy