Skip to content

Instantly share code, notes, and snippets.

@KalpaD
Created February 6, 2021 04:14
Show Gist options
  • Select an option

  • Save KalpaD/ed8a89ecd50c3b36c3920ab40d5fbf3e to your computer and use it in GitHub Desktop.

Select an option

Save KalpaD/ed8a89ecd50c3b36c3920ab40d5fbf3e to your computer and use it in GitHub Desktop.
public class FormattedNameResponseMapper {
private FormattedNameResponseMapper() {
}
public static FormattedNameResponse fromWebExchangeBindException(WebExchangeBindException ex) {
FormattedNameResponse res = new FormattedNameResponse();
List<Error> errors = ex.getFieldErrors().stream()
.map(fieldError -> new Error(fieldError.getField(), fieldError.getDefaultMessage()))
.collect(Collectors.toList());
res.setErrors(errors);
return res;
}
public static FormattedNameResponse fromFormatNameRequest(FormatNameRequest req) {
String s = String.format("%s %s %s %s", req.getTitle(), req.getFirstName(), req.getMiddleName(), req.getLastName());
FormattedNameResponse res = new FormattedNameResponse();
res.setFormattedName(s);
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment