i have a array of StudentLogin where name is the key and value is value
"studentLogin" : [
{
"name" : "firstName_key",
"value" : "<actual first Name value>"
},
{
"name" : "lastName_key",
"value" : "<actual last Name value>"
},
....
]
i have a method which i get List of studentLogin as an input parameter,i need to check if firstName(key) and lastName(key) is present in the same index or not if yes then i need to concat the actual value of firstname and lastname from same index.
i wrote the below method but using two streams,i want to convert it into one stream.
public String convertStudentLoginToFullName(List<StudentLogin> studentLogin) {
if (null != studentLogin) {
String firstName = studentLogin.stream()
.filter(x -> "firstName_key".equalsIgnoreCase(x.getName()))
.map(x->x.getValue())
.findFirst()
.orElse(null);
String lastName = studentLogin.stream()
.filter(x -> "lastName_key".equalsIgnoreCase(x.getName()))
.map(x -> x.getValue())
.findFirst()
.orElse(null);
String fullName=firstName+" "+lastName;
return fullName;
}
}
return null;
}