Skip to content

Commit

Permalink
[fix] Fixed issue #15 to prevent overlap
Browse files Browse the repository at this point in the history
Previous error was due to conclusion having duplicate support identifiers in its set. Implemented an equality relation for JustificiationElement.
  • Loading branch information
Nirmal-code committed Oct 6, 2023
1 parent 144f697 commit 3c558d1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import ca.mcscert.jpipe.model.*;
import ca.mcscert.jpipe.model.justification.*;
import ca.mcscert.jpipe.model.justification.Conclusion;
import ca.mcscert.jpipe.model.justification.JustificationElement;


public class ImplementJustificationBuilder extends ConcreteJustificationBuilder{
Expand Down Expand Up @@ -43,9 +40,4 @@ public void setConclusion(Conclusion conclusion) {
this.conclusion = conclusion;
}






}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ protected final void fill(Conclusion c) {
checkConclusionPredecessor(source);
Strategy strategy = (Strategy) source;
c.addSupport(strategy);

fill(strategy);
}
}
Expand Down Expand Up @@ -120,16 +119,6 @@ protected final void fill(SubConclusion sc) {
}
}

// @Override
// public boolean equals(Object o){
// if (o instanceof JustificationBuilder){
// JustificationBuilder comparable = (JustificationBuilder)o;
// return (comparable.getJustificationName().equals(this.name));
// }else{
// return false;
// }
// }



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public Conclusion(String identifier, String label) {
}

public void addSupport(Strategy from) {
if (supports.contains(from)){
this.supports.remove(from);
}
this.supports.add(from);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,20 @@ public String getIdentifier() {
public String getLabel() {
return label;
}

@Override
public boolean equals(Object obj){
if (obj instanceof Support){
Support foreign_obj=(Support)obj;
if (foreign_obj.getIdentifier().equals(this.identifier)){
return true;
}
}
return false;
}

@Override
public int hashCode() {
return this.identifier.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.HashSet;
import java.util.Set;



public class Strategy extends JustificationElement implements Visitable {

private Set<Support> supports = new HashSet<>();
Expand All @@ -15,6 +17,9 @@ public Strategy(String identifier, String label) {
}

public void addSupport(Support s) {
if (supports.contains(s)){
supports.remove(s);
}
this.supports.add(s);
}

Expand All @@ -27,4 +32,5 @@ public void accept(AbstractVisitor<?> visitor) {
visitor.visit(this);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public SubConclusion(String identifier, String label) {
}

public void addSupport(Strategy strategy) {
if (this.supports.contains(strategy)){
this.supports.remove(strategy);
}
this.supports.add(strategy);
}

Expand Down

0 comments on commit 3c558d1

Please sign in to comment.