[#8619] Let Query subtypes extends RowCountQuery, which extends Publisher<Integer>
This commit is contained in:
parent
b1d992e33b
commit
62c42944d3
55
jOOQ/src/main/java/org/jooq/RowCountQuery.java
Normal file
55
jOOQ/src/main/java/org/jooq/RowCountQuery.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.concurrent.Flow;
|
||||
|
||||
/**
|
||||
* Any query that is not a {@link ResultQuery}, and thus possibly produces a row
|
||||
* count as a result, instead of a {@link Result}.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface RowCountQuery
|
||||
extends
|
||||
Query
|
||||
, org.reactivestreams.Publisher<Integer>
|
||||
, Flow.Publisher<Integer>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.concurrent.Flow;
|
||||
|
||||
import org.jooq.RowCountQuery;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractDelegatingRowCountQuery<Q extends RowCountQuery> extends AbstractDelegatingQuery<Q> implements RowCountQuery {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 6710523592699040547L;
|
||||
|
||||
AbstractDelegatingRowCountQuery(Q delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void subscribe(Flow.Subscriber<? super Integer> subscriber) {
|
||||
getDelegate().subscribe(subscriber);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void subscribe(org.reactivestreams.Subscriber<? super Integer> subscriber) {
|
||||
getDelegate().subscribe(subscriber);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
93
jOOQ/src/main/java/org/jooq/impl/AbstractRowCountQuery.java
Normal file
93
jOOQ/src/main/java/org/jooq/impl/AbstractRowCountQuery.java
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 org.jooq.Configuration;
|
||||
import org.jooq.RowCountQuery;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractRowCountQuery extends AbstractQuery implements RowCountQuery {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 516654856465466162L;
|
||||
|
||||
AbstractRowCountQuery(Configuration configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void subscribe(org.reactivestreams.Subscriber<? super Integer> subscriber) {
|
||||
subscriber.onSubscribe(new org.reactivestreams.Subscription() {
|
||||
Integer rows;
|
||||
|
||||
@Override
|
||||
public void request(long n) {
|
||||
try {
|
||||
if (rows == null)
|
||||
subscriber.onNext(rows = execute());
|
||||
}
|
||||
catch (Throwable t) {
|
||||
subscriber.onError(t);
|
||||
}
|
||||
|
||||
subscriber.onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void subscribe(java.util.concurrent.Flow.Subscriber<? super Integer> subscriber) {
|
||||
subscribe(new FlowToReactiveStreamsSubscriberBridge<Integer>(subscriber));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user