*/
public abstract class RevFilter {
/** Default filter that always returns true (thread safe). */
- public static final RevFilter ALL = new RevFilter() {
+ public static final RevFilter ALL = new AllFilter();
+
+ private static final class AllFilter extends RevFilter {
@Override
public boolean include(final RevWalk walker, final RevCommit c) {
return true;
public String toString() {
return "ALL";
}
- };
+ }
/** Default filter that always returns false (thread safe). */
- public static final RevFilter NONE = new RevFilter() {
+ public static final RevFilter NONE = new NoneFilter();
+
+ private static final class NoneFilter extends RevFilter {
@Override
public boolean include(final RevWalk walker, final RevCommit c) {
return false;
public String toString() {
return "NONE";
}
- };
+ }
/** Excludes commits with more than one parent (thread safe). */
- public static final RevFilter NO_MERGES = new RevFilter() {
+ public static final RevFilter NO_MERGES = new NoMergesFilter();
+
+ private static final class NoMergesFilter extends RevFilter {
@Override
public boolean include(final RevWalk walker, final RevCommit c) {
return c.getParentCount() < 2;
public String toString() {
return "NO_MERGES";
}
- };
+ }
/**
* Selects only merge bases of the starting points (thread safe).
* information beyond the arguments is necessary to determine if the
* supplied commit is a merge base.
*/
- public static final RevFilter MERGE_BASE = new RevFilter() {
+ public static final RevFilter MERGE_BASE = new MergeBaseFilter();
+
+ private static final class MergeBaseFilter extends RevFilter {
@Override
public boolean include(final RevWalk walker, final RevCommit c) {
throw new UnsupportedOperationException(JGitText.get().cannotBeCombined);
public String toString() {
return "MERGE_BASE";
}
- };
+ }
/**
* Create a new filter that does the opposite of this filter.
*/
public abstract class TreeFilter {
/** Selects all tree entries. */
- public static final TreeFilter ALL = new TreeFilter() {
+ public static final TreeFilter ALL = new AllFilter();
+
+ private static final class AllFilter extends TreeFilter {
@Override
public boolean include(final TreeWalk walker) {
return true;
public String toString() {
return "ALL";
}
- };
+ }
/**
* Selects only tree entries which differ between at least 2 trees.
* against the single tree it was actually given. Applications may wish to
* treat such a difference as "all names added".
*/
- public static final TreeFilter ANY_DIFF = new TreeFilter() {
+ public static final TreeFilter ANY_DIFF = new AnyDiffFilter();
+
+ private static final class AnyDiffFilter extends TreeFilter {
private static final int baseTree = 0;
@Override
public String toString() {
return "ANY_DIFF";
}
- };
+ }
/**
* Create a new filter that does the opposite of this filter.