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

com.blazebit.persistence.criteria.BlazeFrom Maven / Gradle / Ivy

There is a newer version: 1.6.12
Show newest version
/*
 * Copyright 2014 - 2021 Blazebit.
 *
 * 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.blazebit.persistence.criteria;

import javax.persistence.criteria.From;
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.SingularAttribute;
import java.util.Set;

/**
 * An extended version of {@link From}.
 *
 * @param  The source type
 * @param  The target type
 * @author Christian Beikov
 * @since 1.2.0
 */
public interface BlazeFrom extends From, BlazeFetchParent, BlazePath {

    /**
     * Returns all joins including fetches since fetches are just joins with the fetch flag set to true.
     *
     * @return All joins
     */
    Set> getBlazeJoins();
    
    /* Aliased joins */

    /**
     * Like {@link From#join(SingularAttribute)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param attribute The target of the join
     * @param alias     The alias for the {@link BlazeJoin}
     * @param        The join target type
     * @return The resulting join
     */
     BlazeJoin join(SingularAttribute attribute, String alias);

    /**
     * Like {@link From#join(SingularAttribute, JoinType)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param attribute The target of the join
     * @param alias     The alias for the {@link BlazeJoin}
     * @param joinType  The join type
     * @param        The join target type
     * @return The resulting join
     */
     BlazeJoin join(SingularAttribute attribute, String alias, JoinType joinType);

    /**
     * Like {@link From#join(CollectionAttribute)} but allows to set the alias of the {@link BlazeCollectionJoin}.
     *
     * @param collection The target of the join
     * @param alias      The alias for the {@link BlazeCollectionJoin}
     * @param         The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin join(CollectionAttribute collection, String alias);

    /**
     * Like {@link From#join(SetAttribute)} but allows to set the alias of the {@link BlazeSetJoin}.
     *
     * @param set   The target of the join
     * @param alias The alias for the {@link BlazeSetJoin}
     * @param    The join target type
     * @return The resulting join
     */
     BlazeSetJoin join(SetAttribute set, String alias);

    /**
     * Like {@link From#join(ListAttribute)} but allows to set the alias of the {@link BlazeListJoin}.
     *
     * @param list  The target of the join
     * @param alias The alias for the {@link BlazeListJoin}
     * @param    The join target type
     * @return The resulting join
     */
     BlazeListJoin join(ListAttribute list, String alias);

    /**
     * Like {@link From#join(MapAttribute)} but allows to set the alias of the {@link BlazeMapJoin}.
     *
     * @param map   The target of the join
     * @param alias The alias for the {@link BlazeMapJoin}
     * @param    The join target key type
     * @param    The join target value type
     * @return The resulting join
     */
     BlazeMapJoin join(MapAttribute map, String alias);

    /**
     * Like {@link From#join(CollectionAttribute, JoinType)} but allows to set the alias of the {@link BlazeCollectionJoin}.
     *
     * @param collection The target of the join
     * @param alias      The alias for the {@link BlazeCollectionJoin}
     * @param joinType   The join type
     * @param         The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin join(CollectionAttribute collection, String alias, JoinType joinType);

    /**
     * Like {@link From#join(SetAttribute, JoinType)} but allows to set the alias of the {@link BlazeSetJoin}.
     *
     * @param set      The target of the join
     * @param alias    The alias for the {@link BlazeSetJoin}
     * @param joinType The join type
     * @param       The join target type
     * @return The resulting join
     */
     BlazeSetJoin join(SetAttribute set, String alias, JoinType joinType);

    /**
     * Like {@link From#join(ListAttribute, JoinType)} but allows to set the alias of the {@link BlazeListJoin}.
     *
     * @param list     The target of the join
     * @param alias    The alias for the {@link BlazeListJoin}
     * @param joinType The join type
     * @param       The join target type
     * @return The resulting join
     */
     BlazeListJoin join(ListAttribute list, String alias, JoinType joinType);

    /**
     * Like {@link From#join(MapAttribute, JoinType)} but allows to set the alias of the {@link BlazeMapJoin}.
     *
     * @param map      The target of the join
     * @param alias    The alias for the {@link BlazeMapJoin}
     * @param joinType The join type
     * @param       The join target key type
     * @param       The join target value type
     * @return The resulting join
     */
     BlazeMapJoin join(MapAttribute map, String alias, JoinType joinType);

