mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +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.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public final class ReflectionTools {
|
public final class ReflectionTools {
|
||||||
@ -58,7 +59,7 @@ public final class ReflectionTools {
|
|||||||
public Method getMethod(Class<?> clazz, String name, Class<?>... params) {
|
public Method getMethod(Class<?> clazz, String name, Class<?>... params) {
|
||||||
try {
|
try {
|
||||||
return Wrapper.of(clazz.getMethod(name, params))
|
return Wrapper.of(clazz.getMethod(name, params))
|
||||||
.filter(obj -> obj.setAccessible(true))
|
.perform(obj -> obj.setAccessible(true))
|
||||||
.get();
|
.get();
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -6,6 +6,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
|
|||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public final class Wrapper<T> {
|
public final class Wrapper<T> {
|
||||||
protected T bean;
|
protected T bean;
|
||||||
@ -61,7 +62,7 @@ public final class Wrapper<T> {
|
|||||||
return new Wrapper<>(function.apply(get()));
|
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());
|
consumer.accept(get());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -70,4 +71,8 @@ public final class Wrapper<T> {
|
|||||||
supplier.get();
|
supplier.get();
|
||||||
return this;
|
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