Added ordering
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.exadel.aem.toolkit.plugin.handlers.widget.common;
import java.lang.annotation.Annotation;
@@ -34,6 +35,7 @@ import com.exadel.aem.toolkit.api.handlers.Source;
import com.exadel.aem.toolkit.api.handlers.Target;
import com.exadel.aem.toolkit.plugin.maven.PluginRuntime;
import com.exadel.aem.toolkit.plugin.util.PluginReflectionUtility;
+import com.exadel.aem.toolkit.plugin.util.ordering.PluginOrderingUtility;
/**
* Stores properties coming from custom annotations and, optionally, processed by custom handlers
@@ -63,7 +65,7 @@ public class CustomHandlingHandler implements BiConsumer<Source, Target> {
.collect(Collectors.toList());
handlers.addAll(sourceToNameMappingHandlers);
- // Extract legacy handlers that accept(Source, Target)
+ // Extract legacy handlers that accept(Element, Field)
List<DialogWidgetHandler> legacyHandlers = handlers.stream().filter(CustomHandlingHandler::isLegacyHandler).collect(Collectors.toList());
if (!legacyHandlers.isEmpty()) {
Field field = source.adaptTo(Field.class);
@@ -76,9 +78,9 @@ public class CustomHandlingHandler implements BiConsumer<Source, Target> {
}
}
- // Process modern handlers that accept(Element, Field)
+ // Process modern handlers that accept(Source, Target)
Collection<DialogWidgetHandler> modernHandlers = CollectionUtils.subtract(handlers, legacyHandlers);
- modernHandlers.forEach(handler -> handler.accept(source, target));
+ PluginOrderingUtility.orderList(new ArrayList<>(modernHandlers)).forEach(handler -> handler.accept(source, target));
}
private static Stream<DialogWidgetHandler> getMatchedHandlersByName(String source) {
