private boolean isBuildTarget(Pullrequest pullRequest) {
    if (pullRequest.getState() != null && pullRequest.getState().equals("OPEN")) {
      if (isSkipBuild(pullRequest.getTitle()) || !isFilteredBuild(pullRequest)) {
        return false;
      }

      Pullrequest.Revision source = pullRequest.getSource();
      String sourceCommit = source.getCommit().getHash();
      Pullrequest.Revision destination = pullRequest.getDestination();
      String owner = destination.getRepository().getOwnerName();
      String repositoryName = destination.getRepository().getRepositoryName();

      Pullrequest.Repository sourceRepository = source.getRepository();
      String buildKeyPart = this.builder.getProjectId();

      final boolean commitAlreadyBeenProcessed =
          this.client.hasBuildStatus(
              sourceRepository.getOwnerName(),
              sourceRepository.getRepositoryName(),
              sourceCommit,
              buildKeyPart);
      if (commitAlreadyBeenProcessed)
        logger.log(
            Level.INFO,
            "Commit {0}#{1} has already been processed",
            new Object[] {sourceCommit, buildKeyPart});

      final String id = pullRequest.getId();
      List<Pullrequest.Comment> comments = client.getPullRequestComments(owner, repositoryName, id);

      boolean rebuildCommentAvailable = false;
      if (comments != null) {
        Collection<Pullrequest.Comment> filteredComments = this.filterPullRequestComments(comments);
        for (Pullrequest.Comment comment : filteredComments) {
          String content = comment.getContent();
          if (this.isTTPComment(content)) {
            rebuildCommentAvailable = true;
            logger.log(
                Level.INFO,
                "Rebuild comment available for commit {0} and comment #{1}",
                new Object[] {sourceCommit, comment.getId()});
          }
          rebuildCommentAvailable &= this.processTTPCommentBuildTags(content, buildKeyPart);
          if (!rebuildCommentAvailable) break;
        }
      }
      if (rebuildCommentAvailable)
        this.postBuildTagInTTPComment(id, "TTP build flag", buildKeyPart);

      final boolean canBuildTarget = rebuildCommentAvailable || !commitAlreadyBeenProcessed;
      logger.log(
          Level.INFO,
          "Build target? {0} [rebuild:{1} processed:{2}]",
          new Object[] {canBuildTarget, rebuildCommentAvailable, commitAlreadyBeenProcessed});
      return canBuildTarget;
    }

    return false;
  }
 public Collection<Pullrequest> getTargetPullRequests() {
   logger.info("Fetch PullRequests.");
   List<Pullrequest> pullRequests = client.getPullRequests();
   List<Pullrequest> targetPullRequests = new ArrayList<Pullrequest>();
   for (Pullrequest pullRequest : pullRequests) {
     if (isBuildTarget(pullRequest)) {
       targetPullRequests.add(pullRequest);
     }
   }
   return targetPullRequests;
 }