java.lang.Object
io.helidon.grpc.core.PriorityBag<T>
- Type Parameters:
T
- the type of elements in the bag
- All Implemented Interfaces:
Iterable<T>
A bag of values ordered by priority.
An element with lower priority number is more significant than an element with a higher priority number.
For cases where priority is the same, elements are ordered in the order that they were added to the bag.
Elements added with negative priorities are assumed to have no priority and will be least significant in order.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an element to the bag.void
Add an element to the bag with a specific priority.void
Add elements to the bag.void
Add elements to the bag.copyMe()
Obtain a copy of thisPriorityBag
.static <T> PriorityBag<T>
create()
Create a newPriorityBag
where elements added with no priority will be last in the order.iterator()
void
merge
(PriorityBag<? extends T> bag) Merge aPriorityBag
into thisPriorityBag
.readOnly()
Obtain an immutable copy of thisPriorityBag
.stream()
Obtain the contents of thisPriorityBag
as an orderedStream
.static <T> PriorityBag<T>
withDefaultPriority
(int priority) Create a newPriorityBag
where elements added with no priority will be be given a default priority value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
create
Create a newPriorityBag
where elements added with no priority will be last in the order.- Type Parameters:
T
- the type of elements in the bag- Returns:
- a new
PriorityBag
where elements dded with no priority will be last in the order
-
withDefaultPriority
Create a newPriorityBag
where elements added with no priority will be be given a default priority value.- Type Parameters:
T
- the type of elements in the bag- Parameters:
priority
- the default priority value to assign to elements added with no priority- Returns:
- a new
PriorityBag
where elements added with no priority will be be given a default priority value
-
copyMe
Obtain a copy of thisPriorityBag
.- Returns:
- a copy of this
PriorityBag
-
readOnly
Obtain an immutable copy of thisPriorityBag
.- Returns:
- an immutable copy of this
PriorityBag
-
merge
Merge aPriorityBag
into thisPriorityBag
.- Parameters:
bag
- the bag to merge
-
addAll
Add elements to the bag.If the element's class is annotated with the
Priority
annotation then that value will be used to determine priority otherwise the default priority value will be used.- Parameters:
values
- the elements to add
-
addAll
Add elements to the bag.- Parameters:
values
- the elements to addpriority
- the priority to assign to the elements
-
add
Add an element to the bag.If the element's class is annotated with the
Priority
annotation then that value will be used to determine priority otherwise the default priority value will be used.- Parameters:
value
- the element to add
-
add
Add an element to the bag with a specific priority.- Parameters:
value
- the element to addpriority
- the priority of the element
-
stream
Obtain the contents of thisPriorityBag
as an orderedStream
.- Returns:
- the contents of this
PriorityBag
as an orderedStream
-
iterator
-