ジョン:
以下は、Employeeオブジェクトのリストを受け入れる方法ですが、私は内部の従業員の対象であるマップobejct、のid値を渡す必要があります。私はJava8に新しいです、plsは以下になります:
class Service {
void meth(List<Employee> employees){
employees.stream().flatMap(e -> map = e.getProps())
.keySet().stream())
.filter(s -> s.equals("id"))
.allMatch(idValue -> isIdValid(empName, idValue).test(id)); //how to pass empName and "id" Value here from employee map props object??
}
boolean isIdValid(String name, String id){
//validation of id here
}
}
class Employee{
String name;
Map<String, Object> props;
}
従業員のJSON
{
"name": "name1",
"props": {
"id": "123", //this value has to retreive
"field2": "hey"
}
}
私はisIdValid方法、どのようにplsは中のempNameおよび「ID」の値を渡す必要がありますか?
また:
あなたは使用することができますentrySet
よう:
return employees.stream()
.flatMap(e -> e.getProps().entrySet().stream())
.filter(s -> s.getKey().equals("id"))
.allMatch(e -> isIdValid(idValue).test(e.getValue()));