org.ungoverned.moduleloader.search.compatibility
Class ExactCompatibilityPolicy
java.lang.Object
org.ungoverned.moduleloader.search.compatibility.ExactCompatibilityPolicy
- All Implemented Interfaces:
- CompatibilityPolicy
- public class ExactCompatibilityPolicy
- extends java.lang.Object
- implements CompatibilityPolicy
This class implements a simple version numbering compatibility policy for the
ImportSearchPolicy where only exact version numbers are considered
to be compatible. This policy simply returns the result of
"leftId.equals(rightId) && leftVersion.equals(rightVersion)". Any
calls to the compare() method result in an exception since this
policy has no basis for comparing identifiers and versions.
- See Also:
CompatibilityPolicy
,
ImportSearchPolicy
Method Summary |
int |
compare(java.lang.Object leftId,
java.lang.Object leftVersion,
java.lang.Object rightId,
java.lang.Object rightVersion)
Compares two versioned identifiers, but since this policy has
no understanding of how to compare identifiers, it always throws
an IllegalArgumentException. |
boolean |
isCompatible(java.lang.Object leftId,
java.lang.Object leftVersion,
java.lang.Object rightId,
java.lang.Object rightVersion)
Returns whether the first import/export target is compatible
with the second. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExactCompatibilityPolicy
public ExactCompatibilityPolicy()
compare
public int compare(java.lang.Object leftId,
java.lang.Object leftVersion,
java.lang.Object rightId,
java.lang.Object rightVersion)
- Compares two versioned identifiers, but since this policy has
no understanding of how to compare identifiers, it always throws
an IllegalArgumentException.
- Specified by:
compare
in interface CompatibilityPolicy
- Parameters:
leftId
- the identifier to test for compatibility.leftVersion
- the version number to test for compatibility.rightId
- the identifier used as the compatibility base line.rightVersion
- the version used as the compatibility base line.
- Returns:
- 0 if the identifiers are equal, -1 if the
left identifier is less then the right identifier, and 1
if the left identifier is greater than the right identifier.
- Throws:
java.lang.IllegalArgumentException
- if the two identifiers
are not comparable, i.e., they refer to completely different
entities.
isCompatible
public boolean isCompatible(java.lang.Object leftId,
java.lang.Object leftVersion,
java.lang.Object rightId,
java.lang.Object rightVersion)
- Returns whether the first import/export target is compatible
with the second. This method simply uses the "equals()" method
to test both the identifier and the verison number.
- Specified by:
isCompatible
in interface CompatibilityPolicy
- Parameters:
leftId
- the identifier to test for compatibility.leftVersion
- the version number to test for compatibility.rightId
- the identifier used as the compatibility base line.rightVersion
- the version used as the compatibility base line.
- Returns:
- true if the left version number object is compatible
with the right version number object, otherwise false.