Browse Source

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>
stable-0.10
Shawn O. Pearce 14 years ago
parent
commit
3de186fbf0
  1. 24
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java
  2. 12
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java

24
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/filter/RevFilter.java

@ -94,7 +94,9 @@ import org.eclipse.jgit.revwalk.RevWalk;
*/ */
public abstract class RevFilter { public abstract class RevFilter {
/** Default filter that always returns true (thread safe). */ /** 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 @Override
public boolean include(final RevWalk walker, final RevCommit c) { public boolean include(final RevWalk walker, final RevCommit c) {
return true; return true;
@ -109,10 +111,12 @@ public abstract class RevFilter {
public String toString() { public String toString() {
return "ALL"; return "ALL";
} }
}; }
/** Default filter that always returns false (thread safe). */ /** 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 @Override
public boolean include(final RevWalk walker, final RevCommit c) { public boolean include(final RevWalk walker, final RevCommit c) {
return false; return false;
@ -127,10 +131,12 @@ public abstract class RevFilter {
public String toString() { public String toString() {
return "NONE"; return "NONE";
} }
}; }
/** Excludes commits with more than one parent (thread safe). */ /** 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 @Override
public boolean include(final RevWalk walker, final RevCommit c) { public boolean include(final RevWalk walker, final RevCommit c) {
return c.getParentCount() < 2; return c.getParentCount() < 2;
@ -145,7 +151,7 @@ public abstract class RevFilter {
public String toString() { public String toString() {
return "NO_MERGES"; return "NO_MERGES";
} }
}; }
/** /**
* Selects only merge bases of the starting points (thread safe). * Selects only merge bases of the starting points (thread safe).
@ -155,7 +161,9 @@ public abstract class RevFilter {
* information beyond the arguments is necessary to determine if the * information beyond the arguments is necessary to determine if the
* supplied commit is a merge base. * 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 @Override
public boolean include(final RevWalk walker, final RevCommit c) { public boolean include(final RevWalk walker, final RevCommit c) {
throw new UnsupportedOperationException(JGitText.get().cannotBeCombined); throw new UnsupportedOperationException(JGitText.get().cannotBeCombined);
@ -170,7 +178,7 @@ public abstract class RevFilter {
public String toString() { public String toString() {
return "MERGE_BASE"; return "MERGE_BASE";
} }
}; }
/** /**
* Create a new filter that does the opposite of this filter. * Create a new filter that does the opposite of this filter.

12
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/TreeFilter.java

@ -84,7 +84,9 @@ import org.eclipse.jgit.treewalk.TreeWalk;
*/ */
public abstract class TreeFilter { public abstract class TreeFilter {
/** Selects all tree entries. */ /** 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 @Override
public boolean include(final TreeWalk walker) { public boolean include(final TreeWalk walker) {
return true; return true;
@ -104,7 +106,7 @@ public abstract class TreeFilter {
public String toString() { public String toString() {
return "ALL"; return "ALL";
} }
}; }
/** /**
* Selects only tree entries which differ between at least 2 trees. * Selects only tree entries which differ between at least 2 trees.
@ -119,7 +121,9 @@ public abstract class TreeFilter {
* against the single tree it was actually given. Applications may wish to * against the single tree it was actually given. Applications may wish to
* treat such a difference as "all names added". * 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; private static final int baseTree = 0;
@Override @Override
@ -149,7 +153,7 @@ public abstract class TreeFilter {
public String toString() { public String toString() {
return "ANY_DIFF"; return "ANY_DIFF";
} }
}; }
/** /**
* Create a new filter that does the opposite of this filter. * Create a new filter that does the opposite of this filter.

Loading…
Cancel
Save