    /**
     * Like {@link From#join(String)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeJoin}
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeJoin join(String attributeName, String alias);

    /**
     * Like {@link BlazeFrom#join(EntityType)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param entityType    The entity type to join
     * @param alias         The alias for the {@link BlazeJoin}
     * @param            The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(EntityType entityType, String alias);

    /**
     * Gets the entity type by the given entity type class and delegates to {@link BlazeFrom#join(EntityType, String)}.
     *
     * @param entityTypeClass   The entity type class to join
     * @param alias             The alias for the {@link BlazeJoin}
     * @param                The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(Class entityTypeClass, String alias);

    /**
     * Like {@link From#joinCollection(String)} but allows to set the alias of the {@link BlazeCollectionJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeCollectionJoin}
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin joinCollection(String attributeName, String alias);

    /**
     * Like {@link From#joinSet(String)} but allows to set the alias of the {@link BlazeSetJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeSetJoin}
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeSetJoin joinSet(String attributeName, String alias);

    /**
     * Like {@link From#joinList(String)} but allows to set the alias of the {@link BlazeListJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeListJoin}
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeListJoin joinList(String attributeName, String alias);

    /**
     * Like {@link From#joinMap(String)} but allows to set the alias of the {@link BlazeMapJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeMapJoin}
     * @param            The join source type
     * @param            The join target key type
     * @param            The join target value type
     * @return The resulting join
     */
     BlazeMapJoin joinMap(String attributeName, String alias);

    /**
     * Like {@link From#join(String, JoinType)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeJoin}
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeJoin join(String attributeName, String alias, JoinType joinType);

    /**
     * Like {@link BlazeFrom#join(EntityType, JoinType)} but allows to set the alias of the {@link BlazeJoin}.
     *
     * @param entityType    The entity type to join
     * @param alias         The alias for the {@link BlazeJoin}
     * @param joinType      The join type
     * @param            The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(EntityType entityType, String alias, JoinType joinType);

    /**
     * Gets the entity type by the given entity type class and delegates to {@link BlazeFrom#join(EntityType, String, JoinType)}.
     *
     * @param entityTypeClass   The entity type class to join
     * @param alias             The alias for the {@link BlazeJoin}
     * @param joinType          The join type
     * @param                The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(Class entityTypeClass, String alias, JoinType joinType);

    /**
     * Like {@link From#joinCollection(String, JoinType)} but allows to set the alias of the {@link BlazeCollectionJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeCollectionJoin}
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin joinCollection(String attributeName, String alias, JoinType joinType);

    /**
     * Like {@link From#joinSet(String, JoinType)} but allows to set the alias of the {@link BlazeSetJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeSetJoin}
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeSetJoin joinSet(String attributeName, String alias, JoinType joinType);

    /**
     * Like {@link From#joinList(String, JoinType)} but allows to set the alias of the {@link BlazeListJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeListJoin}
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeListJoin joinList(String attributeName, String alias, JoinType joinType);

    /**
     * Like {@link From#joinMap(String, JoinType)} but allows to set the alias of the {@link BlazeMapJoin}.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param alias         The alias for the {@link BlazeMapJoin}
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target key type
     * @param            The join target value type
     * @return The resulting join
     */
     BlazeMapJoin joinMap(String attributeName, String alias, JoinType joinType);

    /* Covariant overrides */

    /**
     * Like {@link From#getCorrelationParent} but returns the subtype {@link BlazeFrom} instead.
     *
     * @return The parent of the correlated From object
     */
    BlazeFrom getCorrelationParent();

    /**
     * Like {@link From#join(SingularAttribute)} but returns the subtype {@link BlazeJoin} instead.
     *
     * @param attribute The target of the join
     * @param        The join target type
     * @return The resulting join
     */
     BlazeJoin join(SingularAttribute attribute);

    /**
     * Like {@link From#join(SingularAttribute, JoinType)} but returns the subtype {@link BlazeJoin} instead.
     *
     * @param attribute The target of the join
     * @param joinType  The join type
     * @param        The join target type
     * @return The resulting join
     */
     BlazeJoin join(SingularAttribute attribute, JoinType joinType);

    /**
     * Like {@link From#join(CollectionAttribute)} but returns the subtype {@link BlazeCollectionJoin} instead.
     *
     * @param collection The target of the join
     * @param         The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin join(CollectionAttribute collection);

    /**
     * Like {@link From#join(SetAttribute)} but returns the subtype {@link BlazeSetJoin} instead.
     *
     * @param set The target of the join
     * @param  The join target type
     * @return The resulting join
     */
     BlazeSetJoin join(SetAttribute set);

    /**
     * Like {@link From#join(ListAttribute)} but returns the subtype {@link BlazeListJoin} instead.
     *
     * @param list The target of the join
     * @param   The join target type
     * @return The resulting join
     */
     BlazeListJoin join(ListAttribute list);

