Skip to content

Instantly share code, notes, and snippets.

@maxov
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxov/67d146c5710d3b4a9ae6 to your computer and use it in GitHub Desktop.
Save maxov/67d146c5710d3b4a9ae6 to your computer and use it in GitHub Desktop.
which is better?
// current data api
Optional<DisplayNameData> wrappedDisplayName = entity.getData(DisplayNameData.class);
if (wrappedDisplayName.isPresent()) {
DisplayNameData displayname = wrappedDisplayName.get();
displayname.setDisplayName(Texts.of(displayName.get(), "hai!"));
entity.offer(displayname);
}
// value api
if (entity.supports(Values.DISPLAY_NAME)) {
entity.set(Values.DISPLAY_NAME, Texts.of(entity.tryGet(Values.DISPLAY_NAME), "hai!"));
}
// bound data?
BoundValue<Text> displayName = entity.bind(Values.DISPLAY_NAME);
if (displayName.exists()) {
displayName.set(Texts.of(displayName.get(), "hai!"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment