diff --git a/src/main/java/danta/aem/contextprocessors/AddAllResourceContentPropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddAllResourceContentPropertiesContextProcessor.java index 305553c..35ce4c8 100644 --- a/src/main/java/danta/aem/contextprocessors/AddAllResourceContentPropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddAllResourceContentPropertiesContextProcessor.java @@ -31,6 +31,7 @@ import org.apache.sling.api.resource.Resource; import javax.jcr.Node; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -52,9 +53,11 @@ public class AddAllResourceContentPropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(CONTENT_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(CONTENT_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddBasicResourcePropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddBasicResourcePropertiesContextProcessor.java index 40c2f11..20068d9 100644 --- a/src/main/java/danta/aem/contextprocessors/AddBasicResourcePropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddBasicResourcePropertiesContextProcessor.java @@ -30,6 +30,7 @@ import org.apache.sling.api.resource.Resource; import javax.jcr.Node; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -50,9 +51,11 @@ public class AddBasicResourcePropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(CONTENT_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(CONTENT_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddComponentPropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddComponentPropertiesContextProcessor.java index d326fc5..c19927f 100644 --- a/src/main/java/danta/aem/contextprocessors/AddComponentPropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddComponentPropertiesContextProcessor.java @@ -35,6 +35,7 @@ import org.apache.sling.api.resource.ResourceResolverFactory; import javax.jcr.Node; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -55,14 +56,16 @@ public class AddComponentPropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC) - private ResourceResolverFactory resourceResolverFactory; + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(COMPONENT_CATEGORY)); private static final String CONFIG_SERVICE = "config-service"; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC) + private ResourceResolverFactory resourceResolverFactory; + @Override public Set anyOf() { - return Sets.newHashSet(COMPONENT_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddDesignPropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddDesignPropertiesContextProcessor.java index 5403239..73d243b 100644 --- a/src/main/java/danta/aem/contextprocessors/AddDesignPropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddDesignPropertiesContextProcessor.java @@ -32,6 +32,7 @@ import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -52,9 +53,11 @@ public class AddDesignPropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(DESIGN_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(DESIGN_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddGlobalPropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddGlobalPropertiesContextProcessor.java index 3985001..acf3690 100644 --- a/src/main/java/danta/aem/contextprocessors/AddGlobalPropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddGlobalPropertiesContextProcessor.java @@ -31,6 +31,7 @@ import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -50,9 +51,11 @@ public class AddGlobalPropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(GLOBAL_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(GLOBAL_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddPagePropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddPagePropertiesContextProcessor.java index 1741734..0824712 100644 --- a/src/main/java/danta/aem/contextprocessors/AddPagePropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddPagePropertiesContextProcessor.java @@ -42,6 +42,7 @@ import javax.jcr.Node; import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.Set; @@ -63,12 +64,14 @@ public class AddPagePropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(PAGE_CATEGORY)); + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC) protected AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(PAGE_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/AddSlingModelsPropertiesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddSlingModelsPropertiesContextProcessor.java index 8336f92..cdc95b0 100644 --- a/src/main/java/danta/aem/contextprocessors/AddSlingModelsPropertiesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddSlingModelsPropertiesContextProcessor.java @@ -35,7 +35,14 @@ import java.beans.IntrospectionException; import java.beans.Introspector; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import static danta.Constants.DOT; import static danta.Constants.HIGHEST_PRIORITY; @@ -56,14 +63,16 @@ public class AddSlingModelsPropertiesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(SLING_MODELS_CATEGORY)); + + @Reference + private ModelFactory modelFactory; + @Override public Set anyOf() { - return Sets.newHashSet(SLING_MODELS_CATEGORY); + return ANY_OF; } - @Reference - private ModelFactory modelFactory = null; - @Override public int priority() { return HIGHEST_PRIORITY; diff --git a/src/main/java/danta/aem/contextprocessors/AddStylingContextProcessor.java b/src/main/java/danta/aem/contextprocessors/AddStylingContextProcessor.java index ef7757a..b72c840 100644 --- a/src/main/java/danta/aem/contextprocessors/AddStylingContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/AddStylingContextProcessor.java @@ -31,6 +31,7 @@ import org.apache.sling.api.SlingHttpServletRequest; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -80,9 +81,11 @@ public class AddStylingContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(STYLING_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(STYLING_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/DeserializeJSONPropertyValuesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/DeserializeJSONPropertyValuesContextProcessor.java index 3224d02..67dbe9b 100644 --- a/src/main/java/danta/aem/contextprocessors/DeserializeJSONPropertyValuesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/DeserializeJSONPropertyValuesContextProcessor.java @@ -31,6 +31,7 @@ import org.apache.sling.api.SlingHttpServletRequest; import java.util.Collection; +import java.util.Collections; import java.util.Set; import static danta.Constants.COMPONENT_CATEGORY; @@ -76,9 +77,11 @@ public class DeserializeJSONPropertyValuesContextProcessor extends AbstractCheckComponentCategoryContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(COMPONENT_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(COMPONENT_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/images/AbstractImageContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AbstractImageContextProcessor.java index ace0e23..ae9a28a 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AbstractImageContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AbstractImageContextProcessor.java @@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; +import java.util.Collections; import java.util.Set; import static danta.Constants.IMAGE_CATEGORY; @@ -41,8 +42,10 @@ public abstract class AbstractImageContextProcessor extends AbstractCheckComponentCategoryContextProcessor implements ImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(IMAGE_CATEGORY)); + @Override public Set anyOf() { - return Sets.newHashSet(IMAGE_CATEGORY); + return ANY_OF; } } diff --git a/src/main/java/danta/aem/contextprocessors/images/AddMultipleTransformedImagePathsFromResourcesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddMultipleTransformedImagePathsFromResourcesContextProcessor.java index d43e522..ed3315d 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddMultipleTransformedImagePathsFromResourcesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddMultipleTransformedImagePathsFromResourcesContextProcessor.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -54,12 +55,14 @@ public class AddMultipleTransformedImagePathsFromResourcesContextProcessor extends AbstractImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(MULTIPLE_IMAGE_RESOURCES_CATEGORY)); + @Reference AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(MULTIPLE_IMAGE_RESOURCES_CATEGORY); + return ANY_OF; } private final Predicate IMAGE_RESOURCES_PREDICATE = new Predicate() { diff --git a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathContextProcessor.java index 1d01293..32e7c56 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathContextProcessor.java @@ -28,6 +28,7 @@ import org.apache.felix.scr.annotations.Service; import org.apache.sling.api.SlingHttpServletRequest; +import java.util.Collections; import java.util.Set; import static danta.Constants.*; @@ -45,12 +46,14 @@ public class AddTransformedImagePathContextProcessor extends AbstractImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(CONTENT_IMAGE_CATEGORY)); + @Reference AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(CONTENT_IMAGE_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromDesignContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromDesignContextProcessor.java index 2238569..b69c372 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromDesignContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromDesignContextProcessor.java @@ -32,6 +32,7 @@ import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; +import java.util.Collections; import java.util.Set; import static danta.Constants.*; @@ -49,12 +50,14 @@ public class AddTransformedImagePathFromDesignContextProcessor extends AbstractImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(DESIGN_IMAGE_CATEGORY)); + @Reference private AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(DESIGN_IMAGE_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromGlobalContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromGlobalContextProcessor.java index f9c763e..76d6569 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromGlobalContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathFromGlobalContextProcessor.java @@ -30,6 +30,7 @@ import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; +import java.util.Collections; import java.util.Set; import static danta.Constants.*; @@ -48,7 +49,9 @@ public class AddTransformedImagePathFromGlobalContextProcessor extends AbstractImageContextProcessor { - public static final String CONFIG_GLOBAL_IMAGE_KEY = CONFIG_PROPERTIES_KEY + DOT + "xk_globalImagePath"; + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(GLOBAL_IMAGE_CATEGORY)); + + private static final String CONFIG_GLOBAL_IMAGE_KEY = CONFIG_PROPERTIES_KEY + DOT + "xk_globalImagePath"; private static final String COMPONENT_GLOBAL_DIALOG_PATH = COMPONENT_PROPERTIES_KEY + DOT + GLOBAL_PATH_PROPERTY_KEY; @Reference @@ -56,7 +59,7 @@ public class AddTransformedImagePathFromGlobalContextProcessor @Override public Set anyOf() { - return Sets.newHashSet(GLOBAL_IMAGE_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathsContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathsContextProcessor.java index 33904e5..ff14241 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathsContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddTransformedImagePathsContextProcessor.java @@ -31,6 +31,7 @@ import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,12 +55,14 @@ public class AddTransformedImagePathsContextProcessor extends AbstractImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(IMAGES_BY_KEY_CATEGORY)); + @Reference AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(IMAGES_BY_KEY_CATEGORY); + return ANY_OF; } private final Predicate IMAGE_RESOURCES_PREDICATE = new Predicate() { diff --git a/src/main/java/danta/aem/contextprocessors/images/AddTransformedMultipleImagePathsContextProcessor.java b/src/main/java/danta/aem/contextprocessors/images/AddTransformedMultipleImagePathsContextProcessor.java index cd666b7..1151aed 100644 --- a/src/main/java/danta/aem/contextprocessors/images/AddTransformedMultipleImagePathsContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/images/AddTransformedMultipleImagePathsContextProcessor.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Set; import static danta.Constants.*; @@ -49,12 +50,14 @@ public class AddTransformedMultipleImagePathsContextProcessor extends AbstractImageContextProcessor { + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(MULTIPLE_IMAGE_CATEGORY)); + @Reference AssetPathService assetPathService; @Override public Set anyOf() { - return Sets.newHashSet(MULTIPLE_IMAGE_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/lists/AbstractItemListContextProcessor.java b/src/main/java/danta/aem/contextprocessors/lists/AbstractItemListContextProcessor.java index 65776e7..3a34d05 100644 --- a/src/main/java/danta/aem/contextprocessors/lists/AbstractItemListContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/lists/AbstractItemListContextProcessor.java @@ -21,10 +21,10 @@ import com.google.common.collect.Sets; import danta.api.ContentModel; import danta.core.contextprocessors.AbstractCheckComponentCategoryContextProcessor; -import danta.core.util.NumberUtils; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; +import java.util.Collections; import java.util.Set; import static danta.Constants.HIGHER_PRIORITY; @@ -43,11 +43,13 @@ public abstract class AbstractItemListContextProcessor extends AbstractCheckComponentCategoryContextProcessor implements ListContextProcessor { - protected static final int PRIORITY = NumberUtils.nextPrime(HIGHER_PRIORITY - 20); + private static final Set ANY_OF = Collections.unmodifiableSet(Sets.newHashSet(LIST_CATEGORY)); + + protected static final int PRIORITY = HIGHER_PRIORITY - 19; @Override public Set anyOf() { - return Sets.newHashSet(LIST_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/lists/AddCuratedPageReferencesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/lists/AddCuratedPageReferencesContextProcessor.java index 99a34db..b9123dd 100644 --- a/src/main/java/danta/aem/contextprocessors/lists/AddCuratedPageReferencesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/lists/AddCuratedPageReferencesContextProcessor.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.Set; @@ -45,11 +46,14 @@ public class AddCuratedPageReferencesContextProcessor extends AbstractItemListContextProcessor { + private static final Set ALL_OF = + Collections.unmodifiableSet(Sets.newHashSet(LIST_CATEGORY, CURATED_LIST_CATEGORY)); + public static final int PRIORITY = AddItemListContextProcessor.PRIORITY - 20; @Override public Set allOf() { - return Sets.newHashSet(LIST_CATEGORY, CURATED_LIST_CATEGORY); + return ALL_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/lists/AddPageDetailsContextProcessor.java b/src/main/java/danta/aem/contextprocessors/lists/AddPageDetailsContextProcessor.java index d22f87d..b8d7c5a 100644 --- a/src/main/java/danta/aem/contextprocessors/lists/AddPageDetailsContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/lists/AddPageDetailsContextProcessor.java @@ -49,16 +49,20 @@ public class AddPageDetailsContextProcessor extends AbstractPageDetailsContextProcessor { + private static final Set ALL_OF = Collections.unmodifiableSet(Sets.newHashSet(PAGE_DETAILS_CATEGORY)); + private static final Set ANY_OF = + Collections.unmodifiableSet(Sets.newHashSet(CURATED_LIST_CATEGORY, TRAVERSED_LIST_CATEGORY)); + protected static final int PRIORITY = AddCuratedPageReferencesContextProcessor.PRIORITY - 20; @Override public Set allOf() { - return Sets.newHashSet(PAGE_DETAILS_CATEGORY); + return ALL_OF; } @Override public Set anyOf() { - return Sets.newHashSet(CURATED_LIST_CATEGORY, TRAVERSED_LIST_CATEGORY); + return ANY_OF; } @Override diff --git a/src/main/java/danta/aem/contextprocessors/lists/AddTraversedPageReferencesContextProcessor.java b/src/main/java/danta/aem/contextprocessors/lists/AddTraversedPageReferencesContextProcessor.java index 3a77674..59b6360 100644 --- a/src/main/java/danta/aem/contextprocessors/lists/AddTraversedPageReferencesContextProcessor.java +++ b/src/main/java/danta/aem/contextprocessors/lists/AddTraversedPageReferencesContextProcessor.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.Set; @@ -53,11 +54,13 @@ public class AddTraversedPageReferencesContextProcessor extends AbstractItemListContextProcessor { + private static final Set ALL_OF = Collections.unmodifiableSet(Sets.newHashSet(TRAVERSED_LIST_CATEGORY)); + protected static final int PRIORITY = AddItemListContextProcessor.PRIORITY - 20; @Override public Set allOf() { - return Sets.newHashSet(TRAVERSED_LIST_CATEGORY); + return ALL_OF; } @Override