From 125e4bd1c8e0a8f4b434209b155e6cd0d8f09092 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 7 Sep 2019 18:48:42 +0200 Subject: Bug 1392: Simplify CapabilitiesFilter: Criteria -> Test, remove RemovalCriteria as all Test definitions may be used for anything. --- .../jogamp/nativewindow/CapabilitiesFilter.java | 37 ++++++++++------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src/nativewindow') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java index d7785bc48..17bab355e 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java @@ -40,16 +40,13 @@ public class CapabilitiesFilter { protected CapabilitiesFilter() {} /** Generic filter criteria */ - public static interface Criteria { + public static interface Test { public boolean match(final C cap); } - /** Filter {@link Criteria} for removal */ - public static interface RemovalCriteria extends Criteria { - } - public static class RemoveLessColorCompBits implements RemovalCriteria { + public static class TestLessColorCompBits implements Test { final int minColorCompBits; - public RemoveLessColorCompBits(final int minColorCompBits) { + public TestLessColorCompBits(final int minColorCompBits) { this.minColorCompBits = minColorCompBits; } public final boolean match(final C cap) { @@ -59,9 +56,9 @@ public class CapabilitiesFilter { cap.getAlphaBits() < minColorCompBits; } } - public static class RemoveMoreColorCompBits implements RemovalCriteria { + public static class TestMoreColorCompBits implements Test { final int maxColorCompBits; - public RemoveMoreColorCompBits(final int maxColorCompBits) { + public TestMoreColorCompBits(final int maxColorCompBits) { this.maxColorCompBits = maxColorCompBits; } public final boolean match(final C cap) { @@ -71,9 +68,9 @@ public class CapabilitiesFilter { cap.getAlphaBits() > maxColorCompBits; } } - public static class RemoveUnmatchedNativeVisualID implements RemovalCriteria { + public static class TestUnmatchedNativeVisualID implements Test { final int requiredNativeVisualID; - public RemoveUnmatchedNativeVisualID(final int requiredNativeVisualID) { + public TestUnmatchedNativeVisualID(final int requiredNativeVisualID) { this.requiredNativeVisualID = requiredNativeVisualID; } public final boolean match(final C cap) { @@ -82,12 +79,12 @@ public class CapabilitiesFilter { } /** - * Removing all {@link CapabilitiesImmutable} derived elements matching the given {@code criteria} {@link RemovalCriteria} list. + * Removing all {@link CapabilitiesImmutable} derived elements matching the given {@code criteria} {@link Test} list. * @param availableCaps {@link CapabilitiesImmutable} derived list to be filtered - * @param criteria {@link RemovalCriteria} list run on all non-removed {@link CapabilitiesImmutable} derived elements + * @param criteria {@link Test} list run on all non-removed {@link CapabilitiesImmutable} derived elements * @return the list of removed {@link CapabilitiesImmutable} derived elements, might be of size 0 if none were removed. */ - public static ArrayList removeMatching(final ArrayList availableCaps, final List> criteria) { + public static ArrayList removeMatching(final ArrayList availableCaps, final List> criteria) { final ArrayList removedCaps = new ArrayList(); for(int i=0; i(); } - final ArrayList> criteria = new ArrayList>(); - criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID(requiredNativeVisualID)); + final ArrayList> criteria = new ArrayList>(); + criteria.add(new CapabilitiesFilter.TestUnmatchedNativeVisualID(requiredNativeVisualID)); return removeMatching(availableCaps, criteria); } @@ -133,8 +130,8 @@ public class CapabilitiesFilter { */ public static ArrayList removeMoreColorComps(final ArrayList availableCaps, final int maxColorCompBits) { - final ArrayList> criteria = new ArrayList>(); - criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits(maxColorCompBits)); + final ArrayList> criteria = new ArrayList>(); + criteria.add(new CapabilitiesFilter.TestMoreColorCompBits(maxColorCompBits)); return removeMatching(availableCaps, criteria); } @@ -153,10 +150,10 @@ public class CapabilitiesFilter { */ public static ArrayList removeMoreColorCompsAndUnmatchingNativeVisualID(final ArrayList availableCaps, final int maxColorCompBits, final int requiredNativeVisualID) { - final ArrayList> criteria = new ArrayList>(); - criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits(maxColorCompBits)); + final ArrayList> criteria = new ArrayList>(); + criteria.add(new CapabilitiesFilter.TestMoreColorCompBits(maxColorCompBits)); if( VisualIDHolder.VID_UNDEFINED != requiredNativeVisualID) { - criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID(requiredNativeVisualID)); + criteria.add(new CapabilitiesFilter.TestUnmatchedNativeVisualID(requiredNativeVisualID)); } return removeMatching(availableCaps, criteria); } -- cgit v1.2.3