Package org.apache.wicket.markup.head
Class PriorityFirstComparator
- java.lang.Object
-
- org.apache.wicket.markup.head.PriorityFirstComparator
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator<ResourceAggregator.RecordedHeaderItem>
public class PriorityFirstComparator extends java.lang.Object implements java.util.Comparator<ResourceAggregator.RecordedHeaderItem>, java.io.Serializable
Implements the default sorting algorithm forHeaderItems.PriorityHeaderItems are moved to the front, inverting the component order to convert the child-first into a parent-first order. IfrenderPageFirstis true, the head from the markup of a page is moved to the front of the header, directly after the priority header items.- Author:
- papegaaij
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPriorityFirstComparator.HeaderItemType
-
Constructor Summary
Constructors Constructor Description PriorityFirstComparator(boolean renderPageFirst)Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)protected intcompareWithinGroup(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)Compares two header items that belong in the same group.protected PriorityFirstComparator.HeaderItemTypegetItemType(ResourceAggregator.RecordedHeaderItem item)Determines the type of the item: priority, page or component.protected intinversedComponentOrder(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)Compares two priority header items, converting the child-first order into parent-first.
-
-
-
Method Detail
-
compare
public int compare(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)
- Specified by:
comparein interfacejava.util.Comparator<ResourceAggregator.RecordedHeaderItem>
-
compareWithinGroup
protected int compareWithinGroup(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)
Compares two header items that belong in the same group.- Parameters:
o1-o2-- Returns:
- 0 by default to preserve the order
-
inversedComponentOrder
protected int inversedComponentOrder(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)
Compares two priority header items, converting the child-first order into parent-first.- Parameters:
o1-o2-- Returns:
- -1, 0 or 1 if o1 needs to be rendered before, unchanged or after o2.
-
getItemType
protected PriorityFirstComparator.HeaderItemType getItemType(ResourceAggregator.RecordedHeaderItem item)
Determines the type of the item: priority, page or component.- Parameters:
item-- Returns:
- the type of the item
-
-