blob: 591b0ac725118ae21b0e5a5a28b71623e097e168 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package cc.polyfrost.oneconfig.config.gson;
import cc.polyfrost.oneconfig.config.Config;
import cc.polyfrost.oneconfig.config.annotations.Exclude;
import cc.polyfrost.oneconfig.config.annotations.NonProfileSpecific;
import cc.polyfrost.oneconfig.gui.pages.Page;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
public class ProfileExclusionStrategy extends ExclusionUtils 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) {
if (isSuperClassOf(f.getDeclaredClass(), Config.class)) return true;
if (isSuperClassOf(f.getDeclaredClass(), Page.class)) return true;
if (f.getDeclaredClass().isAssignableFrom(Runnable.class)) return true;
if (f.getAnnotation(NonProfileSpecific.class) != null) return true;
Exclude exclude = f.getAnnotation(Exclude.class);
return exclude != 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) {
Exclude exclude = clazz.getAnnotation(Exclude.class);
return exclude != null;
}
}
|