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

com.speedment.runtime.join.JoinComponent Maven / Gradle / Ivy

/**
 *
 * Copyright (c) 2006-2018, 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.runtime.join;

import com.speedment.common.function.QuadFunction;
import com.speedment.common.function.TriFunction;
import com.speedment.common.injector.annotation.InjectKey;
import com.speedment.common.tuple.Tuple;
import com.speedment.runtime.config.identifier.TableIdentifier;
import com.speedment.runtime.field.trait.HasComparableOperators;
import com.speedment.runtime.join.trait.HasDefaultBuild;
import com.speedment.runtime.join.trait.HasJoins;
import com.speedment.runtime.join.trait.HasOnPredicates;
import com.speedment.runtime.join.trait.HasWhere;
import java.util.function.BiFunction;
import com.speedment.common.function.Function5;
import com.speedment.common.function.Function6;
import com.speedment.common.tuple.TuplesOfNullables;
import com.speedment.common.tuple.nullable.Tuple2OfNullables;
import com.speedment.common.tuple.nullable.Tuple3OfNullables;
import com.speedment.common.tuple.nullable.Tuple4OfNullables;
import com.speedment.common.tuple.nullable.Tuple5OfNullables;
import com.speedment.common.tuple.nullable.Tuple6OfNullables;

/**
 * a JoinComponent can be used to create builders for creating Join objects.
 * Join objects, in turn, can be used to stream over joined tables.
 * 

* It is unspecified if objects returned by builder-type of objects return * itself or a new builder. Users should make no assumption of either case and * use a fluent API style of programming. *

* All methods that takes objects will throw a {@code NullPointerException } if * provided with one or several {@code null } values. *

* Intermediate builder methods are not thread safe. *

* Currently, this component can build joins of grade 2, 3, 4, 5 or 6 * * @author Per Minborg */ @InjectKey(JoinComponent.class) public interface JoinComponent { /** * The maximum number of tables than can be joined. */ int MAX_DEGREE = 6; /** * Adds a provided {@code firstManager} to the collection of joined * managers. Rows are joined from the provided {@code firstManager} * depending on how subsequent managers are added to the builder. * * @param type of entities for the first manager * @param firstManager to use * @return a builder where the provided {@code firstManager} is added * * @throws NullPointerException if the provided {@code firstManager} is * {@code null} */ JoinBuilder1 from(TableIdentifier firstManager); interface JoinBuilder1 extends HasJoins, JoinBuilder1.JoinBuilder2>, HasWhere> { @Override AfterJoin innerJoinOn(HasComparableOperators joinedField); @Override AfterJoin leftJoinOn(HasComparableOperators joinedField); @Override AfterJoin rightJoinOn(HasComparableOperators joinedField); // @Override // AfterJoin fullOuterJoinOn(HasComparableOperators joinedField); @Override JoinBuilder2 crossJoin(TableIdentifier joinedTable); interface AfterJoin extends HasOnPredicates> { } interface JoinBuilder2 extends HasJoins, JoinBuilder2.JoinBuilder3>, HasWhere>, HasDefaultBuild> { @Override AfterJoin innerJoinOn(HasComparableOperators joinedField); @Override AfterJoin leftJoinOn(HasComparableOperators joinedField); @Override AfterJoin rightJoinOn(HasComparableOperators joinedField); // @Override // AfterJoin fullOuterJoinOn(HasComparableOperators joinedField); @Override JoinBuilder3 crossJoin(TableIdentifier joinedTable); @Override default Join> build() { return build(TuplesOfNullables::ofNullables); } /** * Creates and returns a new Join object where elements in the Join * object's stream method is created using the provided * {@code constructor}. * * @param the type of element in the Join object's stream * method. * @param constructor to use to create stream elements. * @return a new Join object where elements in the Join object's * stream method is of a default {@link Tuple} type * * @throws NullPointerException if the provided {@code constructor } * is {@code null} */ Join build(BiFunction constructor); interface AfterJoin extends HasOnPredicates> { } interface JoinBuilder3 extends HasJoins, JoinBuilder3.JoinBuilder4>, HasWhere>, HasDefaultBuild> { @Override AfterJoin innerJoinOn(HasComparableOperators joinedField); @Override AfterJoin leftJoinOn(HasComparableOperators joinedField); @Override AfterJoin rightJoinOn(HasComparableOperators joinedField); // @Override // AfterJoin fullOuterJoinOn(HasComparableOperators joinedField); @Override JoinBuilder4 crossJoin(TableIdentifier joinedTable); @Override default Join> build() { return build(TuplesOfNullables::ofNullables); } /** * Creates and returns a new Join object where elements in the * Join object's stream method is created using the provided * {@code constructor}. * * @param the type of element in the Join object's stream * method. * @param constructor to use to create stream elements. * @return a new Join object where elements in the Join object's * stream method is of a default {@link Tuple} type * * @throws NullPointerException if the provided {@code constructor * } is {@code null} */ Join build(TriFunction constructor); interface AfterJoin extends HasOnPredicates> { } interface JoinBuilder4 extends HasJoins, JoinBuilder4.JoinBuilder5>, HasWhere>, HasDefaultBuild> { @Override AfterJoin innerJoinOn(HasComparableOperators joinedField); @Override AfterJoin leftJoinOn(HasComparableOperators joinedField); @Override AfterJoin rightJoinOn(HasComparableOperators joinedField); // @Override // AfterJoin fullOuterJoinOn(HasComparableOperators joinedField); @Override JoinBuilder5 crossJoin(TableIdentifier joinedTable); @Override default Join> build() { return build(TuplesOfNullables::ofNullables); } /** * Creates and returns a new Join object where elements in * the Join object's stream method is created using the * provided {@code constructor}. * * @param the type of element in the Join object's * stream method. * @param constructor to use to create stream elements. * @return a new Join object where elements in the Join * object's stream method is of a default {@link Tuple} type * * @throws NullPointerException if the provided {@code constructor * } is {@code null} * @throws IllegalStateException if fields that are added * via the {@code on() * } method refers to tables that are not a part of the * join. */ Join build(QuadFunction constructor); interface AfterJoin extends HasOnPredicates> { } interface JoinBuilder5 extends HasJoins, JoinBuilder5.JoinBuilder6>, HasWhere>, HasDefaultBuild> { @Override AfterJoin innerJoinOn(HasComparableOperators joinedField); @Override AfterJoin leftJoinOn(HasComparableOperators joinedField); @Override AfterJoin rightJoinOn(HasComparableOperators joinedField); // @Override // AfterJoin fullOuterJoinOn(HasComparableOperators joinedField); @Override JoinBuilder6 crossJoin(TableIdentifier joinedTable); @Override default Join> build() { return build(TuplesOfNullables::ofNullables); } /** * Creates and returns a new Join object where elements * in the Join object's stream method is created using * the provided {@code constructor}. * * @param the type of element in the Join object's * stream method. * @param constructor to use to create stream elements. * @return a new Join object where elements in the Join * object's stream method is of a default {@link Tuple} * type * * @throws NullPointerException if the provided {@code constructor * } is {@code null} * @throws IllegalStateException if fields that are * added via the {@code on() * } method refers to tables that are not a part of the * join. */ Join build(Function5 constructor); interface AfterJoin extends HasOnPredicates> { } interface JoinBuilder6 extends HasWhere>, HasDefaultBuild> { @Override default Join> build() { return build(TuplesOfNullables::ofNullables); } /** * Creates and returns a new Join object where * elements in the Join object's stream method is * created using the provided {@code constructor}. * * @param the type of element in the Join * object's stream method. * @param constructor to use to create stream * elements. * @return a new Join object where elements in the * Join object's stream method is of a default * {@link Tuple} type * * @throws NullPointerException if the provided {@code constructor * } is {@code null} * @throws IllegalStateException if fields that are * added via the {@code on() * } method refers to tables that are not a part of * the join. */ Join build(Function6 constructor); } } } } } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy