protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINED); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }
@Override public @NonNull B mapChildrenDeep(final @NonNull Function<BuildableComponent<? ,?>, BuildableComponent<? ,?>> function) { if(this.children == EMPTY_COMPONENT_LIST) { return (B) this; } final ListIterator<Component> it = this.children.listIterator(); while(it.hasNext()) { final Component child = it.next(); if(!(child instanceof BuildableComponent)) { continue; } final BuildableComponent mappedChild = function.apply((BuildableComponent) child); if(mappedChild.children().isEmpty()) { if(child == mappedChild) { continue; } it.set(mappedChild); } else { final Builder<?, ?> builder = mappedChild.toBuilder(); builder.mapChildrenDeep(function); it.set(builder.build()); } } return (B) this; }
protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINED); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) public @NonNull B mapChildrenDeep(final @NonNull Function<BuildableComponent<? ,?>, BuildableComponent<? ,?>> function) { if(this.children == EMPTY_COMPONENT_LIST) { return (B) this; } final ListIterator<Component> it = this.children.listIterator(); while(it.hasNext()) { final Component child = it.next(); if(!(child instanceof BuildableComponent)) { continue; } final BuildableComponent mappedChild = function.apply((BuildableComponent) child); if(mappedChild.children().isEmpty()) { if(child == mappedChild) { continue; } it.set(mappedChild); } else { final Builder<?, ?> builder = mappedChild.toBuilder(); builder.mapChildrenDeep(function); it.set(builder.build()); } } return (B) this; }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) public @NonNull B mapChildrenDeep(final @NonNull Function<BuildableComponent<? ,?>, BuildableComponent<? ,?>> function) { if(this.children == EMPTY_COMPONENT_LIST) { return (B) this; } final ListIterator<Component> it = this.children.listIterator(); while(it.hasNext()) { final Component child = it.next(); if(!(child instanceof BuildableComponent)) { continue; } final BuildableComponent mappedChild = function.apply((BuildableComponent) child); if(mappedChild.children().isEmpty()) { if(child == mappedChild) { continue; } it.set(mappedChild); } else { final Builder<?, ?> builder = mappedChild.toBuilder(); builder.mapChildrenDeep(function); it.set(builder.build()); } } return (B) this; }
protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINE); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }