JingGe commented on a change in pull request #18333:
URL: https://github.com/apache/flink/pull/18333#discussion_r784026310



##########
File path: 
flink-architecture-tests/src/test/java/org/apache/flink/architecture/common/JavaFieldPredicates.java
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.architecture.common;
+
+import com.tngtech.archunit.base.DescribedPredicate;
+import com.tngtech.archunit.core.domain.JavaAnnotation;
+import com.tngtech.archunit.core.domain.JavaField;
+import com.tngtech.archunit.core.domain.JavaModifier;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+
+/** Fine-grained predicates focus on the JavaField. */
+public class JavaFieldPredicates {
+
+    /**
+     * Match the public modifier of the {@link JavaField}.
+     *
+     * @return A {@link DescribedPredicate} returning true, if and only if the 
tested {@link
+     *     JavaField} has the public modifier.
+     */
+    public static DescribedPredicate<JavaField> isPublic() {
+        return DescribedPredicate.describe(
+                "public", field -> 
field.getModifiers().contains(JavaModifier.PUBLIC));
+    }
+
+    /**
+     * Match the static modifier of the {@link JavaField}.
+     *
+     * @return A {@link DescribedPredicate} returning true, if and only if the 
tested {@link
+     *     JavaField} has the static modifier.
+     */
+    public static DescribedPredicate<JavaField> isStatic() {
+        return DescribedPredicate.describe(
+                "static", field -> 
field.getModifiers().contains(JavaModifier.STATIC));
+    }
+
+    /**
+     * Match none static modifier of the {@link JavaField}.
+     *
+     * @return A {@link DescribedPredicate} returning true, if and only if the 
tested {@link
+     *     JavaField} has no static modifier.
+     */
+    public static DescribedPredicate<JavaField> isNotStatic() {
+        return DescribedPredicate.describe(
+                "not static", field -> 
!field.getModifiers().contains(JavaModifier.STATIC));
+    }
+
+    /**
+     * Match the final modifier of the {@link JavaField}.
+     *
+     * @return A {@link DescribedPredicate} returning true, if and only if the 
tested {@link
+     *     JavaField} has the final modifier.
+     */
+    public static DescribedPredicate<JavaField> isFinal() {
+        return DescribedPredicate.describe(
+                "final", field -> 
field.getModifiers().contains(JavaModifier.FINAL));
+    }

Review comment:
       I think actually the other way around. There are too combinations.  
Methods like `arePublicStaticFinalOfType` provide the convenience for the most 
asked scenarios. These fine-gained methods will be used for other combinations, 
like how lego works.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to