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

com.impetus.kundera.persistence.DefaultCompoundSelection Maven / Gradle / Ivy

There is a newer version: 3.13
Show newest version
/*******************************************************************************
 * * Copyright 2014 Impetus Infotech.
 *  *
 *  * 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.impetus.kundera.persistence;

import java.util.List;

import javax.persistence.criteria.CompoundSelection;
import javax.persistence.criteria.Selection;

/**
 * Implementation class for multi column selection {@link CompoundSelection}
 * @author vivek.mishra
 *
 */
public class DefaultCompoundSelection implements CompoundSelection
{

    private List> selections;
    private Class resultType;
    private String alias;

    DefaultCompoundSelection(List> selections, Class resultClazz)
    {
        this.selections = selections;
        this.resultType = resultClazz;
        if(isCompoundSelection())
        {
            this.alias = selections.get(0).getAlias();
        }
    }
    
    @Override
    public Selection alias(String paramString)
    {
        this.alias = paramString;
        return this;
    }

    @Override
    public boolean isCompoundSelection()
    {
        return this.selections != null && !this.selections.isEmpty() && this.selections.size() > 1;
    }

    @Override
    public List> getCompoundSelectionItems()
    {
        return this.selections;
    }

    @Override
    public Class getJavaType()
    {
        return this.resultType;
    }

    @Override
    public String getAlias()
    {
        return this.alias;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy