[#5056] Add org.jooq.Queries, a wrapper for Query[]

This commit is contained in:
lukaseder 2016-02-04 23:08:05 +01:00
parent b7d0776c66
commit 7802b8be41
3 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,54 @@
/**
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* 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.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
/**
* A wrapper for a collection of queries.
*
* @author Lukas Eder
*/
public interface Queries {
/**
* The wrapped collection of queries.
*/
Query[] queries();
}

View File

@ -189,6 +189,7 @@ import org.jooq.OrderedAggregateFunctionOfDeferredType;
import org.jooq.Param;
import org.jooq.PlainSQL;
import org.jooq.QuantifiedSelect;
import org.jooq.Queries;
import org.jooq.Query;
import org.jooq.QueryPart;
import org.jooq.Record;
@ -6571,6 +6572,26 @@ public class DSL {
return new QualifiedField<T>(name, type);
}
// -------------------------------------------------------------------------
// XXX: Queries
// -------------------------------------------------------------------------
/**
* Wrap a collection of queries.
*/
@Support
public static Queries queries(Query... queries) {
return queries(Arrays.asList(queries));
}
/**
* Wrap a collection of queries.
*/
@Support
public static Queries queries(Collection<? extends Query> queries) {
return new QueriesImpl(queries);
}

View File

@ -0,0 +1,63 @@
/**
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* 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.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import java.util.Collection;
import org.jooq.Queries;
import org.jooq.Query;
/**
* @author Lukas Eder
*/
class QueriesImpl implements Queries {
private final Collection<? extends Query> queries;
QueriesImpl(Collection<? extends Query> queries) {
this.queries = queries;
}
@Override
public final Query[] queries() {
return queries.toArray(new Query[0]);
}
}