Changeset 8770d7e


Ignore:
Timestamp:
Nov 26, 2013 9:09:36 PM (7 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
8fd2f909
Parents:
c59ef24
Message:

i2psnark: Comparable type arguments

Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/PartialPiece.java

    rc59ef24 r8770d7e  
    3232 * @since 0.8.2
    3333 */
    34 class PartialPiece implements Comparable {
     34class PartialPiece implements Comparable<PartialPiece> {
    3535
    3636    // we store the piece so we can use it in compareTo()
     
    296296     *  then highest downloaded first
    297297     */
    298     public int compareTo(Object o) throws ClassCastException {
    299         PartialPiece opp = (PartialPiece)o;
     298    public int compareTo(PartialPiece opp) {
    300299        int d = this.piece.compareTo(opp.piece);
    301300        if (d != 0)
  • apps/i2psnark/java/src/org/klomp/snark/Peer.java

    rc59ef24 r8770d7e  
    4040import org.klomp.snark.bencode.BEValue;
    4141
    42 public class Peer implements Comparable
     42public class Peer implements Comparable<Peer>
    4343{
    4444  private final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(Peer.class);
     
    195195   * @deprecated unused?
    196196   */
    197   public int compareTo(Object o)
     197  public int compareTo(Peer o)
    198198  {
    199199    Peer p = (Peer)o;
  • apps/i2psnark/java/src/org/klomp/snark/PeerID.java

    rc59ef24 r8770d7e  
    4343 *  Equality is now determined solely by the dest hash.
    4444 */
    45 class PeerID implements Comparable
     45class PeerID implements Comparable<PeerID>
    4646{
    4747  private byte[] id;
     
    7777   * port.
    7878   */
    79   public PeerID(Map m)
     79  public PeerID(Map<String, BEValue> m)
    8080    throws InvalidBEncodingException, UnknownHostException
    8181  {
    82     BEValue bevalue = (BEValue)m.get("peer id");
     82    BEValue bevalue = m.get("peer id");
    8383    if (bevalue == null)
    8484      throw new InvalidBEncodingException("peer id missing");
    8585    id = bevalue.getBytes();
    8686
    87     bevalue = (BEValue)m.get("ip");
     87    bevalue = m.get("ip");
    8888    if (bevalue == null)
    8989      throw new InvalidBEncodingException("ip missing");
     
    196196   * @deprecated unused? and will NPE now that address can be null?
    197197   */
    198   public int compareTo(Object o)
    199   {
    200     PeerID pid = (PeerID)o;
    201 
     198  public int compareTo(PeerID pid)
     199  {
    202200    int result = port - pid.port;
    203201    if (result != 0)
  • apps/i2psnark/java/src/org/klomp/snark/Piece.java

    rc59ef24 r8770d7e  
    88 * Caller must synchronize on many of these methods.
    99 */
    10 class Piece implements Comparable {
     10class Piece implements Comparable<Piece> {
    1111
    1212    private final int id;
     
    2727     *  then rarest first
    2828     */
    29     public int compareTo(Object o) throws ClassCastException {
    30         int pdiff = ((Piece)o).priority - this.priority;   // reverse
     29    public int compareTo(Piece op) {
     30        int pdiff = op.priority - this.priority;   // reverse
    3131        if (pdiff != 0)
    3232            return pdiff;
    33         return this.peers.size() - ((Piece)o).peers.size();
     33        return this.peers.size() - op.peers.size();
    3434    }
    3535   
Note: See TracChangeset for help on using the changeset viewer.