-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
113 additions
and
43 deletions.
There are no files selected for viewing
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
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
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
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
59 changes: 59 additions & 0 deletions
59
core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementsBuilder.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jboss.gwt.elemento.core.builder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import elemental2.dom.HTMLElement; | ||
import org.jboss.gwt.elemento.core.HasElements; | ||
import org.jboss.gwt.elemento.core.IsElement; | ||
|
||
/** A builder to collect elements in a flat list as {@link HasElements} */ | ||
public class ElementsBuilder implements HasElements { | ||
|
||
private final List<HTMLElement> elements; | ||
|
||
public ElementsBuilder() {elements = new ArrayList<>();} | ||
|
||
|
||
// ------------------------------------------------------ mirror add() methods from HtmlContent | ||
|
||
/** Add the given element by calling {@code element.asElement()}. */ | ||
public ElementsBuilder add(IsElement element) { | ||
return add(element.asElement()); | ||
} | ||
|
||
/** Adds the given element. */ | ||
public ElementsBuilder add(HTMLElement element) { | ||
elements.add(element); | ||
return this; | ||
} | ||
|
||
/** Adds all elements from {@code elements.asElements()}. */ | ||
public ElementsBuilder addAll(HasElements elements) { | ||
return addAll(elements.asElements()); | ||
} | ||
|
||
/** Adds all elements. */ | ||
public ElementsBuilder addAll(HTMLElement... elements) { | ||
for (HTMLElement element : elements) { add(element); } | ||
return this; | ||
} | ||
|
||
/** Adds all elements. */ | ||
public ElementsBuilder addAll(Iterable<HTMLElement> elements) { | ||
for (HTMLElement element : elements) { add(element); } | ||
return this; | ||
} | ||
|
||
/** Adds all elements. */ | ||
public ElementsBuilder addAll(IsElement... elements) { | ||
for (IsElement element : elements) { add(element); } | ||
return this; | ||
} | ||
|
||
/** Returns the elements added so far. */ | ||
@Override | ||
public Iterable<HTMLElement> asElements() { | ||
return elements; | ||
} | ||
} |
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
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
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
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
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
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
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
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
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