DATACASS-483 - Add @FunctionalInterface to functional interfaces.

This commit is contained in:
Mark Paluch
2017-07-31 14:29:44 +02:00
parent ad8eb9a989
commit de343e2d6c
28 changed files with 53 additions and 72 deletions

View File

@@ -28,6 +28,7 @@ package org.springframework.data.cassandra;
* @see org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessionFactory
* @see org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate
*/
@FunctionalInterface
public interface ReactiveSessionFactory {
/**

View File

@@ -32,6 +32,7 @@ import com.datastax.driver.core.Session;
* @author Mark Paluch
* @since 2.0
*/
@FunctionalInterface
public interface SessionFactory {
/**

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.cassandra.config;
import com.datastax.driver.core.Cluster;
@@ -22,9 +21,11 @@ import com.datastax.driver.core.Cluster;
* Configuration callback class to allow a user to apply additional configuration logic to the {@link Cluster.Builder}.
*
* @author John Blum
* @author Mark Paluch
* @since 1.5
* @see com.datastax.driver.core.Cluster
* @since 1.0.0
*/
@FunctionalInterface
public interface ClusterBuilderConfigurer {
/**
@@ -35,5 +36,4 @@ public interface ClusterBuilderConfigurer {
* @see com.datastax.driver.core.Cluster.Builder
*/
Cluster.Builder configure(Cluster.Builder clusterBuilder);
}

View File

@@ -37,6 +37,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author Mark Paluch
* @since 2.0
*/
@FunctionalInterface
public interface AsyncPreparedStatementCreator {
/**
@@ -45,10 +46,9 @@ public interface AsyncPreparedStatementCreator {
* re-preparing on the entire cluster.
*
* @param session Session to use to create statement, must not be {@literal null}.
* @return a prepared statement
* @return a prepared statement.
* @throws DriverException there is no need to catch DriverException that may be thrown in the implementation of this
* method. The {@link CqlTemplate} class will handle them.
* method. The {@link AsyncCqlTemplate} class will handle them.
*/
ListenableFuture<PreparedStatement> createPreparedStatement(Session session) throws DriverException;
}

View File

@@ -33,7 +33,9 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author Mark Paluch
* @see AsyncCqlTemplate#execute(AsyncSessionCallback)
* @see AsyncCqlTemplate#query
* @see AsyncCqlTemplate#execute(String)
*/
@FunctionalInterface
public interface AsyncSessionCallback<T> {
/**
@@ -53,5 +55,4 @@ public interface AsyncSessionCallback<T> {
* @see AsyncCqlTemplate#queryForResultSet(String)
*/
ListenableFuture<T> doInSession(Session session) throws DriverException, DataAccessException;
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2013-2017 the original author or authors.
*
* 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 org.springframework.data.cassandra.core.cql;
import com.datastax.driver.core.ResultSetFuture;
/**
* Interface used to give an implementation access to a {@link ResultSetFuture} after the query has completed.
*
* @author David Webb
* @author Matthew T. Adams
*/
public interface AsynchronousQueryListener {
/**
* Called upon query completion.
*
* @param rsf The {@link ResultSetFuture}. Called when the query operation is completed.
*/
void onQueryComplete(ResultSetFuture rsf);
}

View File

@@ -39,10 +39,10 @@ public interface CqlExceptionTranslator extends PersistenceExceptionTranslator {
* other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and
* subsequent cast) is considered reliable when expecting Cassandra-based access to have happened.
*
* @param task readable text describing the task being attempted
* @param cql CQL query or update that caused the problem (may be {@code null})
* @param ex the offending {@link DriverException}
* @return the DataAccessException, wrapping the {@code DriverException}
* @param task readable text describing the task being attempted.
* @param cql CQL query or update that caused the problem (may be {@code null}).
* @param ex the offending {@link DriverException}.
* @return the DataAccessException, wrapping the {@link DriverException}.
* @see org.springframework.dao.DataAccessException#getRootCause()
*/
default DataAccessException translate(String task, String cql, DriverException ex) {

View File

@@ -27,6 +27,7 @@ package org.springframework.data.cassandra.core.cql;
* @see ReactivePreparedStatementCreator
* @see ReactiveStatementCallback
*/
@FunctionalInterface
public interface CqlProvider {
/**

View File

@@ -30,6 +30,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author Mark Paluch
* @see CqlTemplate
*/
@FunctionalInterface
public interface HostMapper<T> {
/**
@@ -42,5 +43,4 @@ public interface HostMapper<T> {
* catch {@link DriverException}).
*/
Collection<T> mapHosts(Iterable<Host> hosts) throws DriverException;
}

View File

@@ -38,6 +38,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @see AsyncCqlTemplate#query(AsyncPreparedStatementCreator, PreparedStatementBinder, ResultSetExtractor)
* @see ReactiveCqlTemplate#query(String, PreparedStatementBinder, ReactiveResultSetExtractor)
*/
@FunctionalInterface
public interface PreparedStatementBinder {
/**

View File

@@ -35,10 +35,11 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author David Webb
* @author Mark Paluch
* @see AsyncCqlTemplate#execute(String, PreparedStatementCallback)
* @see AsyncCqlTemplate#execute(PreparedStatementCreator, PreparedStatementCallback)
* @see AsyncCqlTemplate#execute(AsyncPreparedStatementCreator, PreparedStatementCallback)
* @see CqlTemplate#execute(String, PreparedStatementCallback)
* @see CqlTemplate#execute(PreparedStatementCreator, PreparedStatementCallback)
*/
@FunctionalInterface
public interface PreparedStatementCallback<T> {
/**
@@ -53,8 +54,8 @@ public interface PreparedStatementCallback<T> {
*
* @param session active Cassandra session, must not be {@literal null}.
* @param preparedStatement the {@link PreparedStatement}, must not be {@literal null}.
* @return a result object publisher.
* @throws DriverException if thrown by a session method, to be auto-converted to a DataAccessException.
* @return a result object.
* @throws DriverException if thrown by a session method, to be auto-converted to a {@link DataAccessException}.
* @throws DataAccessException in case of custom exceptions.
* @see AsyncCqlTemplate#queryForObject(String, Class, Object...)
* @see AsyncCqlTemplate#queryForList(String, Class, Object...)

View File

@@ -32,13 +32,14 @@ import com.datastax.driver.core.exceptions.DriverException;
* @see CqlTemplate#execute(PreparedStatementCreator, PreparedStatementCallback)
* @see CqlTemplate#query(PreparedStatementCreator, RowCallbackHandler)
*/
@FunctionalInterface
public interface PreparedStatementCreator {
/**
* Create a statement in this session. Allows implementations to use {@link PreparedStatement}.
*
* @param session {@link Session} to use to create statement
* @return a prepared statement
* @param session {@link Session} to use to create statement.
* @return a prepared statement.
* @throws DriverException there is no need to catch {@link DriverException} that may be thrown in the implementation
* of this method. The {@link CqlTemplate} class will handle them.
*/

View File

@@ -38,6 +38,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @see ReactiveCqlTemplate#execute(ReactivePreparedStatementCreator, ReactivePreparedStatementCallback)
* @see ReactiveCqlTemplate#execute(String, ReactivePreparedStatementCallback)
*/
@FunctionalInterface
public interface ReactivePreparedStatementCallback<T> {
/**
@@ -53,7 +54,7 @@ public interface ReactivePreparedStatementCallback<T> {
* @param session active Cassandra session, must not be {@literal null}.
* @param ps the {@link PreparedStatement}, must not be {@literal null}.
* @return a result object publisher.
* @throws DriverException if thrown by a session method, to be auto-converted to a DataAccessException.
* @throws DriverException if thrown by a session method, to be auto-converted to a {@link DataAccessException}.
* @throws DataAccessException in case of custom exceptions.
* @see ReactiveCqlTemplate#queryForObject(String, Class, Object...)
* @see ReactiveCqlTemplate#queryForFlux(String, Object...)

View File

@@ -37,6 +37,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author Mark Paluch
* @since 2.0
*/
@FunctionalInterface
public interface ReactivePreparedStatementCreator {
/**
@@ -45,7 +46,7 @@ public interface ReactivePreparedStatementCreator {
* overhead of re-preparing on the entire cluster.
*
* @param session Session to use to create statement, must not be {@literal null}.
* @return a prepared statement
* @return a prepared statement.
* @throws DriverException there is no need to catch DriverException that may be thrown in the implementation of this
* method. The {@link ReactiveCqlTemplate} class will handle them.
*/

View File

@@ -33,13 +33,13 @@ import com.datastax.driver.core.exceptions.DriverException;
* Note: {@link ReactiveResultSetExtractor} object is typically stateless and thus reusable, as long as it doesn't
* access stateful resources or keep result state within the object.
*
* @param <T>
* @author Mark Paluch
* @since 2.0
* @see ReactiveCqlTemplate
* @see RowCallbackHandler
* @see RowMapper
*/
@FunctionalInterface
public interface ReactiveResultSetExtractor<T> {
/**

View File

@@ -48,9 +48,10 @@ public interface ReactiveSessionCallback<T> {
* application exception: it gets propagated to the caller of the template.
*
* @param session active Cassandra session.
* @return a result object publisher
* @throws DriverException if thrown by a session method, to be auto-converted to a DataAccessException
* @throws DataAccessException in case of custom exceptions
* @return a result object publisher.
* @throws DriverException if thrown by a session method, to be auto-converted to a {@link DataAccessException}.
* @throws DataAccessException in case of custom exceptions.
* @see ReactiveCqlTemplate#execute(ReactivePreparedStatementCreator, ReactivePreparedStatementCallback)
*/
Publisher<T> doInSession(ReactiveSession session) throws DriverException, DataAccessException;
}

View File

@@ -45,12 +45,12 @@ public interface ReactiveStatementCallback<T> {
* application exception, it gets propagated to the caller of the template.
*
* @param session active Cassandra session.
* @param stmt CQL Statement
* @return a result object publisher
* @throws DriverException if thrown by a session method, to be auto-converted to a DataAccessException
* @param stmt CQL Statement.
* @return a result object publisher.
* @throws DriverException if thrown by a session method, to be auto-converted to a {@link DataAccessException}
* @throws DataAccessException in case of custom exceptions
* @see ReactiveCqlTemplate#queryForObject(String, Class)
* @see ReactiveCqlTemplate#queryForResultSet(String)
* @see ReactiveCqlTemplate#query(String, ReactiveResultSetExtractor)
* @see ReactiveCqlTemplate#query(Statement, ReactiveResultSetExtractor)
*/
Publisher<T> doInStatement(ReactiveSession session, Statement stmt) throws DriverException;
Publisher<T> doInStatement(ReactiveSession session, Statement stmt) throws DriverException, DataAccessException;
}

View File

@@ -34,24 +34,23 @@ import com.datastax.driver.core.exceptions.DriverException;
*
* @author Matthew T. Adams
* @author Mark Paluch
* @since April 24, 2003
* @see AsyncCqlTemplate
* @see CqlTemplate
* @see RowCallbackHandler
* @see RowMapper
*/
@FunctionalInterface
public interface ResultSetExtractor<T> {
/**
* Implementations must implement this method to process the entire {@link ResultSet}.
*
* @param resultSet {@link ResultSet} to extract data from.
* @return an arbitrary result object, or {@code null} if none (the extractor will typically be stateful in the latter
* case).
* @return an arbitrary result object, or {@literal null} if none (the extractor will typically be stateful in the
* latter case).
* @throws DriverException if a {@link DriverException} is encountered getting column values or navigating (that is,
* there's no need to catch {@link DriverException})
* @throws DataAccessException in case of custom exceptions
*/
T extractData(ResultSet resultSet) throws DriverException, DataAccessException;
}

View File

@@ -45,7 +45,7 @@ public interface RowCallbackHandler {
* Exactly what the implementation chooses to do is up to it: A trivial implementation might simply count rows, while
* another implementation might build an XML document.
*
* @param row the {@link Row} to process (pre-initialized for the current row)
* @param row the {@link Row} to process (pre-initialized for the current row).
* @throws DriverException if a {@link DriverException} is encountered getting column values (that is, there's no need
* to catch {@link DriverException})
*/

View File

@@ -33,6 +33,7 @@ import com.datastax.driver.core.exceptions.DriverException;
* @see RowCallbackHandler
* @see ResultSetExtractor
*/
@FunctionalInterface
public interface RowMapper<T> {
/**

View File

@@ -32,7 +32,9 @@ import com.datastax.driver.core.exceptions.DriverException;
* @author Mark Paluch
* @see CqlTemplate#execute(SessionCallback)
* @see CqlTemplate#query
* @see CqlTemplate#execute(String)
*/
@FunctionalInterface
public interface SessionCallback<T> {
/**

View File

@@ -35,7 +35,7 @@ public interface SessionFactoryLookup {
* their backing store.
*
* @param sessionFactoryName the name of the {@link SessionFactory}.
* @return the {@link SessionFactory} (never {@code null})
* @return the {@link SessionFactory} (never {@code null}).
* @throws SessionFactoryLookupFailureException if the lookup failed.
*/
SessionFactory getSessionFactory(String sessionFactoryName) throws SessionFactoryLookupFailureException;

View File

@@ -64,5 +64,4 @@ public interface PreparedStatementCache {
*/
PreparedStatement getPreparedStatement(Session session, RegularStatement statement,
Supplier<PreparedStatement> preparer);
}

View File

@@ -23,13 +23,13 @@ import org.springframework.data.mapping.MappingException;
* @author David Webb
* @author Mark Paluch
*/
@FunctionalInterface
public interface CassandraPersistentEntityMetadataVerifier {
/**
* Performs verification on the Persistent Entity to ensure all markers and marker combinations are valid.
*
* @param entity
* @param entity the entity to verify, must not be {@literal null}.
*/
void verify(CassandraPersistentEntity<?> entity) throws MappingException;
}

View File

@@ -25,6 +25,7 @@ import com.datastax.driver.core.UserType;
* @author Mark Paluch
* @since 1.5
*/
@FunctionalInterface
public interface UserTypeResolver {
/**

View File

@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
* @author Mark Paluch
* @since 2.0
*/
@FunctionalInterface
public interface Filter extends Iterable<CriteriaDefinition> {
/**

View File

@@ -36,6 +36,7 @@ import com.datastax.driver.core.Statement;
* @author Mark Paluch
* @since 1.5
*/
@FunctionalInterface
interface CassandraQueryExecution {
Object execute(Statement statement, Class<?> type);

View File

@@ -36,6 +36,7 @@ import com.datastax.driver.core.Statement;
* @author Mark Paluch
* @since 2.0
*/
@FunctionalInterface
interface ReactiveCassandraQueryExecution {
Object execute(Statement statement, Class<?> type);