Is there a way to determine at runtime if an object was created using Lambdaj.on() method?

59 Views Asked by At

I want to write a method that takes as a parameter either result of Lambdaj.on() call or a string.

public static <T> void method(T arg) {
}

T can be String here. Is it possible to determine if arg was created using Lambdaj.on() method?

1

There are 1 best solutions below

0
alkedr On

After reading Lambdaj source code (ArgumentsFactory.java for the most part) I can conclude that this is impossible.

Lambdaj stores data in a WeakHashMap<Object, Argument<?>>, where key is what return things like on(SomeCLass.classs).getX(). WeakHashMap compares objects using .hashCode() and .equals().