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

com.speedment.common.tuple.TupleBuilder Maven / Gradle / Ivy

Go to download

A Speedment bundle that shades all dependencies into one jar. This is useful when deploying an application on a server.

There is a newer version: 3.1.18
Show newest version
/**
 *
 * Copyright (c) 2006-2017, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.common.tuple;

/**
 *
 * @author Per Minborg
 */
public class TupleBuilder {

    private Tuple current = Tuples.of();

    private TupleBuilder() {
    }

    public static Build0 builder() {
        return new TupleBuilder().new Build0();
    }

    public class Build0 extends BaseBuilder {

        public  Build1 add(T0 e0) {
            current = Tuples.of(e0);
            return new Build1<>();
        }

    }

    public class Build1 extends BaseBuilder> {

        public  Build2 add(T1 e1) {
            current = Tuples.of(current.get(0), e1);
            return new Build2<>();
        }

    }

    public class Build2 extends BaseBuilder> {

        public  Build3 add(T2 e2) {
            current = Tuples.of(current.get(0), current.get(1), e2);
            return new Build3<>();
        }

    }

    public class Build3 extends BaseBuilder> {

        public  Build4 add(T3 e3) {
            current = Tuples.of(current.get(0), current.get(1), current.get(2), e3);
            return new Build4<>();
        }
    }

    public class Build4 extends BaseBuilder> {

        public  Build5 add(T4 e4) {
            current = Tuples.of(current.get(0), current.get(1), current.get(2), current.get(3), e4);
            return new Build5<>();
        }

    }

    public class Build5 extends BaseBuilder> {

        public  Build6 add(T5 e5) {
            current = Tuples.of(
                    current.get(0),
                    current.get(1),
                    current.get(2),
                    current.get(3),
                    current.get(4),
                    e5);
            return new Build6<>();
        }

    }

    public class Build6 extends BaseBuilder> {

    }

    protected class BaseBuilder {

        @SuppressWarnings("unchecked")
        public T build() {
            return (T) current;
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy