org.jboss.classloading.spi.version
Class VersionComparatorRegistry

java.lang.Object
  extended by org.jboss.classloading.spi.version.VersionComparatorRegistry

public class VersionComparatorRegistry
extends Object

Version comparator registry.

Author:
Ales Justin, Adrian Brock

Constructor Summary
VersionComparatorRegistry()
          Create a new VersionComparatorRegistry.
 
Method Summary
<T,U> int
compare(T t, U u)
          Compare two version impls.
<T,U> VersionComparator<T,U>
getComparator(Class<T> t, Class<U> u)
          Get the comparator.
protected
<T,U> VersionComparator<T,U>
getComparator(T t, U u)
          Get the comparator.
static VersionComparatorRegistry getInstance()
          Get the singleton
<T,U> void
registerVersionComparator(Class<T> t, Class<U> u, VersionComparator<T,U> comparator)
          Register version comparator.
<T> void
registerVersionComparator(Class<T> t, VersionComparator<T,T> comparator)
          Register version comparator.
<T> void
removeVersionComparator(Class<T> t)
          Remove the version comparator.
<T,U> void
removeVersionComparator(Class<T> t, Class<U> u)
          Remove the version comparator.
<T,U> boolean
same(T t, U u)
          Test whether two version impls are request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionComparatorRegistry

public VersionComparatorRegistry()
Create a new VersionComparatorRegistry.

Method Detail

getInstance

public static VersionComparatorRegistry getInstance()
Get the singleton

Returns:
the singleton

removeVersionComparator

public <T,U> void removeVersionComparator(Class<T> t,
                                          Class<U> u)
Remove the version comparator.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - first version impl
u - second version impl

removeVersionComparator

public <T> void removeVersionComparator(Class<T> t)
Remove the version comparator.

Type Parameters:
T - the version type
Parameters:
t - version impl

registerVersionComparator

public <T> void registerVersionComparator(Class<T> t,
                                          VersionComparator<T,T> comparator)
Register version comparator. If comparator parameter is null, it's actually a removal.

Type Parameters:
T - the version type
Parameters:
t - version impl
comparator - the version comparator

registerVersionComparator

public <T,U> void registerVersionComparator(Class<T> t,
                                            Class<U> u,
                                            VersionComparator<T,U> comparator)
Register version comparator. If comparator parameter is null, it's actually a removal.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - first version impl
u - second version impl
comparator - the version comparator

getComparator

protected <T,U> VersionComparator<T,U> getComparator(T t,
                                                     U u)
Get the comparator.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - first version impl
u - second version impl
Returns:
the matching comparator

getComparator

public <T,U> VersionComparator<T,U> getComparator(Class<T> t,
                                                  Class<U> u)
Get the comparator.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - first version impl class
u - second version impl class
Returns:
the matching comparator

compare

public <T,U> int compare(T t,
                         U u)
Compare two version impls.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - the first version
u - the second version
Returns:
the compare result

same

public <T,U> boolean same(T t,
                          U u)
Test whether two version impls are request.

Type Parameters:
T - the first version type
U - the second version type
Parameters:
t - T version impl
u - U version impl
Returns:
the compare result


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.