Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Annotation:
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.FIELD)
- public @interface Exclude {
- }
- //Strategy:
- public class AnnotationExclusionStrategy implements ExclusionStrategy {
- @Override
- public boolean shouldSkipField(FieldAttributes f) {
- return f.getAnnotation(Exclude.class) != null;
- }
- @Override
- public boolean shouldSkipClass(Class<?> clazz) {
- return false;
- }
- }
- //Usage:
- new GsonBuilder().setExclusionStrategies(new AnnotationExclusionStrategy()).create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement