Name TreeFilter and MergeFilter implementations

Naming these inner classes ensures that stack traces which contain
them will give us useful information about which filter is involved in
the trace, rather than the generated names $1, $2, etc.  This makes it
much easier to understand a stack trace at a glance.

Change-Id: Ia6a75fdb382ff6461e02054d94baf011bdeee5aa
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-11-18 16:50:14 -08:00
parent 2054c3fb8a
commit 3de186fbf0
2 changed files with 24 additions and 12 deletions

View File

@ -94,7 +94,9 @@
*/
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;
@ -109,10 +111,12 @@ public RevFilter clone() {
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;
@ -127,10 +131,12 @@ public RevFilter clone() {
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;
@ -145,7 +151,7 @@ public RevFilter clone() {
public String toString() {
return "NO_MERGES";
}
};
}
/**
* Selects only merge bases of the starting points (thread safe).
@ -155,7 +161,9 @@ public String toString() {
* 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);
@ -170,7 +178,7 @@ public RevFilter clone() {
public String toString() {
return "MERGE_BASE";
}
};
}
/**
* Create a new filter that does the opposite of this filter.

View File

@ -84,7 +84,9 @@
*/
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;
@ -104,7 +106,7 @@ public TreeFilter clone() {
public String toString() {
return "ALL";
}
};
}
/**
* Selects only tree entries which differ between at least 2 trees.
@ -119,7 +121,9 @@ public String toString() {
* 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
@ -149,7 +153,7 @@ public TreeFilter clone() {
public String toString() {
return "ANY_DIFF";
}
};
}
/**
* Create a new filter that does the opposite of this filter.