    /**
     * Like {@link From#join(MapAttribute)} but returns the subtype {@link BlazeMapJoin} instead.
     *
     * @param map The target of the join
     * @param  The join target key type
     * @param  The join target value type
     * @return The resulting join
     */
     BlazeMapJoin join(MapAttribute map);

    /**
     * Like {@link From#join(CollectionAttribute, JoinType)} but returns the subtype {@link BlazeCollectionJoin} instead.
     *
     * @param collection The target of the join
     * @param joinType   The join type
     * @param         The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin join(CollectionAttribute collection, JoinType joinType);

    /**
     * Like {@link From#join(SetAttribute, JoinType)} but returns the subtype {@link BlazeSetJoin} instead.
     *
     * @param set      The target of the join
     * @param joinType The join type
     * @param       The join target type
     * @return The resulting join
     */
     BlazeSetJoin join(SetAttribute set, JoinType joinType);

    /**
     * Like {@link From#join(ListAttribute, JoinType)} but returns the subtype {@link BlazeListJoin} instead.
     *
     * @param list     The target of the join
     * @param joinType The join type
     * @param       The join target type
     * @return The resulting join
     */
     BlazeListJoin join(ListAttribute list, JoinType joinType);

    /**
     * Like {@link From#join(MapAttribute, JoinType)} but returns the subtype {@link BlazeMapJoin} instead.
     *
     * @param map      The target of the join
     * @param joinType The join type
     * @param       The join target key type
     * @param       The join target value type
     * @return The resulting join
     */
     BlazeMapJoin join(MapAttribute map, JoinType joinType);

    /**
     * Like {@link From#join(String)} but returns the subtype {@link BlazeJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeJoin join(String attributeName);

    /**
     * Creates an inner join to the specified entity type.
     *
     * @param entityType    The entity type to join
     * @param            The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(EntityType entityType);

    /**
     * Gets the entity type by the given entity type class and delegates to {@link BlazeFrom#join(EntityType)}.
     *
     * @param entityTypeClass   The entity type class to join
     * @param                The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(Class entityTypeClass);

    /**
     * Like {@link From#joinCollection(String)} but returns the subtype {@link BlazeCollectionJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin joinCollection(String attributeName);

    /**
     * Like {@link From#joinSet(String)} but returns the subtype {@link BlazeSetJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeSetJoin joinSet(String attributeName);

    /**
     * Like {@link From#joinList(String)} but returns the subtype {@link BlazeListJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeListJoin joinList(String attributeName);

    /**
     * Like {@link From#joinMap(String)} but returns the subtype {@link BlazeMapJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param            The join source type
     * @param            The join target key type
     * @param            The join target value type
     * @return The resulting join
     */
     BlazeMapJoin joinMap(String attributeName);

    /**
     * Like {@link From#join(String, JoinType)} but returns the subtype {@link BlazeJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeJoin join(String attributeName, JoinType joinType);

    /**
     * Creates a join of the specified join type to the specified entity type.
     *
     * @param entityType    The entity type to join
     * @param joinType      The join type
     * @param            The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(EntityType entityType, JoinType joinType);

    /**
     * Gets the entity type by the given entity type class and delegates to {@link BlazeFrom#join(EntityType, JoinType)}.
     *
     * @param entityTypeClass   The entity type class to join
     * @param joinType          The join type
     * @param                The joined entity type
     * @return The resulting join
     * @since 1.3.0
     */
     BlazeJoin join(Class entityTypeClass, JoinType joinType);

    /**
     * Like {@link From#joinCollection(String, JoinType)} but returns the subtype {@link BlazeCollectionJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeCollectionJoin joinCollection(String attributeName, JoinType joinType);

    /**
     * Like {@link From#joinSet(String, JoinType)} but returns the subtype {@link BlazeSetJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeSetJoin joinSet(String attributeName, JoinType joinType);

    /**
     * Like {@link From#joinList(String, JoinType)} but returns the subtype {@link BlazeListJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target type
     * @return The resulting join
     */
     BlazeListJoin joinList(String attributeName, JoinType joinType);

    /**
     * Like {@link From#joinMap(String, JoinType)} but returns the subtype {@link BlazeMapJoin} instead.
     *
     * @param attributeName The name of the attribute for the target of the join
     * @param joinType      The join type
     * @param            The join source type
     * @param            The join target key type
     * @param            The join target value type
     * @return The resulting join
     */
     BlazeMapJoin joinMap(String attributeName, JoinType joinType);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy