Last active
August 29, 2015 14:21
-
-
Save maxov/67d146c5710d3b4a9ae6 to your computer and use it in GitHub Desktop.
which is better?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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