Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 702cf57

Browse files
committed
Updated the Requirement-API to return if unsetting was successful. Added requirement-deletion to the rest api.
1 parent 84bf56c commit 702cf57

File tree

1 file changed

+3
-2
lines changed
  • src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration

1 file changed

+3
-2
lines changed

src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Requirements.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ public Optional<? extends Requirement<? extends Serializable>> getRequirementByI
8181
* Unsets the value of a requirement specified by the unique id.
8282
*
8383
* @param uniqueRequirementId the plugin unique requirement id
84-
* @return true, if a requirement with the given id exists
84+
* @return true, if the requirement exists and previously had a value
8585
*/
8686
public boolean unsetRequirementById(String uniqueRequirementId) {
8787
Optional<? extends Requirement<? extends Serializable>> requirement =
8888
getAllEntries().filter(entry -> entry.getKey().equals(uniqueRequirementId))
8989
.map(Map.Entry::getValue).findFirst();
9090

91+
boolean wasSet = requirement.isPresent() && requirement.get().isSet();
9192
requirement.ifPresent(Requirement::unsetValue);
92-
return requirement.isPresent();
93+
return wasSet;
9394
}
9495

9596
/**

0 commit comments

Comments
 (0)