Improve manager
update manager
This commit is contained in:
@@ -8,16 +8,18 @@ import fr.istic.nplouzeau.cartaylor.api.PartType;
|
|||||||
|
|
||||||
public class CompatibilityChecker implements fr.istic.nplouzeau.cartaylor.api.CompatibilityChecker {
|
public class CompatibilityChecker implements fr.istic.nplouzeau.cartaylor.api.CompatibilityChecker {
|
||||||
|
|
||||||
private HashMap<PartType, Set<PartType>> incompatibilites;
|
private HashMap<PartType, Set<PartType>> incompatibilities;
|
||||||
private HashMap<PartType, Set<PartType>> requirements;
|
private HashMap<PartType, Set<PartType>> requirements;
|
||||||
|
|
||||||
public CompatibilityChecker(Set<PartType> incompatibilities, Set<PartType> requirements){
|
public CompatibilityChecker( HashMap<PartType, Set<PartType>> incompatibilities, HashMap<PartType, Set<PartType>> requirements){
|
||||||
|
this.incompatibilities=incompatibilities;
|
||||||
|
this.requirements= requirements;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PartType> getIncompatibilities(PartType reference) {
|
public Set<PartType> getIncompatibilities(PartType reference) {
|
||||||
return this.incompatibilites.get(reference);
|
return this.incompatibilities.get(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,15 +6,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import fr.istic.nplouzeau.cartaylor.api.PartType;
|
import fr.istic.nplouzeau.cartaylor.api.PartType;
|
||||||
|
|
||||||
public class CompatibilityManager implements fr.istic.nplouzeau.cartaylor.api.CompatibilityManager {
|
public abstract class CompatibilityManager implements fr.istic.nplouzeau.cartaylor.api.CompatibilityManager {
|
||||||
|
|
||||||
private HashMap<PartType, Set<PartType>> incompatibilites;
|
|
||||||
private HashMap<PartType, Set<PartType>> requirements;
|
|
||||||
|
|
||||||
public CompatibilityManager() {
|
|
||||||
this.requirements= new HashMap<>();
|
|
||||||
this.incompatibilites = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addIncompatibilities(PartType reference, Set<PartType> target){
|
public void addIncompatibilities(PartType reference, Set<PartType> target){
|
||||||
@@ -27,8 +19,7 @@ public class CompatibilityManager implements fr.istic.nplouzeau.cartaylor.api.Co
|
|||||||
Set<PartType> require = this.getRequirements(reference);
|
Set<PartType> require = this.getRequirements(reference);
|
||||||
|
|
||||||
if(incompa== null){
|
if(incompa== null){
|
||||||
incompa= new HashSet<PartType>(target);
|
incompa=target;
|
||||||
this.incompatibilites.put(reference,incompa);
|
|
||||||
}else {
|
}else {
|
||||||
for(PartType x: target){
|
for(PartType x: target){
|
||||||
if (incompa.contains(x)){
|
if (incompa.contains(x)){
|
||||||
@@ -81,8 +72,7 @@ public class CompatibilityManager implements fr.istic.nplouzeau.cartaylor.api.Co
|
|||||||
Set<PartType> incompa = this.getIncompatibilities(reference);
|
Set<PartType> incompa = this.getIncompatibilities(reference);
|
||||||
Set<PartType> require = this.getRequirements(reference);
|
Set<PartType> require = this.getRequirements(reference);
|
||||||
if(require== null){
|
if(require== null){
|
||||||
require= new HashSet<PartType>(target);
|
require= target;
|
||||||
this.incompatibilites.put(reference,require);
|
|
||||||
}else {
|
}else {
|
||||||
for(PartType x: target){
|
for(PartType x: target){
|
||||||
if (require.contains(x)){
|
if (require.contains(x)){
|
||||||
@@ -126,13 +116,7 @@ public class CompatibilityManager implements fr.istic.nplouzeau.cartaylor.api.Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<PartType> getIncompatibilities(PartType reference) {
|
|
||||||
return this.incompatibilites.get(reference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public abstract Set<PartType> getIncompatibilities(PartType reference);
|
||||||
public Set<PartType> getRequirements(PartType reference) {
|
public abstract Set<PartType> getRequirements(PartType reference);
|
||||||
return this.requirements.get(reference);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user