org.thirdteeth.immutables.pcollections.encodings.PCollectionsPVectorEncodings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pcollections-encodings Show documentation
Show all versions of pcollections-encodings Show documentation
Immutables.org encodings for pcollections (Encodings)
package org.thirdteeth.immutables.pcollections.encodings;
import org.immutables.encode.Encoding;
import org.pcollections.PVector;
import org.pcollections.TreePVector;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@Encoding
class PCollectionsPVectorEncodings {
@Encoding.Impl
private PVector field = TreePVector.empty();
PCollectionsPVectorEncodings() {
}
@Encoding.Builder
static final class Builder
{
private PVector list = TreePVector.empty();
Builder() {
}
@Encoding.Naming(standard = Encoding.StandardNaming.ADD)
@Encoding.Init
void add(final T element) {
this.list = this.list.plus(element);
}
@SafeVarargs
@Encoding.Naming(standard = Encoding.StandardNaming.ADD)
@Encoding.Init
final void addVarArgs(final T... elements) {
this.list = this.list.plusAll(Arrays.asList(elements));
}
@Encoding.Naming(standard = Encoding.StandardNaming.ADD_ALL)
@Encoding.Init
void addAll(final Collection element) {
this.list = this.list.plusAll(element);
}
@Encoding.Naming(value = "setJavaList*")
@Encoding.Init
void setJavaList(final List in_list) {
this.list = TreePVector.from(in_list);
}
@Encoding.Init
@Encoding.Copy
void set(final PVector elements) {
this.list = elements;
}
@Encoding.Build
PVector build() {
return this.list;
}
}
}