Skip to content

Instantly share code, notes, and snippets.

@ilmoeuro
Created February 27, 2018 12:07
Show Gist options
  • Save ilmoeuro/6d79dc9ed635a56ff957719c806958c9 to your computer and use it in GitHub Desktop.
Save ilmoeuro/6d79dc9ed635a56ff957719c806958c9 to your computer and use it in GitHub Desktop.
private Device deviceFromEntity(DeviceEntity entity) {
Device result = new Device();
result.setId(entity.getId());
result.setName(entity.getName());
return result;
}
@Override
public Response listDevices(
Long userId,
Integer firstResult,
Integer maxResults) throws Exception {
// TODO error handling
List<DeviceEntity> entities = deviceDAO.listAll(firstResult, maxResults);
List<Device> devices = entities.stream()
.map(this::deviceFromEntity)
.collect(Collectors.toList());
return Response.ok(devices).build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment