@FunctionalInterface
public interface LeafReference<P, C> extends Serializable {
/**
- * Dummy method to express the method signature of a typical getter. This method
+ * Dummy method to express the method signature of a typical getter. Due to this match we can match any Java
+ * method reference which takes in {@code parent} and results in {@code child} -- expose the feature of using
+ * {@code Parent::getChild} method shorthand.
*
* @param parent Parent object
* @return Leaf value
* @deprecated This method is present only for technical realization of taking the method reference and should
- * never be involved directly.
+ * never be involved directly. See {@code LambdaDecoder} for gory details.
*/
@Deprecated(forRemoval = true)
C dummyMethod(P parent);
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.function.Function;
import org.opendaylight.mdsal.binding.api.query.MatchBuilderPath.LeafReference;
import org.opendaylight.yangtools.concepts.Immutable;
* to {@link LeafReference} lambdas.
*
* <p>
- * We then assume runtime is following guidance around {@link SerializedLambda}, thus Serializable lambdas have a
- * {@code writeReplace()} method and that it produces {@link SerializedLambda} -- which we use to get the information
+ * We then assume runtime is following guidance around {@link SerializedLambda}, thus {@link Serializable} lambdas have
+ * a {@code writeReplace()} method and it produces a {@link SerializedLambda} -- which we use to get the information
* about what the lambda does at least in the single case we support.
*
* <p>
* <li>it creates additional implementation of the interface, bringing the system-wide total to 3, which can hurt
* JIT's decisions</li>
* </ul>
+ * While that approach would certainly be feasible and would on top of plain {@link Function}, overall it would be
+ * messier, less type-safe and a perf-killer.
*/
final class LambdaDecoder {
+ // FIXME: when we have JDK16: this should be a record
static final class LambdaTarget implements Immutable {
final String targetClass;
final String targetMethod;