import com
.google
.common
.collect
.Lists
;
public class TestBase {
public static void main(String
[] args
) {
List
<BABY> list
= new TestBase().getList();
if (CommonUtils
.isNotEmpty(list
)) {
Set
<String> set
= new HashSet(Lists
.transform(list
, module
-> module
.getName()));
System
.out
.println("result:" + set
);
}
}
public List
<BABY> getList(){
List
<BABY> list
= new ArrayList();
list
.add(new BABY("张三",11,new Date()));
list
.add(new BABY("李四",12,new Date()));
list
.add(new BABY("张三",15,new Date()));
list
.add(new BABY("王五",13,new Date()));
list
.add(new BABY("赵六",14,new Date()));
list
.add(new BABY("张三",15,new Date()));
return list
;
}
class BABY{
private String name
;
private Integer age
;
private Date birthday
;
public BABY(String name
,Integer age
,Date birthday
){
this.name
= name
;
this.age
= age
;
this.birthday
= birthday
;
}
public String
getName() {
return name
;
}
public void setName(String name
) {
this.name
= name
;
}
public Integer
getAge() {
return age
;
}
public void setAge(Integer age
) {
this.age
= age
;
}
public Date
getBirthday() {
return birthday
;
}
public void setBirthday(Date birthday
) {
this.birthday
= birthday
;
}
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-8691.html