-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Didn't find rule 'classes should not be final' #1363
Comments
You can use ArchRule rule = classes()
.that().areAnnotatedWith(Entity.class)
.should().notHaveModifier(JavaModifier.FINAL); |
Thank you ! At first I was looking for methods similar to |
Just one more remark on shorter implementations: For If there was no predefined method in the fluent API, you could still simplify your conditions using import static com.tngtech.archunit.base.DescribedPredicate.describe;
import static com.tngtech.archunit.lang.conditions.ArchConditions.be;
import static com.tngtech.archunit.lang.conditions.ArchConditions.not; to ArchCondition<JavaClass> beFinal = be(describe("final", javaClass ->
javaClass.getModifiers().contains(JavaModifier.FINAL))
);
ArchCondition<JavaClass> notBeFinal = not(beFinal); |
Thank you for your clarifications. Using a predicate is indeed shorter and more elegant 👍 |
I didn't find a rule to assert that classes should (or not) be final.
For example I'd like to do this :
I was just able to add a custom ArchCondition like :
The text was updated successfully, but these errors were encountered: