我有一个简单的 pojo:
class UserId {
String ssn;
String otsId;
Integer actorId;
public UserId(String ssn, String otsId, Integer actorId) {
this.ssn = ssn;
this.otsId = otsId;
this.actorId = actorId;
}
@Override
public String toString() {
return "[otsId=" + otsId + ", ssn=" + ssn + ", actorId=" + actorId + "]";
}
}
例如,我想从那里提取所有ssn
值到 a List<String>
。所以就像我写的一个例子:
public class UserIdTest {
public static void main(String[] args) {
List<UserId> list = new ArrayList<UserId>();
list.add(new UserId("111111-1111", "12345678", new Integer(234589235)));
list.add(new UserId("111111-1111", "12345678", new Integer(234589235)));
list.add(new UserId("111111-1111", "12345678", new Integer(234589235)));
getSsnList(list);
}
private static List<String> getSsnList(List<UserId> users) {
return extract(users, on(UserId.class).ssn);
}
}
和 LambdaJ 抛出:
Exception in thread "main" ch.lambdaj.function.argument.ArgumentConversionException: Unable to convert the placeholder null in a valid argument
at ch.lambdaj.function.argument.ArgumentsFactory.actualArgument(ArgumentsFactory.java:76)
at ch.lambdaj.function.convert.ArgumentConverter.<init>(ArgumentConverter.java:29)
at ch.lambdaj.Lambda.extract(Lambda.java:1035)
at UserIdTest.getSsnList(UserIdTest.java:23)
at UserIdTest.main(UserIdTest.java:20)
这似乎是一个非常基本的操作,所以我在这里缺少什么?