This fixes a few violations and flips enforcement on.
Change-Id: I6b0de1511bda6ad509991f343c2a456ba67866d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
private static final Logger LOG = LoggerFactory.getLogger(ManagedNewTransactionRunnerImpl.class);
@Inject
- public ManagedNewTransactionRunnerImpl(DataBroker broker) {
+ public ManagedNewTransactionRunnerImpl(final DataBroker broker) {
// Early check to ensure the error message is understandable for the caller
super(requireNonNull(broker, "broker must not be null"));
}
@Override
@CheckReturnValue
public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(
- Class<D> datastoreType, InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) {
+ final Class<D> datastoreType,
+ final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) {
return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction,
WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit);
}
@Override
- public <R> R applyWithNewTransactionChainAndClose(Function<ManagedTransactionChain, R> chainConsumer) {
+ public <R> R applyWithNewTransactionChainAndClose(final Function<ManagedTransactionChain, R> chainConsumer) {
try (TransactionChain realTxChain = getTransactionFactory().createTransactionChain(
new TransactionChainListener() {
@Override
@Override
@CheckReturnValue
public <D extends Datastore, E extends Exception> FluentFuture<? extends Object>
- callWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType,
- InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer) {
+ callWithNewReadWriteTransactionAndSubmit(final Class<D> datastoreType,
+ final InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer) {
return callWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction,
WriteTrackingTypedReadWriteTransactionImpl::new, txConsumer::accept, this::commit);
}
// This is overridden to use this class’s commit method
@Override
@CheckReturnValue
- public <D extends Datastore, E extends Exception> FluentFuture<? extends Object> callWithNewWriteOnlyTransactionAndSubmit(
- Class<D> datastoreType, InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer) {
+ public <D extends Datastore, E extends Exception> FluentFuture<? extends Object>
+ callWithNewWriteOnlyTransactionAndSubmit(final Class<D> datastoreType,
+ final InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer) {
return super.callWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newWriteOnlyTransaction,
WriteTrackingTypedWriteTransactionImpl::new, txConsumer::accept, this::commit);
}
@CheckReturnValue
- private FluentFuture<? extends CommitInfo> commit(WriteTransaction realTx, WriteTrackingTransaction wrappedTx) {
+ private FluentFuture<? extends CommitInfo> commit(final WriteTransaction realTx,
+ final WriteTrackingTransaction wrappedTx) {
if (wrappedTx.isWritten()) {
// The transaction contains changes, commit it
return realTx.commit();
/**
* Managed transaction factories provide managed transactions, <em>i.e.</em> transactions which are automatically
* submitted or cancelled (write) or closed (read).
+ *
* <p>
* This is a common interface for broker- and chain-based transaction managers, and should not be used directly.
*/
* @param datastoreType the {@link Datastore} type that will be accessed
* @param txFunction the {@link InterruptibleCheckedFunction} that needs a new read-write transaction
* @return the {@link FluentFuture} returned by {@link ReadWriteTransaction#commit()}, or a failed future with an
- * application specific exception (not from submit())
+ * application specific exception (not from submit())
*/
@CheckReturnValue
<D extends Datastore, E extends Exception, R>
* @param datastoreType the {@link Datastore} type that will be accessed
* @param txConsumer the {@link InterruptibleCheckedConsumer} that needs a new read-write transaction
* @return the {@link FluentFuture} returned by {@link ReadWriteTransaction#commit()}, or a failed future with an
- * application specific exception (not from submit())
+ * application specific exception (not from submit())
*/
@CheckReturnValue
<D extends Datastore, E extends Exception>
* @param datastoreType the {@link Datastore} type that will be accessed
* @param txConsumer the {@link InterruptibleCheckedConsumer} that needs a new write only transaction
* @return the {@link FluentFuture} returned by {@link WriteTransaction#commit()}, or a failed future with an
- * application specific exception (not from submit())
+ * application specific exception (not from submit())
*/
@CheckReturnValue
<D extends Datastore, E extends Exception>
private final T transactionFactory;
- ManagedTransactionFactoryImpl(T transactionFactory) {
+ ManagedTransactionFactoryImpl(final T transactionFactory) {
this.transactionFactory = requireNonNull(transactionFactory, "transactionFactory must not be null");
}
@Override
public <D extends Datastore, E extends Exception, R> R applyInterruptiblyWithNewReadOnlyTransactionAndClose(
- Class<D> datastoreType, InterruptibleCheckedFunction<TypedReadTransaction<D>, R, E> txFunction)
+ final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadTransaction<D>, R, E> txFunction)
throws E, InterruptedException {
try (ReadTransaction realTx = transactionFactory.newReadOnlyTransaction()) {
TypedReadTransaction<D>
@Override
public <D extends Datastore, E extends Exception, R> R applyWithNewReadOnlyTransactionAndClose(
- Class<D> datastoreType, CheckedFunction<TypedReadTransaction<D>, R, E> txFunction) throws E {
+ final Class<D> datastoreType, final CheckedFunction<TypedReadTransaction<D>, R, E> txFunction) throws E {
try (ReadTransaction realTx = transactionFactory.newReadOnlyTransaction()) {
TypedReadTransaction<D>
wrappedTx = new TypedReadTransactionImpl<>(datastoreType, realTx);
@Override
@CheckReturnValue
public <D extends Datastore, E extends Exception, R>
- FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType,
- InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) {
+ FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(final Class<D> datastoreType,
+ final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) {
return applyWithNewTransactionAndSubmit(datastoreType, transactionFactory::newReadWriteTransaction,
TypedReadWriteTransactionImpl::new, txFunction, (realTx, wrappedTx) -> realTx.commit());
}
@Override
public <D extends Datastore, E extends Exception> void callInterruptiblyWithNewReadOnlyTransactionAndClose(
- Class<D> datastoreType, InterruptibleCheckedConsumer<TypedReadTransaction<D>, E> txConsumer)
+ final Class<D> datastoreType, final InterruptibleCheckedConsumer<TypedReadTransaction<D>, E> txConsumer)
throws E, InterruptedException {
try (ReadTransaction realTx = transactionFactory.newReadOnlyTransaction()) {
TypedReadTransaction<D> wrappedTx = new TypedReadTransactionImpl<>(datastoreType, realTx);
@Override
public <D extends Datastore, E extends Exception> void callWithNewReadOnlyTransactionAndClose(
- Class<D> datastoreType, CheckedConsumer<TypedReadTransaction<D>, E> txConsumer) throws E {
+ final Class<D> datastoreType, final CheckedConsumer<TypedReadTransaction<D>, E> txConsumer) throws E {
try (ReadTransaction realTx = transactionFactory.newReadOnlyTransaction()) {
TypedReadTransaction<D> wrappedTx = new TypedReadTransactionImpl<>(datastoreType, realTx);
txConsumer.accept(wrappedTx);
@Override
@CheckReturnValue
public <D extends Datastore, E extends Exception>
- FluentFuture<? extends Object> callWithNewReadWriteTransactionAndSubmit(Class<D> datastoreType,
- InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer) {
+ FluentFuture<? extends Object> callWithNewReadWriteTransactionAndSubmit(final Class<D> datastoreType,
+ final InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer) {
return callWithNewTransactionAndSubmit(datastoreType, transactionFactory::newReadWriteTransaction,
TypedReadWriteTransactionImpl::new, txConsumer, (realTx, wrappedTx) -> realTx.commit());
}
@Override
@CheckReturnValue
- public <D extends Datastore, E extends Exception> FluentFuture<? extends Object> callWithNewWriteOnlyTransactionAndSubmit(
- Class<D> datastoreType, InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer) {
+ public <D extends Datastore, E extends Exception> FluentFuture<? extends Object>
+ callWithNewWriteOnlyTransactionAndSubmit(final Class<D> datastoreType,
+ final InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer) {
return callWithNewTransactionAndSubmit(datastoreType, transactionFactory::newWriteOnlyTransaction,
TypedWriteTransactionImpl::new, txConsumer, (realTx, wrappedTx) -> realTx.commit());
}
@CheckReturnValue
protected <D extends Datastore, T extends WriteTransaction, W, E extends Exception> FluentFuture<? extends Object>
callWithNewTransactionAndSubmit(
- Class<D> datastoreType, Supplier<T> txSupplier, BiFunction<Class<D>, T, W> txWrapper,
- InterruptibleCheckedConsumer<W, E> txConsumer, BiFunction<T, W, FluentFuture<?>> txSubmitter) {
+ final Class<D> datastoreType, final Supplier<T> txSupplier, final BiFunction<Class<D>, T, W> txWrapper,
+ final InterruptibleCheckedConsumer<W, E> txConsumer, final BiFunction<T, W, FluentFuture<?>> txSubmitter) {
return applyWithNewTransactionAndSubmit(datastoreType, txSupplier, txWrapper, tx -> {
txConsumer.accept(tx);
return null;
@SuppressWarnings("checkstyle:IllegalCatch")
protected <D extends Datastore, T extends WriteTransaction, W, R, E extends Exception> FluentFuture<R>
applyWithNewTransactionAndSubmit(
- Class<D> datastoreType, Supplier<T> txSupplier, BiFunction<Class<D>, T, W> txWrapper,
- InterruptibleCheckedFunction<W, R, E> txFunction, BiFunction<T, W, FluentFuture<?>> txSubmitter) {
+ final Class<D> datastoreType, final Supplier<T> txSupplier, final BiFunction<Class<D>, T, W> txWrapper,
+ final InterruptibleCheckedFunction<W, R, E> txFunction,
+ final BiFunction<T, W, FluentFuture<?>> txSubmitter) {
T realTx = txSupplier.get();
W wrappedTx = txWrapper.apply(datastoreType, realTx);
R result;
import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.FluentFuture;
import java.util.Optional;
* @throws NullPointerException if the provided transaction is {@code null}.
*/
public static ReadWriteTransaction toReadWriteTransaction(
- TypedReadWriteTransaction<? extends Datastore> datastoreTx) {
+ final TypedReadWriteTransaction<? extends Datastore> datastoreTx) {
if (datastoreTx instanceof TypedReadWriteTransactionImpl) {
TypedReadWriteTransactionImpl nonSubmitCancelableDatastoreReadWriteTransaction =
(TypedReadWriteTransactionImpl) datastoreTx;
* @param datastoreTx The transaction to adapt.
* @return The adapted transaction.
*/
- public static WriteTransaction toWriteTransaction(TypedWriteTransaction<? extends Datastore> datastoreTx) {
+ public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) {
if (datastoreTx instanceof TypedWriteTransactionImpl) {
TypedWriteTransactionImpl nonSubmitCancelableDatastoreWriteTransaction =
(TypedWriteTransactionImpl) datastoreTx;
private final LogicalDatastoreType datastoreType;
private final T delegate;
- private WriteTransactionAdapter(LogicalDatastoreType datastoreType, T delegate) {
+ private WriteTransactionAdapter(final LogicalDatastoreType datastoreType, final T delegate) {
this.datastoreType = datastoreType;
this.delegate = delegate;
}
@Override
- public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
+ public <T extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
+ final T data) {
checkStore(store);
delegate.put(path, data);
}
@Override
- public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents) {
+ public <T extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
+ final T data, final boolean createMissingParents) {
checkStore(store);
delegate.put(path, data, createMissingParents);
}
@Override
- public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
+ public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
+ final T data) {
checkStore(store);
delegate.merge(path, data);
}
@Override
- public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
- boolean createMissingParents) {
+ public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
+ final T data, final boolean createMissingParents) {
checkStore(store);
delegate.merge(path, data, createMissingParents);
}
}
@Override
- public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
+ public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
checkStore(store);
delegate.delete(path);
}
throw new UnsupportedOperationException("Managed transactions must not be committed");
}
- void checkStore(LogicalDatastoreType store) {
+ void checkStore(final LogicalDatastoreType store) {
checkArgument(datastoreType.equals(store), "Invalid datastore %s used instead of %s", store, datastoreType);
}
private static final class ReadWriteTransactionAdapter<D extends Datastore>
extends WriteTransactionAdapter<D, TypedReadWriteTransaction<D>> implements ReadWriteTransaction {
- private ReadWriteTransactionAdapter(LogicalDatastoreType datastoreType, TypedReadWriteTransaction<D> delegate) {
+ private ReadWriteTransactionAdapter(final LogicalDatastoreType datastoreType,
+ final TypedReadWriteTransaction<D> delegate) {
super(datastoreType, delegate);
}
@Override
- public <T extends DataObject> FluentFuture<Optional<T>> read(LogicalDatastoreType store,
- InstanceIdentifier<T> path) {
+ public <T extends DataObject> FluentFuture<Optional<T>> read(final LogicalDatastoreType store,
+ final InstanceIdentifier<T> path) {
checkStore(store);
return delegate().read(path);
}