Example usage for com.google.common.collect SortedArraySet SortedArraySet

List of usage examples for com.google.common.collect SortedArraySet SortedArraySet

Introduction

In this page you can find the example usage for com.google.common.collect SortedArraySet SortedArraySet.

Prototype

public SortedArraySet(SortedSet<E> set) 

Source Link

Document

Creates a new sorted set with the same elements and the same ordering as the specified sorted set.

Usage

From source file:org.hardisonbrewing.clover.ReductMojo.java

private generated.File reduceFile(generated.File file) throws Exception {

    String filePath = file.getPath();
    if (!new File(filePath).exists()) {
        throw new FileNotFoundException(filePath);
    }//from ww  w  .  j a v a  2  s.c  o  m

    Properties properties = info(filePath);
    long revision = Long.parseLong(properties.getProperty("Revision"));
    if (revision < cutoffRevision) {
        return null;
    }

    generated.File fileReduced = null;
    Set<Line> sortedLines = null;

    List<Long> revisions = blame(file.getPath());

    for (Line line : file.getLine()) {

        int lineNumber = line.getNum();
        if (cutoffRevision >= revisions.get(lineNumber - 1)) {
            continue;
        }

        if (fileReduced == null) {
            fileReduced = new generated.File();
            fileReduced.setMetrics(new FileMetrics());
            fileReduced.setName(file.getName());
            fileReduced.setPath(file.getPath());
            sortedLines = new SortedArraySet<Line>(new LineComparator());
        }

        addMetrics(fileReduced, line);
        sortedLines.add(line);
    }

    if (fileReduced != null) {
        List<Line> lines = fileReduced.getLine();
        lines.addAll(sortedLines);
    }

    return fileReduced;
}