From 052d054fcf5e9ee35ba1dc76a343e0e67045cd82 Mon Sep 17 00:00:00 2001 From: leonardork Date: Fri, 22 Sep 2017 14:14:41 -0300 Subject: [PATCH 1/5] applying method extraction technique --- src/fdtmc/FDTMC.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fdtmc/FDTMC.java b/src/fdtmc/FDTMC.java index ef21282..13a3522 100644 --- a/src/fdtmc/FDTMC.java +++ b/src/fdtmc/FDTMC.java @@ -156,14 +156,20 @@ public Interface createInterface(String id, State initial, State success, State errorTransition); List interfaceOccurrences = null; - if (interfaces.containsKey(id)) { + interfaceOccurrences = checkExistenceOfInterface(id); + interfaceOccurrences.add(newInterface); + return newInterface; + } + + private List checkExistenceOfInterface(String id) { + List interfaceOccurrences; + if (interfaces.containsKey(id)) { interfaceOccurrences = interfaces.get(id); } else { interfaceOccurrences = new LinkedList(); interfaces.put(id, interfaceOccurrences); } - interfaceOccurrences.add(newInterface); - return newInterface; + return interfaceOccurrences; } public State getStateByLabel(String label) { From dd2c00961b9644ae7563c949f4f406b76d976574 Mon Sep 17 00:00:00 2001 From: leonardork Date: Fri, 22 Sep 2017 15:16:26 -0300 Subject: [PATCH 2/5] extract method to compare attibutes os object --- src/fdtmc/Interface.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/fdtmc/Interface.java b/src/fdtmc/Interface.java index f6cd969..b077388 100644 --- a/src/fdtmc/Interface.java +++ b/src/fdtmc/Interface.java @@ -53,15 +53,19 @@ public String getAbstractedId() { public boolean equals(Object obj) { if (obj != null && obj instanceof Interface) { Interface other = (Interface) obj; - return initial.equals(other.initial) - && success.equals(other.success) - && error.equals(other.error) - && successTransition.equals(other.successTransition) - && errorTransition.equals(other.errorTransition); + return compareAllAtributtes(other); } return false; } + private boolean compareAllAtributtes(Interface other) { + return initial.equals(other.initial) + && success.equals(other.success) + && error.equals(other.error) + && successTransition.equals(other.successTransition) + && errorTransition.equals(other.errorTransition); + } + @Override public int hashCode() { return initial.hashCode() From 1b1d03a4a902641efdc9e17b110a3b64be165c90 Mon Sep 17 00:00:00 2001 From: leonardork Date: Fri, 22 Sep 2017 15:21:50 -0300 Subject: [PATCH 3/5] extract method --- src/tool/RDGNode.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tool/RDGNode.java b/src/tool/RDGNode.java index 180097c..874e9ed 100644 --- a/src/tool/RDGNode.java +++ b/src/tool/RDGNode.java @@ -102,13 +102,17 @@ public static String getNextId() { public boolean equals(Object obj) { if (obj != null && obj instanceof RDGNode) { RDGNode other = (RDGNode) obj; - return this.getPresenceCondition().equals(other.getPresenceCondition()) - && this.getFDTMC().equals(other.getFDTMC()) - && this.getDependencies().equals(other.getDependencies()); + return compareAttributesOfRDGNodeObject(other); } return false; } + private boolean compareAttributesOfRDGNodeObject(RDGNode other) { + return this.getPresenceCondition().equals(other.getPresenceCondition()) + && this.getFDTMC().equals(other.getFDTMC()) + && this.getDependencies().equals(other.getDependencies()); + } + @Override public int hashCode() { return id.hashCode() + presenceCondition.hashCode() + fdtmc.hashCode() + dependencies.hashCode(); From 970bf596372544a5275f84342acd2b2719cdb106 Mon Sep 17 00:00:00 2001 From: geisonszo Date: Fri, 29 Sep 2017 19:14:46 -0300 Subject: [PATCH 4/5] extract method --- src/fdtmc/FDTMC.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/fdtmc/FDTMC.java b/src/fdtmc/FDTMC.java index 13a3522..78e9c2d 100644 --- a/src/fdtmc/FDTMC.java +++ b/src/fdtmc/FDTMC.java @@ -233,19 +233,29 @@ public String toString() { */ @Override public boolean equals(Object obj) { + if (obj != null && obj instanceof FDTMC) { FDTMC other = (FDTMC) obj; LinkedList> thisInterfaces = new LinkedList>(interfaces.values()); LinkedList> otherInterfaces = new LinkedList>(other.interfaces.values()); - return states.equals(other.states) - && getInitialState().equals(other.getInitialState()) - && getSuccessState().equals(other.getSuccessState()) - && getErrorState().equals(other.getErrorState()) - && transitionSystem.equals(other.transitionSystem) - && thisInterfaces.equals(otherInterfaces); + + return compareState(other, thisInterfaces, otherInterfaces); } + return false; } + + private boolean compareState(FDTMC other, LinkedList> thisInterfaces, LinkedList> otherInterfaces) { + + boolean state = states.equals(other.states) + && getInitialState().equals(other.getInitialState()) + && getSuccessState().equals(other.getSuccessState()) + && getErrorState().equals(other.getErrorState()) + && transitionSystem.equals(other.transitionSystem) + && thisInterfaces.equals(otherInterfaces); + + return state; + } @Override public int hashCode() { From 4a1622f8a886a34e8c165ca68b2ca12e7bf1cbe3 Mon Sep 17 00:00:00 2001 From: Jhonatan Alves Date: Fri, 29 Sep 2017 23:51:51 -0300 Subject: [PATCH 5/5] Simplifying methods returns --- src/tool/RDGNode.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tool/RDGNode.java b/src/tool/RDGNode.java index 874e9ed..bcf333f 100644 --- a/src/tool/RDGNode.java +++ b/src/tool/RDGNode.java @@ -90,7 +90,9 @@ public static RDGNode getById(String id) { } public static String getNextId() { - return "n" + lastNodeIndex++; + String nextId; + nextId = "n" + lastNodeIndex++; + return nextId; } /** @@ -115,12 +117,16 @@ private boolean compareAttributesOfRDGNodeObject(RDGNode other) { @Override public int hashCode() { - return id.hashCode() + presenceCondition.hashCode() + fdtmc.hashCode() + dependencies.hashCode(); + int hashCode; + hashCode = id.hashCode() + presenceCondition.hashCode() + fdtmc.hashCode() + dependencies.hashCode(); + return hashCode; } @Override public String toString() { - return getId() + " (" + getPresenceCondition() + ")"; + String newString; + newString = getId() + " (" + getPresenceCondition() + ")"; + return newString; } /**