Removing warnings

This commit is contained in:
Shams Asari
2018-07-05 12:40:36 +01:00
parent 20a589d66d
commit 0c8c914882
45 changed files with 168 additions and 344 deletions

View File

@ -136,7 +136,7 @@ class IntegrationTestingTutorial : IntegrationTest() {
// move to Bob
parallel(
(1..numberOfStates).map { i ->
expect(match = { it.moved() == i * 100 }) { update: Vault.Update<Cash.State> ->
expect(match = { it.moved() == i * 100 }) { _: Vault.Update<Cash.State> ->
}
}
),
@ -154,7 +154,7 @@ class IntegrationTestingTutorial : IntegrationTest() {
}
}
fun Vault.Update<Cash.State>.moved(): Int {
private fun Vault.Update<Cash.State>.moved(): Int {
val consumedSum = consumed.sumBy { it.state.data.amount.quantity.toInt() }
val producedSum = produced.sumBy { it.state.data.amount.quantity.toInt() }
return consumedSum - producedSum

View File

@ -40,6 +40,7 @@ import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
@ -134,7 +135,7 @@ public class FlowCookbookJava {
// We retrieve a notary from the network map.
// DOCSTART 01
CordaX500Name notaryName = new CordaX500Name("Notary Service", "London", "GB");
Party specificNotary = getServiceHub().getNetworkMapCache().getNotary(notaryName);
Party specificNotary = Objects.requireNonNull(getServiceHub().getNetworkMapCache().getNotary(notaryName));
// Alternatively, we can pick an arbitrary notary from the notary
// list. However, it is always preferable to specify the notary
// explicitly, as the notary list might change when new notaries are
@ -378,7 +379,7 @@ public class FlowCookbookJava {
// Or we can add the output state as a ``TransactionState``, which already specifies
// the output's contract and notary.
// DOCSTART 51
TransactionState txState = new TransactionState(ourOutputState, DummyContract.PROGRAM_ID, specificNotary);
TransactionState txState = new TransactionState<>(ourOutputState, DummyContract.PROGRAM_ID, specificNotary);
// DOCEND 51
// Commands can be added as ``Command``s.
@ -662,7 +663,7 @@ public class FlowCookbookJava {
}
@Override
protected void checkTransaction(SignedTransaction stx) {
protected void checkTransaction(@NotNull SignedTransaction stx) {
requireThat(require -> {
// Any additional checking we see fit...
DummyState outputState = (DummyState) stx.getTx().getOutputs().get(0).getData();

View File

@ -13,6 +13,7 @@ package net.corda.docs.java.tutorial.contract;
import net.corda.core.contracts.*;
import net.corda.core.transactions.LedgerTransaction;
import net.corda.core.transactions.LedgerTransaction.InOutGroup;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
import java.util.Currency;
@ -22,6 +23,7 @@ import static net.corda.core.contracts.ContractsDSL.requireSingleCommand;
import static net.corda.core.contracts.ContractsDSL.requireThat;
import static net.corda.finance.utils.StateSumming.sumCashBy;
@SuppressWarnings("unused")
public class CommercialPaper implements Contract {
// DOCSTART 1
public static final String IOU_CONTRACT_ID = "com.example.contract.IOUContract";
@ -29,7 +31,7 @@ public class CommercialPaper implements Contract {
// DOCSTART 3
@Override
public void verify(LedgerTransaction tx) {
public void verify(@NotNull LedgerTransaction tx) {
List<InOutGroup<State, State>> groups = tx.groupStates(State.class, State::withoutOwner);
CommandWithParties<Commands> cmd = requireSingleCommand(tx.getCommands(), Commands.class);
// DOCEND 3
@ -37,7 +39,7 @@ public class CommercialPaper implements Contract {
// DOCSTART 4
TimeWindow timeWindow = tx.getTimeWindow();
for (InOutGroup group : groups) {
for (InOutGroup<State, State> group : groups) {
List<State> inputs = group.getInputs();
List<State> outputs = group.getOutputs();
@ -57,6 +59,7 @@ public class CommercialPaper implements Contract {
Amount<Issued<Currency>> received = sumCashBy(tx.getOutputStates(), input.getOwner());
if (timeWindow == null) throw new IllegalArgumentException("Redemptions must be timestamped");
Instant time = timeWindow.getFromTime();
if (time == null) throw new IllegalArgumentException("Redemptions must have a from time");
requireThat(require -> {
require.using("the paper must have matured", time.isAfter(input.getMaturityDate()));
require.using("the received amount equals the face value", received == input.getFaceValue());
@ -68,6 +71,7 @@ public class CommercialPaper implements Contract {
State output = outputs.get(0);
if (timeWindow == null) throw new IllegalArgumentException("Issuances must have a time-window");
Instant time = timeWindow.getUntilTime();
if (time == null) throw new IllegalArgumentException("Issuances must have an until time");
requireThat(require -> {
// Don't allow people to issue commercial paper under other entities identities.
require.using("output states are issued by a command signer", cmd.getSigners().contains(output.getIssuance().getParty().getOwningKey()));