For anyone familiar with lambdaj (not I) you will have seen this stacktrace, or some variation, before:
ch.lambdaj.function.argument.ArgumentConversionException: Unable to convert the placeholder org.dom4j.tree.AbstractAttribute in a valid argument at ch.lambdaj.function.argument.ArgumentsFactory.actualArgument(ArgumentsFactory.java:92) at ch.lambdaj.function.matcher.HasArgumentWithValue.havingValue(HasArgumentWithValue.java:70) at ch.lambdaj.Lambda.having(Lambda.java:1204)
My understadning is that this happens through a limitation of lambdaj with final classes.
I get the above when testing the following code:
import static ch.lambdaj.Lambda.having;
import static ch.lambdaj.Lambda.selectFirst;
import static org.hamcrest.CoreMatchers.equalTo;
import java.util.List;
import org.dom4j.tree.AbstractAttribute;
public class DocumentUtils {
public static String getAttributeValueFromListByName(
List<AbstractAttribute> list, String name) {
AbstractAttribute requiredAttribute = selectFirst(list,
having((AbstractAttribute.class).getName(), equalTo(name)));
String value = requiredAttribute.getValue();
return value;
}
}
I had been using dom4j's Attribute interface, getting the same problem, then thought maybe lambdaj doesn't like interfaces.. so I switched to the AbstractAttribute abstract class.
Is there an issue with lambdaj and abstract classes? Or is my method just pants? Any ideas how to solve this?
FYI: I'm using lambdaj 2.4 and dom4j 1.6
Thanks a lot in advance.
Issue 92 has been raised with lambdaj, as requested by Mario Fusco (LambdaJ Developer)