Skip to content

Instantly share code, notes, and snippets.

@andres-sacco
Last active January 16, 2021 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andres-sacco/5a0e194e810c3c99840d047349da2999 to your computer and use it in GitHub Desktop.
Save andres-sacco/5a0e194e810c3c99840d047349da2999 to your computer and use it in GitHub Desktop.
Common rules
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
import java.util.Arrays;
import com.tngtech.archunit.lang.ArchRule;
class CommonRules {
static ArchRule methodsShouldBePublicRule(String... packageNames) {
return methods()
.that().areDeclaredInClassesThat()
.resideInAnyPackage(packageNames)
.should().bePublic()
.because("Public methods are only allowed in " + Arrays.toString(packageNames));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment