All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bt.torrent.messaging.IncompletePiecesValidator Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package bt.torrent.messaging;

import bt.data.Bitfield;

import java.util.function.Predicate;

public class IncompletePiecesValidator implements Predicate {

    private Bitfield bitfield;

    public IncompletePiecesValidator(Bitfield bitfield) {
        this.bitfield = bitfield;
    }

    @Override
    public boolean test(Integer pieceIndex) {
        return !isComplete(pieceIndex);
    }

    private boolean isComplete(Integer pieceIndex) {
        Bitfield.PieceStatus pieceStatus = bitfield.getPieceStatus(pieceIndex);
        return pieceStatus == Bitfield.PieceStatus.COMPLETE || pieceStatus == Bitfield.PieceStatus.COMPLETE_VERIFIED;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy