All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.thirdteeth.immutables.pcollections.encodings.PCollectionsPVectorEncodings Maven / Gradle / Ivy

There is a newer version: 0.1.4
Show newest version
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;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy