DATACMNS-1074 - Polishing.

Java-8-ification.

Original pull request: #221.
This commit is contained in:
Oliver Gierke
2017-06-07 10:17:31 +02:00
parent 83d9c56eb4
commit 976aeaf34c

View File

@@ -21,6 +21,7 @@ import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
@@ -163,13 +164,10 @@ public class DefaultMethodInvokingMethodInterceptor implements MethodInterceptor
*/
public static MethodHandleLookup getMethodHandleLookup() {
for (MethodHandleLookup lookup : MethodHandleLookup.values()) {
if (lookup.isAvailable()) {
return lookup;
}
}
throw new IllegalStateException("No MethodHandleLookup available!");
return Arrays.stream(MethodHandleLookup.values()) //
.filter(it -> it.isAvailable()) //
.findFirst() //
.orElseThrow(() -> new IllegalStateException("No MethodHandleLookup available!"));
}
private static Optional<Constructor<Lookup>> getLookupConstructor() {