aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-27 14:48:10 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-27 14:48:10 +0200
commit61861be3663dc05883c387070c81eae9154444ef (patch)
tree7e06a816a7d6c7a4ee101a05d0c12710986dba2b /src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
parentd7ec593b877b6f41c6b5b431584789e9080aede7 (diff)
downloadOneConfig-61861be3663dc05883c387070c81eae9154444ef.tar.gz
OneConfig-61861be3663dc05883c387070c81eae9154444ef.tar.bz2
OneConfig-61861be3663dc05883c387070c81eae9154444ef.zip
non profile specific system
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
new file mode 100644
index 0000000..8efa0b7
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/NonProfileSpecificExclusionStrategy.java
@@ -0,0 +1,26 @@
+package cc.polyfrost.oneconfig.config.gson;
+
+import cc.polyfrost.oneconfig.config.annotations.Exclude;
+import cc.polyfrost.oneconfig.config.annotations.NonProfileSpecific;
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
+
+public class NonProfileSpecificExclusionStrategy implements ExclusionStrategy {
+ /**
+ * @param f the field object that is under test
+ * @return true if the field should be ignored; otherwise false
+ */
+ @Override
+ public boolean shouldSkipField(FieldAttributes f) {
+ return f.getAnnotation(NonProfileSpecific.class) == null || f.getAnnotation(Exclude.class) != null;
+ }
+
+ /**
+ * @param clazz the class object that is under test
+ * @return true if the class should be ignored; otherwise false
+ */
+ @Override
+ public boolean shouldSkipClass(Class<?> clazz) {
+ return clazz.getAnnotation(Exclude.class) != null;
+ }
+}