我对属性有点问题。我目前正在开发一个项目,该项目将来自LDAP服务器的电子邮件解析为Java应用程序,该应用程序将在未来通过电子邮件做一些有趣的事情。
我目前正在使用此代码来接收来自LDAP用户的电子邮件,并且需要将电子邮件放入User类中,如我的代码中所示:
public User(String mail){
eMail = "NO EMAIL!";
if (mail != null && !mail.isEmpty()){
eMail = mail;
}
else
{
eMail = "NO EMAIL!";
}
}
这是User class的构造函数:
case class container(id: String, `type`: Option[String], things: List[???])
答案 0 :(得分:1)
试试这个
User user = new User(attrs.get("mail")!=null?attrs.get("mail").toString():null);
答案 1 :(得分:0)
首先,您需要使用!= null
检查给定属性是否存在(例如,使用Objects.toString
执行内部操作,或手动if)检查,然后使用toString
{ {1}},就像内部Attribute
一样:
println
或者您也可以使用(在属性中检索单个值,如果您有许多需要使用User user = new User(Objects.toString(attrs.get("mail")));
):
getAll