From 6546881559e4bbcfe2b220199a9f3cd4196d1960 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 9 Jun 2015 23:58:41 +1000 Subject: A few changes, as suggested by static analysis --- .../java/au/id/zancanaro/javacheck/state/CommandValue.java | 4 ++-- .../java/au/id/zancanaro/javacheck/state/GeneratedCommand.java | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src/main/java/au/id/zancanaro/javacheck/state') diff --git a/src/main/java/au/id/zancanaro/javacheck/state/CommandValue.java b/src/main/java/au/id/zancanaro/javacheck/state/CommandValue.java index 1ca51a9..d2f3419 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/CommandValue.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/CommandValue.java @@ -46,8 +46,8 @@ public class CommandValue { @SuppressWarnings("unchecked") public T get() { - if (values.containsKey(getId())) { - return (T) values.get(getId()); + if (values.containsKey(id)) { + return (T) values.get(id); } else { throw new NoSuchElementException("Concrete values cannot be supplied prior to being calculated"); } diff --git a/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java b/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java index 23f306b..92a90f9 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java @@ -30,19 +30,15 @@ public class GeneratedCommand { GeneratedCommand that = (GeneratedCommand) o; - if (args != null ? !args.equals(that.args) : that.args != null) - return false; - if (command != null ? !command.equals(that.command) : that.command != null) - return false; + return !(args != null ? !args.equals(that.args) : that.args != null) + && !(command != null ? !command.equals(that.command) : that.command != null); - return true; } @Override public int hashCode() { int result = command != null ? command.hashCode() : 0; - result = 31 * result + (args != null ? args.hashCode() : 0); - return result; + return 31 * result + (args != null ? args.hashCode() : 0); } @Override -- cgit v1.2.3