-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes & improvements to action parsing (#1057)
Signed-off-by: Pablete1234 <[email protected]>
- Loading branch information
1 parent
1133839
commit d4409b1
Showing
14 changed files
with
127 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/src/main/java/tc/oc/pgm/action/ActionScopeValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package tc.oc.pgm.action; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import tc.oc.pgm.api.feature.FeatureValidation; | ||
import tc.oc.pgm.util.xml.InvalidXMLException; | ||
import tc.oc.pgm.util.xml.Node; | ||
|
||
public class ActionScopeValidation implements FeatureValidation<ActionDefinition<?>> { | ||
|
||
private static final Map<Class<?>, ActionScopeValidation> INSTANCES = new HashMap<>(); | ||
|
||
public static ActionScopeValidation of(Class<?> scope) { | ||
return INSTANCES.computeIfAbsent(scope, ActionScopeValidation::new); | ||
} | ||
|
||
private final Class<?> scope; | ||
|
||
private ActionScopeValidation(Class<?> scope) { | ||
this.scope = scope; | ||
} | ||
|
||
@Override | ||
public void validate(ActionDefinition<?> definition, Node node) throws InvalidXMLException { | ||
Class<?> scope = definition.getScope(); | ||
if (!scope.isAssignableFrom(this.scope)) | ||
throw new InvalidXMLException( | ||
"Wrong action scope, got " | ||
+ scope.getSimpleName() | ||
+ " but expected " | ||
+ scope.getSimpleName(), | ||
node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.