Package com.adobe.aem.modernize.rule
Interface RewriteRule
-
- All Superinterfaces:
Comparable<RewriteRule>
- All Known Subinterfaces:
ComponentRewriteRule
,PolicyImportRule
,ServiceBasedRewriteRule
,StructureRewriteRule
- All Known Implementing Classes:
ColumnControlRewriteRule
,PageRewriteRule
@ConsumerType public interface RewriteRule extends Comparable<RewriteRule>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RewriteRule.Comparator
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @Nullable Node
applyTo(@NotNull Node root, @NotNull Set<String> finalPaths)
Applies this rule to the subtree rooted at the specifiedroot
node.default int
compareTo(@NotNull RewriteRule o)
String
getId()
Returns the unique identifier for this Rule.default int
getRanking()
Ranking of this Rule relative to others that may also match a given node.default String
getTitle()
The title for this rule.boolean
matches(@NotNull Node root)
Returns true if this rule matches the given subtree.
-
-
-
Method Detail
-
getTitle
default String getTitle()
The title for this rule.- Returns:
- the title
-
getId
String getId()
Returns the unique identifier for this Rule.- Returns:
- the id
-
matches
boolean matches(@NotNull @NotNull Node root) throws RepositoryException
Returns true if this rule matches the given subtree.- Parameters:
root
- The root of the subtree to be checked for a match- Returns:
- true if this rule applies, false otherwise
- Throws:
RepositoryException
- if reading the repository fails
-
applyTo
@Nullable @Nullable Node applyTo(@NotNull @NotNull Node root, @NotNull @NotNull Set<String> finalPaths) throws RewriteException, RepositoryException
Applies this rule to the subtree rooted at the specified
root
node. The implementation of this method may either modify the properties and nodes contained in that tree, or replace it by adding a new child to the parent ofroot
. In the latter case, the implementation is responsible for removing the original subtree (without saving).Repository modifications are made but not saved.
Rewrite rules must not rewrite trees in a circular fashion, as this might lead to infinite loops.
Optionally, the implementation can indicate which nodes of the resulting tree are final and therefore safe for the algorithm to skip in subsequent traversals of the tree. Add the paths of final nodes to the specified set.
- Parameters:
root
- The root of the subtree to be rewrittenfinalPaths
- list of nodes paths which should not be updated after this method completes- Returns:
- the root node of the rewritten tree, or null if it was removed
- Throws:
RewriteException
- if the rewrite operation failed or cannot be completedRepositoryException
- if the node updates cannot be saved
-
compareTo
default int compareTo(@NotNull @NotNull RewriteRule o)
- Specified by:
compareTo
in interfaceComparable<RewriteRule>
-
getRanking
default int getRanking()
Ranking of this Rule relative to others that may also match a given node.- Returns:
- the rule's ranking
-
-