Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions src/fdtmc/FDTMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,20 @@ public Interface createInterface(String id, State initial, State success, State
errorTransition);

List<Interface> interfaceOccurrences = null;
if (interfaces.containsKey(id)) {
interfaceOccurrences = checkExistenceOfInterface(id);
interfaceOccurrences.add(newInterface);
return newInterface;
}

private List<Interface> checkExistenceOfInterface(String id) {
List<Interface> interfaceOccurrences;
if (interfaces.containsKey(id)) {
interfaceOccurrences = interfaces.get(id);
} else {
interfaceOccurrences = new LinkedList<Interface>();
interfaces.put(id, interfaceOccurrences);
}
interfaceOccurrences.add(newInterface);
return newInterface;
return interfaceOccurrences;
}

public State getStateByLabel(String label) {
Expand Down Expand Up @@ -227,19 +233,29 @@ public String toString() {
*/
@Override
public boolean equals(Object obj) {

if (obj != null && obj instanceof FDTMC) {
FDTMC other = (FDTMC) obj;
LinkedList<List<Interface>> thisInterfaces = new LinkedList<List<Interface>>(interfaces.values());
LinkedList<List<Interface>> otherInterfaces = new LinkedList<List<Interface>>(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<List<Interface>> thisInterfaces, LinkedList<List<Interface>> 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() {
Expand Down
14 changes: 9 additions & 5 deletions src/fdtmc/Interface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 16 additions & 6 deletions src/tool/RDGNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public static RDGNode getById(String id) {
}

public static String getNextId() {
return "n" + lastNodeIndex++;
String nextId;
nextId = "n" + lastNodeIndex++;
return nextId;
}

/**
Expand All @@ -102,21 +104,29 @@ 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();
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;
}

/**
Expand Down