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

com.querydsl.sql.UnionImpl Maven / Gradle / Ivy

There is a newer version: 6.10.1
Show newest version
/*
 * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
 *
 * 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.querydsl.sql;

import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.NonUniqueResultException;
import com.querydsl.core.Query;
import com.querydsl.core.QueryMetadata;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.ExpressionUtils;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.Visitor;
import java.util.List;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable;

/**
 * Default implementation of the Union interface
 *
 * @param  result type
 * @param  concrete query type
 * @author tiwe
 */
public class UnionImpl & Query> implements Union {

  private final Q query;

  public UnionImpl(Q query) {
    this.query = query;
  }

  @Override
  public List list() {
    return query.fetch();
  }

  @Override
  public List fetch() {
    return query.fetch();
  }

  @Override
  public T fetchFirst() {
    return query.fetchFirst();
  }

  @Override
  public T fetchOne() throws NonUniqueResultException {
    return query.fetchOne();
  }

  @Override
  public CloseableIterator iterate() {
    return query.iterate();
  }

  @Override
  public Stream stream() {
    return query.stream();
  }

  @Override
  public QueryResults fetchResults() {
    return query.fetchResults();
  }

  @Override
  public long fetchCount() {
    return query.fetchCount();
  }

  @Override
  public Union groupBy(Expression... o) {
    query.groupBy(o);
    return this;
  }

  @Override
  public Union having(Predicate... o) {
    query.having(o);
    return this;
  }

  @Override
  public Union orderBy(OrderSpecifier... o) {
    query.orderBy(o);
    return this;
  }

  @Override
  public Expression as(String alias) {
    return ExpressionUtils.as(this, alias);
  }

  @Override
  public Expression as(Path alias) {
    return ExpressionUtils.as(this, alias);
  }

  @Override
  public String toString() {
    return query.toString();
  }

  @Nullable
  @Override
  public  R accept(Visitor v, @Nullable C context) {
    return query.accept(v, context);
  }

  @Override
  public Class getType() {
    return query.getType();
  }

  @Override
  public QueryMetadata getMetadata() {
    return query.getMetadata();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy