@Test void testSingleComponentLike() { final Component c0 = Component.text("kittens"); assertSame(c0, LinearComponents.linear(c0)); }
public static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables) { final int length = applicables.length; if(length == 0) return Component.empty(); if(length == 1) { final ComponentBuilderApplicable ap0 = applicables[0]; if(ap0 instanceof ComponentLike) { return ((ComponentLike) ap0).asComponent(); } throw nothingComponentLike(); } final TextComponentImpl.BuilderImpl builder = new TextComponentImpl.BuilderImpl(); Style.Builder style = null; for(int i = 0; i < length; i++) { final ComponentBuilderApplicable applicable = applicables[i]; if(applicable instanceof StyleBuilderApplicable) { if(style == null) { style = Style.style(); } style.apply((StyleBuilderApplicable) applicable); } else if(style != null && applicable instanceof ComponentLike) { builder.applicableApply(((ComponentLike) applicable).asComponent().style(style)); } else { builder.applicableApply(applicable); } } final int size = builder.children.size(); if(size == 0) { throw nothingComponentLike(); } else if(size == 1) { return builder.children.get(0); } else { return builder.build(); } }
LinearComponents { public static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables) { final int length = applicables.length; if(length == 0) return Component.empty(); if(length == 1) { final ComponentBuilderApplicable ap0 = applicables[0]; if(ap0 instanceof ComponentLike) { return ((ComponentLike) ap0).asComponent(); } throw nothingComponentLike(); } final TextComponentImpl.BuilderImpl builder = new TextComponentImpl.BuilderImpl(); Style.Builder style = null; for(int i = 0; i < length; i++) { final ComponentBuilderApplicable applicable = applicables[i]; if(applicable instanceof StyleBuilderApplicable) { if(style == null) { style = Style.style(); } style.apply((StyleBuilderApplicable) applicable); } else if(style != null && applicable instanceof ComponentLike) { builder.applicableApply(((ComponentLike) applicable).asComponent().style(style)); } else { builder.applicableApply(applicable); } } final int size = builder.children.size(); if(size == 0) { throw nothingComponentLike(); } else if(size == 1) { return builder.children.get(0); } else { return builder.build(); } } }
LinearComponents { public static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables) { final int length = applicables.length; if(length == 0) return Component.empty(); if(length == 1) { final ComponentBuilderApplicable ap0 = applicables[0]; if(ap0 instanceof ComponentLike) { return ((ComponentLike) ap0).asComponent(); } throw nothingComponentLike(); } final TextComponentImpl.BuilderImpl builder = new TextComponentImpl.BuilderImpl(); Style.Builder style = null; for(int i = 0; i < length; i++) { final ComponentBuilderApplicable applicable = applicables[i]; if(applicable instanceof StyleBuilderApplicable) { if(style == null) { style = Style.style(); } style.apply((StyleBuilderApplicable) applicable); } else if(style != null && applicable instanceof ComponentLike) { builder.applicableApply(((ComponentLike) applicable).asComponent().style(style)); } else { builder.applicableApply(applicable); } } final int size = builder.children.size(); if(size == 0) { throw nothingComponentLike(); } else if(size == 1) { return builder.children.get(0); } else { return builder.build(); } } private  LinearComponents(); }
LinearComponents { public static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables) { final int length = applicables.length; if(length == 0) return Component.empty(); if(length == 1) { final ComponentBuilderApplicable ap0 = applicables[0]; if(ap0 instanceof ComponentLike) { return ((ComponentLike) ap0).asComponent(); } throw nothingComponentLike(); } final TextComponentImpl.BuilderImpl builder = new TextComponentImpl.BuilderImpl(); Style.Builder style = null; for(int i = 0; i < length; i++) { final ComponentBuilderApplicable applicable = applicables[i]; if(applicable instanceof StyleBuilderApplicable) { if(style == null) { style = Style.style(); } style.apply((StyleBuilderApplicable) applicable); } else if(style != null && applicable instanceof ComponentLike) { builder.applicableApply(((ComponentLike) applicable).asComponent().style(style)); } else { builder.applicableApply(applicable); } } final int size = builder.children.size(); if(size == 0) { throw nothingComponentLike(); } else if(size == 1) { return builder.children.get(0); } else { return builder.build(); } } private  LinearComponents(); static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables); }
LinearComponents { public static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables) { final int length = applicables.length; if(length == 0) return Component.empty(); if(length == 1) { final ComponentBuilderApplicable ap0 = applicables[0]; if(ap0 instanceof ComponentLike) { return ((ComponentLike) ap0).asComponent(); } throw nothingComponentLike(); } final TextComponentImpl.BuilderImpl builder = new TextComponentImpl.BuilderImpl(); Style.Builder style = null; for(int i = 0; i < length; i++) { final ComponentBuilderApplicable applicable = applicables[i]; if(applicable instanceof StyleBuilderApplicable) { if(style == null) { style = Style.style(); } style.apply((StyleBuilderApplicable) applicable); } else if(style != null && applicable instanceof ComponentLike) { builder.applicableApply(((ComponentLike) applicable).asComponent().style(style)); } else { builder.applicableApply(applicable); } } final int size = builder.children.size(); if(size == 0) { throw nothingComponentLike(); } else if(size == 1) { return builder.children.get(0); } else { return builder.build(); } } private  LinearComponents(); static @NonNull Component linear(final @NonNull ComponentBuilderApplicable@NonNull... applicables);  }