1 package org.onap.sdc.dcae.catalog.commons;
3 import java.util.Arrays;
6 import org.onap.sdc.dcae.catalog.commons.ListBuilder;
8 import java.util.LinkedList;
10 public class ListBuilder<T> {
14 public ListBuilder() {
15 this.list = new LinkedList<T>();
18 public boolean isEmpty() {
19 return this.list.isEmpty();
22 public ListBuilder add(T theValue) {
23 this.list.add(theValue);
27 public ListBuilder addAll(final Iterable<? extends T> theValues) {
28 for (final T val : theValues) {
34 public ListBuilder addAll(final List<? extends T> theList) {
35 this.list.addAll(theList);
39 public ListBuilder addAll(final T[] theArray) {
40 for (T t: theArray) this.list.add(t);
48 public List buildOpt() {
49 return this.list.isEmpty() ? null : this.list;
52 public static <V> List<V> asList(V[] theArray) {
53 return Arrays.asList(theArray);
56 public static <V> List<V> asListOpt(V[] theArray) {
57 return (theArray != null && theArray.length > 0) ? Arrays.asList(theArray) : null;