/*
 * Copyright Terracotta, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ehcache.jsr107;

/**
 * @author teck
 */
final class Unwrap {

  static <T> T unwrap(Class<T> clazz, Object... obj) {
    if (clazz == null || obj == null) {
      throw new NullPointerException();
    }

    for (Object o : obj) {
      if (o != null && clazz.isAssignableFrom(o.getClass())) {
        return clazz.cast(o);
      }
    }

    throw new IllegalArgumentException("Cannot unwrap to " + clazz);
  }

  private Unwrap() {
    //
  }
}

@@ -617,16 +617,104 @@
 sr107;%0A%0A
+import static java.util.Arrays.stream;%0Aimport static java.util.Objects.requireNonNull;%0A%0A
 /**%0A * @
@@ -814,235 +814,133 @@
     
-if (clazz == null %7C%7C obj == null) %7B%0A      throw new NullPointerException();%0A    %7D%0A%0A    for (Object o : obj) %7B%0A      if (o != null && clazz.isAssignableFrom(o.getClass())) %7B%0A        return 
+requireNonNull(clazz);%0A    return stream(obj).filter(clazz::isInstance).map(
 clazz
-.
+::
 cast
-(o);%0A      %7D%0A    %7D%0A%0A    throw
+).findFirst()%0A      .orElseThrow(() -%3E
  new
@@ -989,24 +989,25 @@
 o %22 + clazz)
+)
 ;%0A  %7D%0A%0A  pri

Use Java 8 constructs for unwrap