Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2015-12-01 12:33:45 -0500
committerBrian Vosburgh2015-12-01 12:33:45 -0500
commit721607b8b6ec01789a6d769035ae17019c1cbcae (patch)
tree8f30efecd6383b6f6ccb77153e57daa4a45ff1cb
parent8fac72e2d9ac4e6ff1e89bc2cb51ce02e4445c20 (diff)
downloadwebtools.dali-721607b8b6ec01789a6d769035ae17019c1cbcae.tar.gz
webtools.dali-721607b8b6ec01789a6d769035ae17019c1cbcae.tar.xz
webtools.dali-721607b8b6ec01789a6d769035ae17019c1cbcae.zip
add ClassTools.allInstanceFields(...)
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassTools.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassTools.java
index e5dfc32dd5..37b31557cb 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassTools.java
@@ -19,6 +19,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateAdapter;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
+import org.eclipse.jpt.common.utility.predicate.Predicate;
/**
* {@link Class} utility methods.
@@ -290,6 +293,27 @@ public final class ClassTools {
}
/**
+ * Return all the instance (non-static) fields for the
+ * specified class, including inherited fields.
+ * Make any private/package/protected fields accessible.
+ * @see Class#getDeclaredFields()
+ */
+ public static Iterable<Field> allInstanceFields(Class<?> javaClass) {
+ return IterableTools.filter(allFields(javaClass), FIELD_IS_NOT_STATIC);
+ }
+
+ public static final Predicate<Field> FIELD_IS_STATIC = new FieldIsStatic();
+ public static class FieldIsStatic
+ extends PredicateAdapter<Field>
+ {
+ @Override
+ public boolean evaluate(Field field) {
+ return Modifier.isStatic(field.getModifiers());
+ }
+ }
+ public static final Predicate<Field> FIELD_IS_NOT_STATIC = PredicateTools.not(FIELD_IS_STATIC);
+
+ /**
* Return all the fields for the
* specified class, including inherited fields.
* Make any private/package/protected fields accessible.

Back to the top