mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 00:37:36 +00:00
BLEEDING EDGE v1.3_061
This commit is contained in:
parent
5f37e63b0f
commit
5490213609
@ -9,6 +9,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class ReflectionTools {
|
||||
@ -58,7 +59,7 @@ public final class ReflectionTools {
|
||||
public Method getMethod(Class<?> clazz, String name, Class<?>... params) {
|
||||
try {
|
||||
return Wrapper.of(clazz.getMethod(name, params))
|
||||
.filter(obj -> obj.setAccessible(true))
|
||||
.perform(obj -> obj.setAccessible(true))
|
||||
.get();
|
||||
} catch (NoSuchMethodException e) {
|
||||
return null;
|
||||
|
@ -6,6 +6,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class Wrapper<T> {
|
||||
protected T bean;
|
||||
@ -61,7 +62,7 @@ public final class Wrapper<T> {
|
||||
return new Wrapper<>(function.apply(get()));
|
||||
}
|
||||
|
||||
public final Wrapper<T> filter(Consumer<? super T> consumer) {
|
||||
public final Wrapper<T> perform(Consumer<? super T> consumer) {
|
||||
consumer.accept(get());
|
||||
return this;
|
||||
}
|
||||
@ -70,4 +71,8 @@ public final class Wrapper<T> {
|
||||
supplier.get();
|
||||
return this;
|
||||
}
|
||||
|
||||
public final Wrapper<T> filter(Predicate<? super T> predicate) {
|
||||
return predicate.test(get()) ? this : null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user