package org.eclipse.collections.api.factory.bag;
import java.util.stream.Stream;
import org.eclipse.collections.api.bag.ImmutableBag;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.factory.Bags;
import org.eclipse.collections.api.tuple.primitive.ObjectIntPair;
public interface ImmutableBagFactory
{
<T> ImmutableBag<T> empty();
<T> ImmutableBag<T> of();
<T> ImmutableBag<T> with();
<T> ImmutableBag<T> of(T element);
<T> ImmutableBag<T> with(T element);
<T> ImmutableBag<T> of(T... elements);
default <T> ImmutableBag<T> ofOccurrences(T element, int occurrence)
{
return this.withOccurrences(element, occurrence);
}
default <T> ImmutableBag<T> ofOccurrences(T element1, int occurrence1, T element2, int occurrence2)
{
return this.withOccurrences(element1, occurrence1, element2, occurrence2);
}
default <T> ImmutableBag<T> ofOccurrences(T element1, int occurrence1, T element2, int occurrence2, T element3, int occurrence3)
{
return this.withOccurrences(element1, occurrence1, element2, occurrence2, element3, occurrence3);
}
default <T> ImmutableBag<T> ofOccurrences(T element1, int occurrence1, T element2, int occurrence2, T element3, int occurrence3, T element4, int occurrence4)
{
return this.withOccurrences(element1, occurrence1, element2, occurrence2, element3, occurrence3, element4, occurrence4);
}
default <T> ImmutableBag<T> ofOccurrences(ObjectIntPair<T>... elementsWithOccurrences)
{
return this.withOccurrences(elementsWithOccurrences);
}
<T> ImmutableBag<T> with(T... elements);
default <T> ImmutableBag<T> withOccurrences(T element, int occurrence)
{
MutableBag<T> mutableBag = Bags.mutable.withOccurrences(element, occurrence);
return mutableBag.toImmutable();
}
default <T> ImmutableBag<T> withOccurrences(T element1, int occurrence1, T element2, int occurrence2)
{
MutableBag<T> mutableBag = Bags.mutable.withOccurrences(
element1, occurrence1,
element2, occurrence2);
return mutableBag.toImmutable();
}
default <T> ImmutableBag<T> withOccurrences(T element1, int occurrence1, T element2, int occurrence2, T element3, int occurrence3)
{
MutableBag<T> mutableBag = Bags.mutable.withOccurrences(
element1, occurrence1,
element2, occurrence2,
element3, occurrence3);
return mutableBag.toImmutable();
}
default <T> ImmutableBag<T> withOccurrences(T element1, int occurrence1, T element2, int occurrence2, T element3, int occurrence3, T element4, int occurrence4)
{
MutableBag<T> mutableBag = Bags.mutable.withOccurrences(
element1, occurrence1,
element2, occurrence2,
element3, occurrence3,
element4, occurrence4);
return mutableBag.toImmutable();
}
default <T> ImmutableBag<T> withOccurrences(ObjectIntPair<T>... elementsWithOccurrences)
{
return Bags.mutable.withOccurrences(elementsWithOccurrences).toImmutable();
}
<T> ImmutableBag<T> ofAll(Iterable<? extends T> items);
<T> ImmutableBag<T> withAll(Iterable<? extends T> items);
default <T> ImmutableBag<T> fromStream(Stream<? extends T> stream)
{
return Bags.mutable.<T>fromStream(stream).toImmutable();
}
}