public final class ConfigSourceComparator extends Object implements Comparator<ConfigSource>
Comparator
of ConfigSource
s that considers only
their ordinals and
names in accordance with the
minimal requirements of the MicroProfile Config specification as
spelled out (only) in the ConfigSource
API documentation.
This Comparator
implementation is, and must be,
inconsistent with equals()
,
as implied by the same specification.
Note that the requirement to use a ConfigSource
's
name as a secondary sorting key
is defined only in the javadocs of the ConfigSource.getOrdinal()
method.
Note further that there are no guidelines or requirements about
what format a ConfigSource
's name must take, so in effect the ordering
of two ConfigSource
s that have a common ordinal is undefined.
Modifier and Type | Field and Description |
---|---|
static ConfigSourceComparator |
INSTANCE
The sole instance of this class.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(ConfigSource firstConfigSource,
ConfigSource secondConfigSource)
Compares two
ConfigSource s, returning -1 if the
first has an ordinal
greater than that of the second and 1 if the second has
an ordinal greater than
that of the first, and then the result of invoking String.compareTo(String) on the return values of the ConfigSource s' respective ConfigSource.getName()
methods. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public static final ConfigSourceComparator INSTANCE
public final int compare(ConfigSource firstConfigSource, ConfigSource secondConfigSource)
ConfigSource
s, returning -1
if the
first has an ordinal
greater than that of the second and 1
if the second has
an ordinal greater than
that of the first, and then the result of invoking String.compareTo(String)
on the return values of the ConfigSource
s' respective ConfigSource.getName()
methods.
This method may return 0
when both ConfigSource
s are not otherwise semantically equal.
compare
in interface Comparator<ConfigSource>
firstConfigSource
- the first of two ConfigSource
s;
may be null
secondConfigSource
- the second of two ConfigSource
s; may be null
-1
if the first ConfigSource
has an
ordinal greater than that
of the second, 1
if the second ConfigSource
has
an ordinal greater than
that of the first, and the result of invoking String.compareTo(String)
on the return values of the ConfigSource
s' respective ConfigSource.getName()
methods
otherwiseConfigSource
,
ConfigSource.getName()
,
ConfigSource.getOrdinal()
Copyright © 2019–2021, microBean™. All rights reserved.