Package org.apache.wicket.markup.head
Class PriorityFirstComparator
- java.lang.Object
-
- org.apache.wicket.markup.head.PriorityFirstComparator
-
- All Implemented Interfaces:
Serializable
,Comparator<ResourceAggregator.RecordedHeaderItem>
public class PriorityFirstComparator extends Object implements Comparator<ResourceAggregator.RecordedHeaderItem>, Serializable
Implements the default sorting algorithm forHeaderItem
s.PriorityHeaderItem
s are moved to the front, inverting the component order to convert the child-first into a parent-first order. IfrenderPageFirst
is 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 class
PriorityFirstComparator.HeaderItemType
-
Constructor Summary
Constructors Constructor Description PriorityFirstComparator(boolean renderPageFirst)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)
protected int
compareWithinGroup(ResourceAggregator.RecordedHeaderItem item1, ResourceAggregator.RecordedHeaderItem item2)
Compares two header items that belong in the same group.protected PriorityFirstComparator.HeaderItemType
getItemType(ResourceAggregator.RecordedHeaderItem item)
Determines the type of the item: priority, page or component.protected int
inversedComponentOrder(ResourceAggregator.RecordedHeaderItem item1, ResourceAggregator.RecordedHeaderItem item2)
Compare two recordedPriorityHeaderItem
s, converting the child-first order into parent-first.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
PriorityFirstComparator
public PriorityFirstComparator(boolean renderPageFirst)
Construct.- Parameters:
renderPageFirst
- when true, the header of the page is moved to the front.
-
-
Method Detail
-
compare
public int compare(ResourceAggregator.RecordedHeaderItem o1, ResourceAggregator.RecordedHeaderItem o2)
- Specified by:
compare
in interfaceComparator<ResourceAggregator.RecordedHeaderItem>
-
compareWithinGroup
protected int compareWithinGroup(ResourceAggregator.RecordedHeaderItem item1, ResourceAggregator.RecordedHeaderItem item2)
Compares two header items that belong in the same group.- Parameters:
item1
-item2
-- Returns:
- 0 by default to preserve the order
-
inversedComponentOrder
protected int inversedComponentOrder(ResourceAggregator.RecordedHeaderItem item1, ResourceAggregator.RecordedHeaderItem item2)
Compare two recordedPriorityHeaderItem
s, converting the child-first order into parent-first.- Parameters:
item1
- first itemitem2
- second item- Returns:
- -1, 0 or 1 if item1 needs to be rendered before, unchanged or after item2.
- See Also:
ResourceAggregator.RecordedHeaderItemLocation.getDepth()
-
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
-
-