Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.