From 11a3847a499b9e161b1ccf5fb35cbcf2ec0fdf84 Mon Sep 17 00:00:00 2001 From: Peter Gafert Date: Sun, 24 Mar 2019 15:43:58 +0100 Subject: [PATCH] Added negations to CodeUnitsShould.*(..) Issue: #38 Signed-off-by: Peter Gafert --- .../AbstractCodeUnitsShouldInternal.java | 47 +++++ .../lang/syntax/elements/CodeUnitsShould.java | 193 +++++++++++++++++- .../syntax/elements/CodeUnitsShouldTest.java | 73 ++++++- 3 files changed, 304 insertions(+), 9 deletions(-) diff --git a/archunit/src/main/java/com/tngtech/archunit/lang/syntax/AbstractCodeUnitsShouldInternal.java b/archunit/src/main/java/com/tngtech/archunit/lang/syntax/AbstractCodeUnitsShouldInternal.java index 109c37402d..b053ba4799 100644 --- a/archunit/src/main/java/com/tngtech/archunit/lang/syntax/AbstractCodeUnitsShouldInternal.java +++ b/archunit/src/main/java/com/tngtech/archunit/lang/syntax/AbstractCodeUnitsShouldInternal.java @@ -28,6 +28,8 @@ import com.tngtech.archunit.lang.syntax.elements.CodeUnitsShould; import com.tngtech.archunit.lang.syntax.elements.CodeUnitsShouldConjunction; +import static com.tngtech.archunit.lang.conditions.ArchConditions.not; + abstract class AbstractCodeUnitsShouldInternal> extends AbstractMembersShouldInternal implements CodeUnitsShould, CodeUnitsShouldConjunction { @@ -61,46 +63,91 @@ public SELF haveRawParameterTypes(Class... parameterTypes) { return addCondition(ArchConditions.haveRawParameterTypes(parameterTypes)); } + @Override + public SELF notHaveRawParameterTypes(Class... parameterTypes) { + return addCondition(not(ArchConditions.haveRawParameterTypes(parameterTypes))); + } + @Override public SELF haveRawParameterTypes(String... parameterTypeNames) { return addCondition(ArchConditions.haveRawParameterTypes(parameterTypeNames)); } + @Override + public SELF notHaveRawParameterTypes(String... parameterTypeNames) { + return addCondition(not(ArchConditions.haveRawParameterTypes(parameterTypeNames))); + } + @Override public SELF haveRawParameterTypes(DescribedPredicate> predicate) { return addCondition(ArchConditions.haveRawParameterTypes(predicate)); } + @Override + public SELF notHaveRawParameterTypes(DescribedPredicate> predicate) { + return addCondition(not(ArchConditions.haveRawParameterTypes(predicate))); + } + @Override public SELF haveRawReturnType(Class type) { return addCondition(ArchConditions.haveRawReturnType(type)); } + @Override + public SELF notHaveRawReturnType(Class type) { + return addCondition(not(ArchConditions.haveRawReturnType(type))); + } + @Override public SELF haveRawReturnType(String typeName) { return addCondition(ArchConditions.haveRawReturnType(typeName)); } + @Override + public SELF notHaveRawReturnType(String typeName) { + return addCondition(not(ArchConditions.haveRawReturnType(typeName))); + } + @Override public SELF haveRawReturnType(DescribedPredicate predicate) { return addCondition(ArchConditions.haveRawReturnType(predicate)); } + @Override + public SELF notHaveRawReturnType(DescribedPredicate predicate) { + return addCondition(not(ArchConditions.haveRawReturnType(predicate))); + } + @Override public SELF declareThrowableOfType(Class type) { return addCondition(ArchConditions.declareThrowableOfType(type)); } + @Override + public SELF notDeclareThrowableOfType(Class type) { + return addCondition(not(ArchConditions.declareThrowableOfType(type))); + } + @Override public SELF declareThrowableOfType(String typeName) { return addCondition(ArchConditions.declareThrowableOfType(typeName)); } + @Override + public SELF notDeclareThrowableOfType(String typeName) { + return addCondition(not(ArchConditions.declareThrowableOfType(typeName))); + } + @Override public SELF declareThrowableOfType(DescribedPredicate predicate) { return addCondition(ArchConditions.declareThrowableOfType(predicate)); } + @Override + public SELF notDeclareThrowableOfType(DescribedPredicate predicate) { + return addCondition(not(ArchConditions.declareThrowableOfType(predicate))); + } + static class CodeUnitsShouldInternal extends AbstractCodeUnitsShouldInternal { CodeUnitsShouldInternal( diff --git a/archunit/src/main/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShould.java b/archunit/src/main/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShould.java index 11061c9f89..cfe19ac7b6 100644 --- a/archunit/src/main/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShould.java +++ b/archunit/src/main/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShould.java @@ -48,6 +48,27 @@ public interface CodeUnitsShould... parameterTypes); + /** + * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not have the specified raw parameter types. + *

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawParameterTypes(Class[]) notHaveRawParameterTypes(String.class, int.class)}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod(String stringParam, int intParam) {...}
+     * }
+     * 
+ * + * @param parameterTypes Parameter types {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawParameterTypes(Class... parameterTypes); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} have the specified fully qualified raw parameter type names. *

