From 61861be3663dc05883c387070c81eae9154444ef Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Mon, 27 Jun 2022 14:48:10 +0200 Subject: non profile specific system --- .../config/gson/ProfileExclusionStrategy.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java (limited to 'src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java') diff --git a/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java b/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.java new file mode 100644 index 0000000..c94e8bd --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/config/gson/ProfileExclusionStrategy.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 ProfileExclusionStrategy 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(NonProfileSpecific.class) != null || clazz.getAnnotation(Exclude.class) != null; + } +} -- cgit