com.selesse.jxlint.model.LintErrorOrderings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jxlint Show documentation
Show all versions of jxlint Show documentation
Framework for doing static analysis in Java
The newest version!
package com.selesse.jxlint.model;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
import com.google.common.primitives.Ints;
import com.selesse.jxlint.model.rules.LintError;
import javax.annotation.Nullable;
public class LintErrorOrderings {
private static Ordering lineNumberOrdering = new Ordering() {
@Override
public int compare(@Nullable LintError left, @Nullable LintError right) {
return Ints.compare(left.getLineNumber(), right.getLineNumber());
}
};
private static Ordering categoryNameOrdering = new Ordering() {
@Override
public int compare(@Nullable LintError left, @Nullable LintError right) {
return LintRuleOrderings.getCategoryThenNameOrdering().
compare(left.getViolatedRule(), right.getViolatedRule());
}
};
private static Ordering categoryNameFileLineNumberOrdering = new Ordering() {
@Override
public int compare(@Nullable LintError left, @Nullable LintError right) {
return ComparisonChain.start()
.compare(left.getViolatedRule(), right.getViolatedRule(),
LintRuleOrderings.getCategoryThenNameOrdering())
.compare(left.getFile(), right.getFile())
.compare(left.getLineNumber(), right.getLineNumber())
.result();
}
};
private static final Ordering fileThenLineNumberOrdering = new Ordering() {
@Override
public int compare(@Nullable LintError left, @Nullable LintError right) {
return ComparisonChain.start()
.compare(left.getFile(), right.getFile())
.compare(left.getLineNumber(), right.getLineNumber())
.result();
}
};
public static Ordering getLineNumberOrdering() {
return lineNumberOrdering;
}
public static Ordering getCategoryThenNameOrdering() {
return categoryNameOrdering;
}
public static Ordering getCategoryNameFileLineNumberOrdering() {
return categoryNameFileLineNumberOrdering;
}
public static Ordering getFileThenLineNumberOrdering() {
return fileThenLineNumberOrdering;
}
}