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?
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?
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()
.