mirror of
https://github.com/corda/corda.git
synced 2025-01-21 12:05:08 +00:00
Remove the copy of Guava from within the finance module. (#1362)
This commit is contained in:
parent
1139c1abf5
commit
03ddaaac11
@ -26,6 +26,8 @@ dependencies {
|
||||
// ObjectWeb Asm: a library for synthesising and working with JVM bytecode.
|
||||
compile "org.ow2.asm:asm:5.0.4"
|
||||
|
||||
compile "com.google.guava:guava:$guava_version"
|
||||
|
||||
testCompile "junit:junit:$junit_version"
|
||||
testCompile project(':test-utils')
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ dependencies {
|
||||
// and CorDapps using :finance features should use 'cordapp' not 'compile' linkage.
|
||||
cordaCompile project(':core')
|
||||
|
||||
compile "com.google.guava:guava:$guava_version"
|
||||
|
||||
testCompile project(':test-utils')
|
||||
testCompile project(path: ':core', configuration: 'testArtifacts')
|
||||
testCompile "junit:junit:$junit_version"
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.corda.finance.contracts;
|
||||
|
||||
import co.paralleluniverse.fibers.Suspendable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import kotlin.Unit;
|
||||
import net.corda.core.contracts.*;
|
||||
import net.corda.core.crypto.testing.NullPublicKey;
|
||||
@ -20,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.Currency;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -128,7 +127,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AbstractParty> getParticipants() {
|
||||
return ImmutableList.of(this.owner);
|
||||
return Collections.singletonList(this.owner);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +174,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
final List<AuthenticatedObject<CommandData>> commands = tx.getCommands().stream().filter(
|
||||
it -> it.getValue() instanceof Commands
|
||||
).collect(Collectors.toList());
|
||||
final AuthenticatedObject<CommandData> command = Iterables.getOnlyElement(commands);
|
||||
final AuthenticatedObject<CommandData> command = onlyElementOf(commands);
|
||||
final TimeWindow timeWindow = tx.getTimeWindow();
|
||||
|
||||
for (final LedgerTransaction.InOutGroup<State, State> group : groups) {
|
||||
@ -184,7 +183,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
if (command.getValue() instanceof Commands.Move) {
|
||||
final AuthenticatedObject<Commands.Move> cmd = requireSingleCommand(tx.getCommands(), Commands.Move.class);
|
||||
// There should be only a single input due to aggregation above
|
||||
final State input = Iterables.getOnlyElement(inputs);
|
||||
final State input = onlyElementOf(inputs);
|
||||
|
||||
if (!cmd.getSigners().contains(input.getOwner().getOwningKey()))
|
||||
throw new IllegalStateException("Failed requirement: the transaction is signed by the owner of the CP");
|
||||
@ -197,7 +196,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
final AuthenticatedObject<Commands.Redeem> cmd = requireSingleCommand(tx.getCommands(), Commands.Redeem.class);
|
||||
|
||||
// There should be only a single input due to aggregation above
|
||||
final State input = Iterables.getOnlyElement(inputs);
|
||||
final State input = onlyElementOf(inputs);
|
||||
|
||||
if (!cmd.getSigners().contains(input.getOwner().getOwningKey()))
|
||||
throw new IllegalStateException("Failed requirement: the transaction is signed by the owner of the CP");
|
||||
@ -218,7 +217,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
});
|
||||
} else if (command.getValue() instanceof Commands.Issue) {
|
||||
final AuthenticatedObject<Commands.Issue> cmd = requireSingleCommand(tx.getCommands(), Commands.Issue.class);
|
||||
final State output = Iterables.getOnlyElement(outputs);
|
||||
final State output = onlyElementOf(outputs);
|
||||
final Instant time = null == timeWindow
|
||||
? null
|
||||
: timeWindow.getUntilTime();
|
||||
@ -257,4 +256,13 @@ public class JavaCommercialPaper implements Contract {
|
||||
tx.addOutputState(new TransactionState<>(new State(paper.getState().getData().getIssuance(), newOwner, paper.getState().getData().getFaceValue(), paper.getState().getData().getMaturityDate()), paper.getState().getNotary(), paper.getState().getEncumbrance()));
|
||||
tx.addCommand(new Command<>(new Commands.Move(), paper.getState().getData().getOwner().getOwningKey()));
|
||||
}
|
||||
|
||||
private static <T> T onlyElementOf(Iterable<T> iterable) {
|
||||
Iterator<T> iter = iterable.iterator();
|
||||
T item = iter.next();
|
||||
if (iter.hasNext()) {
|
||||
throw new IllegalArgumentException("Iterable has more than one element!");
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user