aboutsummaryrefslogtreecommitdiff
path: root/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
diff options
context:
space:
mode:
Diffstat (limited to 'guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java')
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
index d5a8dad54..a5ba12333 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
@@ -18,6 +18,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.util.ArrayList;
import java.util.Collection;
@@ -26,6 +27,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collector;
+import jsinterop.annotations.JsMethod;
/**
* GWT emulated version of {@link com.google.common.collect.ImmutableSet}. For the unsorted sets,
@@ -84,6 +86,13 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
return copyOf(all.iterator());
}
+ /** ImmutableSet.of API that is friendly to use from JavaScript. */
+ @JsMethod(name = "of")
+ static <E> ImmutableSet<E> jsOf(E... elements) {
+ return copyOf(elements);
+ }
+
+ @JsMethod
public static <E> ImmutableSet<E> copyOf(E[] elements) {
checkNotNull(elements);
switch (elements.length) {
@@ -237,12 +246,14 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
this.contents = Lists.newArrayListWithCapacity(initialCapacity);
}
+ @CanIgnoreReturnValue
@Override
public Builder<E> add(E element) {
contents.add(checkNotNull(element));
return this;
}
+ @CanIgnoreReturnValue
@Override
public Builder<E> add(E... elements) {
checkNotNull(elements); // for GWT
@@ -251,6 +262,7 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
return this;
}
+ @CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
if (elements instanceof Collection) {
@@ -261,12 +273,14 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
return this;
}
+ @CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterator<? extends E> elements) {
super.addAll(elements);
return this;
}
+ @CanIgnoreReturnValue
Builder<E> combine(Builder<E> builder) {
contents.addAll(builder.contents);
return this;