This commit is contained in:
2024-10-25 23:35:28 +02:00
parent 23ea8746b1
commit 0b33ac703d
16 changed files with 230 additions and 231 deletions

View File

@@ -5,10 +5,5 @@ package src.fr.api;
* A public type to organize part types in categories
*/
public interface Category {
/*
* return the name of the cathegory
* @return String, name of the cathegory, non null
*/
String getName();
}

View File

@@ -1,18 +1,6 @@
package src.fr.api;
import java.util.Set;
public interface CompatibilityChecker {
/*
* return the list of the incompatibles PartType of a PartType
* @param reference : the PartType that we want to see the incompatibilities,non null
* @return the Set list of the incompatibles PartType
*/
Set<PartType> getIncompatibilities(PartType reference);
/*
* return the list of the requirements PartType of a PartType
* @param reference : the PartType that we want to see the requirements,non null
* @return the Set list of the requirements PartType
*/
Set<PartType> getRequirements(PartType reference);
}

View File

@@ -1,34 +1,8 @@
package src.fr.api;
import java.util.Set;
public interface CompatibilityManager extends CompatibilityChecker {
/*
* add a incompatibles PartType to a PartType
* @param reference : the PartType that we wish to add incompatibilities
* @param target : Set list of incompatibilities PartType to add
*/
void addIncompatibilities(PartType reference,Set<PartType> target);
/*
* remove a PartType of the incompatibilities of a PartType, warning,
* warning : we must also remove the incompatibility from all the other PartTypes which the @param reference in their incompatibility
* @param reference : the PartType that we wish to remove a incompatible PartType
* @param target : PartType to remove of incompatibility
*/
void removeIncompatibility(PartType reference, PartType target);
/*
* add requirements PartType to a PartType
* @param reference : the PartType that we wish to add requirements
* @param target : Set list of requirement PartType to add
*/
void addRequirements(PartType reference, Set<PartType> target);
/*
* remove a PartType of the incompatibilities of a PartType
* @param reference : the PartType that we wish to remove a requirement PartType
* @param target : PartType to remove of requirement
*/
void removeRequirement(PartType reference, PartType target);
}

View File

@@ -1,18 +1,13 @@
package src.fr.api;
import java.util.Set;
import java.util.Optional;
public interface Configuration {
/*
* @return true if there is no compatibility issue between PartType else false
*/
boolean isValid();
boolean isComplete();
Set<PartType> getSelectedParts();
public Set<Part> getSelectedParts();
public Optional<Part> getSelectionForCategory(Category category);
void selectPart(PartType chosenPart);
PartType getSelectionForCategory(Category category);
void unselectPartType(Category categoryToClear);
void clear();
}

8
src/fr/api/Part.java Normal file
View File

@@ -0,0 +1,8 @@
package src.fr.api;
public interface Part extends PropertyManager {
default String getName() {
return this.getClass().getTypeName();
};
Category getCategory();
PartType getType();
}

View File

@@ -0,0 +1,42 @@
package src.fr.api;
import java.util.Set;
import java.util.Optional;
public interface PropertyManager {
/**
* Returns an immutable set of the property names supported by the property manager.
*
* @return
*/
public Set<String> getPropertyNames();
/**
* Returns the immutable set of discrete string values for a given property.
* For properties that have a non explicit set of possible values (eg double converted to strings),
* or for a non existing property name, returns an empty set.
*
* @param propertyName a non-null string reference
* @return an immutable set (see above)
*/
public Set<String> getAvailablePropertyValues(String propertyName);
/**
* Returns the optional value of a property.
* If the object does not support that property then an empty optional is returned.
* @param propertyName the property to read
* @return
*/
public Optional<String> getProperty(String propertyName);
/**
* Sets the value of a given property.
* If there is not such property, or if it not writable, or if the value is invalid
* then an IllegalArgumentException is thrown.
* @param propertyName
* @param propertyValue
* @throws IllegalArgumentException (see above)
*/
void setProperty(String propertyName, String propertyValue);
}