- java.lang.Object
-
- org.snmp4j.agent.MOScopeComparator
-
- All Implemented Interfaces:
Comparator<MOScope>
- Direct Known Subclasses:
MOScopePriorityComparator
public class MOScopeComparator extends Object implements Comparator<MOScope>
TheMOScopeComparator
compares two scopes with each other.Two scopes are compared by their context (if both are
MOContextScope
instances) first and then by their lower bound.A scope is compared with a query by comparing the scope with the queries scope and then if both are deemed to be equal, the upper bound of the scope is checked. If it is unbounded (upper bound is
null
, then the scoped is deemed to be greater than the query. Otherwise, the upper bound of the scope is compared with the lower bound of the query. Scope and query are deemed to be equal if both bounds are equal and both are included. Otherwise the scope is deemed to be less than the query.- Version:
- 1.0
- Author:
- Frank Fock
-
-
Constructor Summary
Constructors Constructor Description MOScopeComparator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(MOScope o1, MOScope o2)
Compares a scope with another scope or query.boolean
equals(Object obj)
int
hashCode()
static boolean
isQueryContextMatching(MOQuery a, MOScope b)
Indicates whether the given query's context matches the context of the given scope.-
Methods inherited from interface java.util.Comparator
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
compare
public int compare(MOScope o1, MOScope o2)
Compares a scope with another scope or query. See also the class description how comparison is done.- Specified by:
compare
in interfaceComparator<MOScope>
- Parameters:
o1
- a MOScope instance.o2
- a MOScope instance.- Returns:
- an integer less than zero if
o1
is less thano2
and zero if both values are deemed to be equal and a value greater than zero ifo1
is greater thano2
.
-
isQueryContextMatching
public static boolean isQueryContextMatching(MOQuery a, MOScope b)
Indicates whether the given query's context matches the context of the given scope.- Parameters:
a
- a MOQuery instance.b
- another MOScope instance.- Returns:
true
if the query's context isnull
or if both contexts match or if the context ofscope
is the empty string.- Since:
- 2.0.2
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in interfaceComparator<MOScope>
- Overrides:
equals
in classObject
-
-