@@ -69,6 +90,27 @@ public interface CodeUnitsShould
+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawParameterTypes(String[]) notHaveRawParameterTypes(String.class.getName(), int.class.getName())}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod(String stringParam, int intParam) {...}
+     * }
+     * 
+ * + * @param parameterTypeNames Fully qualified names of parameter types {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawParameterTypes(String... parameterTypeNames); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} have raw parameter types matching the given predicate. *

@@ -91,7 +133,28 @@ public interface CodeUnitsShould> predicate); /** - * Asserts that {@link JavaCodeUnit JavaCodeUnits} have the specified raw return types. + * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not have raw parameter types matching the given predicate. + *

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawParameterTypes(DescribedPredicate) notHaveRawParameterTypes(whereFirstTypeIs(String.class))}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod(String stringParam, int intParam) {...}
+     * }
+     * 
+ * + * @param predicate A {@link DescribedPredicate} that determines, which {@link JavaCodeUnit JavaCodeUnits} do not match by their raw parameter types + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawParameterTypes(DescribedPredicate> predicate); + + /** + * Asserts that {@link JavaCodeUnit JavaCodeUnits} have the specified raw return type. *

* E.g. *

@@ -111,6 +174,27 @@ public interface CodeUnitsShould type);
 
+    /**
+     * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not have the specified raw return type.
+     * 

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawReturnType(Class) notHaveRawReturnType(String.class)}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     String someMethod() {...}
+     * }
+     * 
+ * + * @param type Return type {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawReturnType(Class type); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} have the specified fully qualified raw return type name. *

@@ -132,6 +216,27 @@ public interface CodeUnitsShould
+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawReturnType(String) notHaveRawReturnType(String.class.getName())}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     String someMethod() {...}
+     * }
+     * 
+ * + * @param typeName Fully qualified name of a return type {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawReturnType(String typeName); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} have raw return types matching the given predicate. *

@@ -153,6 +258,27 @@ public interface CodeUnitsShould predicate); + /** + * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not have raw return types matching the given predicate. + *

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notHaveRawReturnType(DescribedPredicate) notHaveRawReturnType(assignableTo(Serializable.class))}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     String someMethod() {...}
+     * }
+     * 
+ * + * @param predicate A {@link DescribedPredicate} that determines, which {@link JavaCodeUnit JavaCodeUnits} do not match by their raw return types + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notHaveRawReturnType(DescribedPredicate predicate); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} declare a {@link Throwable} of the specified type in their throws clause. *

@@ -174,6 +300,27 @@ public interface CodeUnitsShould type); + /** + * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not declare a {@link Throwable} of the specified type in their throws clause. + *

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notDeclareThrowableOfType(Class) notDeclareThrowableOfType(SomeException.class)}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod() throws SomeException {...}
+     * }
+     * 
+ * + * @param type Type of a declared {@link Throwable} {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notDeclareThrowableOfType(Class type); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} declare a {@link Throwable} of the specified fully qualified type name in their throws clause. *

@@ -195,12 +342,33 @@ public interface CodeUnitsShould
+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notDeclareThrowableOfType(String) notDeclareThrowableOfType(SomeException.class.getName())}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod() throws SomeException {...}
+     * }
+     * 
+ * + * @param typeName Fully qualified name of a type of a declared {@link Throwable} {@link JavaCodeUnit JavaCodeUnits} should not have + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notDeclareThrowableOfType(String typeName); + /** * Asserts that {@link JavaCodeUnit JavaCodeUnits} declare a {@link Throwable} which matches the given predicate. *

* E.g. *

-     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#declareThrowableOfType(DescribedPredicate) declareThrowableOfType(nameStartingWith("First"))}
+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#declareThrowableOfType(DescribedPredicate) declareThrowableOfType(nameStartingWith("Some"))}
      * 
* would be violated by someMethod in * @@ -215,4 +383,25 @@ public interface CodeUnitsShould predicate); + + /** + * Asserts that {@link JavaCodeUnit JavaCodeUnits} do not declare a {@link Throwable} which matches the given predicate. + *

+ * E.g. + *

+     * {@link ArchRuleDefinition#codeUnits() codeUnits()}.{@link GivenCodeUnits#should() should()}.{@link CodeUnitsShould#notDeclareThrowableOfType(DescribedPredicate) notDeclareThrowableOfType(nameStartingWith("Some"))}
+     * 
+ * would be violated by someMethod in + * + *

+     * class Example {
+     *     void someMethod() throws SomeException {...}
+     * }
+     * 
+ * + * @param predicate A {@link DescribedPredicate} that determines, which {@link JavaCodeUnit JavaCodeUnits} do not match by their declared {@link Throwable} + * @return A syntax conjunction element, which can be completed to form a full rule + */ + @PublicAPI(usage = ACCESS) + CONJUNCTION notDeclareThrowableOfType(DescribedPredicate predicate); } diff --git a/archunit/src/test/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShouldTest.java b/archunit/src/test/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShouldTest.java index 40c58e5768..b2ce90b3c8 100644 --- a/archunit/src/test/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShouldTest.java +++ b/archunit/src/test/java/com/tngtech/archunit/lang/syntax/elements/CodeUnitsShouldTest.java @@ -1,6 +1,7 @@ package com.tngtech.archunit.lang.syntax.elements; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -125,6 +126,12 @@ public static Object[][] restricted_parameter_types_rules() { union(allMethodsExcept(METHOD_ONE_ARG), allConstructorsExcept(CONSTRUCTOR_ONE_ARG))), $(codeUnits().should().haveRawParameterTypes(oneParameterOfType(String.class)), union(allMethodsExcept(METHOD_ONE_ARG), allConstructorsExcept(CONSTRUCTOR_ONE_ARG))), + $(codeUnits().should().notHaveRawParameterTypes(String.class), + ImmutableSet.of(METHOD_ONE_ARG, CONSTRUCTOR_ONE_ARG)), + $(codeUnits().should().notHaveRawParameterTypes(String.class.getName()), + ImmutableSet.of(METHOD_ONE_ARG, CONSTRUCTOR_ONE_ARG)), + $(codeUnits().should().notHaveRawParameterTypes(oneParameterOfType(String.class)), + ImmutableSet.of(METHOD_ONE_ARG, CONSTRUCTOR_ONE_ARG)), $(methods().should().haveRawParameterTypes(String.class), allMethodsExcept(METHOD_ONE_ARG)), @@ -132,13 +139,25 @@ public static Object[][] restricted_parameter_types_rules() { allMethodsExcept(METHOD_ONE_ARG)), $(methods().should().haveRawParameterTypes(oneParameterOfType(String.class)), allMethodsExcept(METHOD_ONE_ARG)), + $(methods().should().notHaveRawParameterTypes(String.class), + ImmutableSet.of(METHOD_ONE_ARG)), + $(methods().should().notHaveRawParameterTypes(String.class.getName()), + ImmutableSet.of(METHOD_ONE_ARG)), + $(methods().should().notHaveRawParameterTypes(oneParameterOfType(String.class)), + ImmutableSet.of(METHOD_ONE_ARG)), $(constructors().should().haveRawParameterTypes(String.class), allConstructorsExcept(CONSTRUCTOR_ONE_ARG)), $(constructors().should().haveRawParameterTypes(String.class.getName()), allConstructorsExcept(CONSTRUCTOR_ONE_ARG)), $(constructors().should().haveRawParameterTypes(oneParameterOfType(String.class)), - allConstructorsExcept(CONSTRUCTOR_ONE_ARG)) + allConstructorsExcept(CONSTRUCTOR_ONE_ARG)), + $(constructors().should().notHaveRawParameterTypes(String.class), + ImmutableSet.of(CONSTRUCTOR_ONE_ARG)), + $(constructors().should().notHaveRawParameterTypes(String.class.getName()), + ImmutableSet.of(CONSTRUCTOR_ONE_ARG)), + $(constructors().should().notHaveRawParameterTypes(oneParameterOfType(String.class)), + ImmutableSet.of(CONSTRUCTOR_ONE_ARG)) ); } @@ -160,6 +179,12 @@ public static Object[][] restricted_return_type_rules() { union(allMethodsExcept(METHOD_ONE_ARG, METHOD_THREE_ARGS), ALL_CONSTRUCTOR_DESCRIPTIONS)), $(codeUnits().should().haveRawReturnType(equivalentTo(String.class)), union(allMethodsExcept(METHOD_ONE_ARG, METHOD_THREE_ARGS), ALL_CONSTRUCTOR_DESCRIPTIONS)), + $(codeUnits().should().notHaveRawReturnType(String.class), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), + $(codeUnits().should().notHaveRawReturnType(String.class.getName()), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), + $(codeUnits().should().notHaveRawReturnType(equivalentTo(String.class)), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), $(methods().should().haveRawReturnType(String.class), allMethodsExcept(METHOD_ONE_ARG, METHOD_THREE_ARGS)), @@ -167,13 +192,25 @@ public static Object[][] restricted_return_type_rules() { allMethodsExcept(METHOD_ONE_ARG, METHOD_THREE_ARGS)), $(methods().should().haveRawReturnType(equivalentTo(String.class)), allMethodsExcept(METHOD_ONE_ARG, METHOD_THREE_ARGS)), + $(methods().should().notHaveRawReturnType(String.class), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), + $(methods().should().notHaveRawReturnType(String.class.getName()), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), + $(methods().should().notHaveRawReturnType(equivalentTo(String.class)), + ImmutableSet.of(METHOD_ONE_ARG, METHOD_THREE_ARGS)), $(constructors().should().haveRawReturnType(String.class), ALL_CONSTRUCTOR_DESCRIPTIONS), $(constructors().should().haveRawReturnType(String.class.getName()), ALL_CONSTRUCTOR_DESCRIPTIONS), $(constructors().should().haveRawReturnType(equivalentTo(String.class)), - ALL_CONSTRUCTOR_DESCRIPTIONS) + ALL_CONSTRUCTOR_DESCRIPTIONS), + $(constructors().should().notHaveRawReturnType(String.class), + Collections.emptySet()), + $(constructors().should().notHaveRawReturnType(String.class.getName()), + Collections.emptySet()), + $(constructors().should().notHaveRawReturnType(equivalentTo(String.class)), + Collections.emptySet()) ); } @@ -195,6 +232,12 @@ public static Object[][] restricted_throwable_type_rules() { ImmutableSet.of(METHOD_TWO_ARGS, METHOD_FOUR_ARGS, CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), $(codeUnits().should().declareThrowableOfType(equivalentTo(FirstException.class)), ImmutableSet.of(METHOD_TWO_ARGS, METHOD_FOUR_ARGS, CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(codeUnits().should().notDeclareThrowableOfType(FirstException.class), + allCodeUnitsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS, CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(codeUnits().should().notDeclareThrowableOfType(FirstException.class.getName()), + allCodeUnitsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS, CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(codeUnits().should().notDeclareThrowableOfType(equivalentTo(FirstException.class)), + allCodeUnitsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS, CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), $(methods().should().declareThrowableOfType(FirstException.class), ImmutableSet.of(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), @@ -202,13 +245,25 @@ public static Object[][] restricted_throwable_type_rules() { ImmutableSet.of(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), $(methods().should().declareThrowableOfType(equivalentTo(FirstException.class)), ImmutableSet.of(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), + $(methods().should().notDeclareThrowableOfType(FirstException.class), + allMethodsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), + $(methods().should().notDeclareThrowableOfType(FirstException.class.getName()), + allMethodsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), + $(methods().should().notDeclareThrowableOfType(equivalentTo(FirstException.class)), + allMethodsExcept(METHOD_TWO_ARGS, METHOD_FOUR_ARGS)), $(constructors().should().declareThrowableOfType(FirstException.class), ImmutableSet.of(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), $(constructors().should().declareThrowableOfType(FirstException.class.getName()), ImmutableSet.of(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), $(constructors().should().declareThrowableOfType(equivalentTo(FirstException.class)), - ImmutableSet.of(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)) + ImmutableSet.of(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(constructors().should().notDeclareThrowableOfType(FirstException.class), + allConstructorsExcept(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(constructors().should().notDeclareThrowableOfType(FirstException.class.getName()), + allConstructorsExcept(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)), + $(constructors().should().notDeclareThrowableOfType(equivalentTo(FirstException.class)), + allConstructorsExcept(CONSTRUCTOR_TWO_ARGS, CONSTRUCTOR_FOUR_ARGS)) ); } @@ -230,11 +285,15 @@ public boolean apply(JavaCodeUnit codeUnit) { }; } - private static Set allMethodsExcept(String... method) { - return Sets.difference(ALL_METHOD_DESCRIPTIONS, ImmutableSet.copyOf(method)); + private static Set allMethodsExcept(String... methods) { + return Sets.difference(ALL_METHOD_DESCRIPTIONS, ImmutableSet.copyOf(methods)); + } + + private static Set allConstructorsExcept(String... constructors) { + return Sets.difference(ALL_CONSTRUCTOR_DESCRIPTIONS, ImmutableSet.copyOf(constructors)); } - private static Set allConstructorsExcept(String... constructor) { - return Sets.difference(ALL_CONSTRUCTOR_DESCRIPTIONS, ImmutableSet.copyOf(constructor)); + private static Set allCodeUnitsExcept(String... codeUnits) { + return union(allMethodsExcept(codeUnits), allConstructorsExcept(codeUnits)); } } \ No newline at end of file