Changeset 0eebfba


Ignore:
Timestamp:
Jan 1, 2011 8:07:34 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3784908
Parents:
08a3165
Message:

generics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/XORComparator.java

    r08a3165 r0eebfba  
    1010 *
    1111 */
    12 class XORComparator implements Comparator {
     12class XORComparator implements Comparator<Hash> {
    1313    private Hash _base;
    1414    /**
     
    1818        _base = target;
    1919    }
    20     public int compare(Object lhs, Object rhs) {
     20    public int compare(Hash lhs, Hash rhs) {
    2121        if (lhs == null) throw new NullPointerException("LHS is null");
    2222        if (rhs == null) throw new NullPointerException("RHS is null");
    23         if ( (lhs instanceof Hash) && (rhs instanceof Hash) ) {
    24             byte lhsDelta[] = DataHelper.xor(((Hash)lhs).getData(), _base.getData());
    25             byte rhsDelta[] = DataHelper.xor(((Hash)rhs).getData(), _base.getData());
    26             return DataHelper.compareTo(lhsDelta, rhsDelta);
    27         } else {
    28             throw new ClassCastException(lhs.getClass().getName() + " / " + rhs.getClass().getName());
    29         }
     23        byte lhsDelta[] = DataHelper.xor(lhs.getData(), _base.getData());
     24        byte rhsDelta[] = DataHelper.xor(rhs.getData(), _base.getData());
     25        return DataHelper.compareTo(lhsDelta, rhsDelta);
    3026    }
    3127}
Note: See TracChangeset for help on using the changeset viewer.