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

org.thirdteeth.immutables.pcollections.encodings.PCollectionsPStackEncodings 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.ConsPStack;
import org.pcollections.PStack;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

@Encoding
class PCollectionsPStackEncodings {
    @Encoding.Impl
    private PStack field = ConsPStack.empty();

    PCollectionsPStackEncodings() {

    }

    @Encoding.Builder
    static final class Builder
    {
        private PStack list = ConsPStack.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.Init
        @Encoding.Copy
        void set(final PStack elements) {
            this.list = elements;
        }

        @Encoding.Naming(value = "setJavaList*")
        @Encoding.Init
        void setJavaList(final List in_list) {
            this.list = ConsPStack.from(in_list);
        }

        @Encoding.Build
        PStack build() {
            return this.list;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy