I have a class TeamResponse used to form a JSON response. It has a handful of parameters, and one of them can be optional:
public TeamResponse(Team team, List<TeamSkillTemplateResponse> teamSkillTemplateResponses) {
this.id = team.getId();
this.name = team.getName();
this.department = new DepartmentResponse(team.getDepartment());
this.division = new DivisionResponse(team.getDepartment().getDivision());
this.valueStream = team.getValueStream().map(ValueStreamResponse::new).orElseGet(null);
this.skillTemplate = teamSkillTemplateResponses;
}
I have actually two questions on this one: 1. Is it appropriate to return null in the response, if the value is not present? 2. Is it appropriate to return null THIS way? (method getTeam() returns Optional)
Thank you.