dtu.ds.warnme.ws.rest.json.gson.exclusionStrategies.PasswordExclusionStrategy.java Source code

Java tutorial

Introduction

Here is the source code for dtu.ds.warnme.ws.rest.json.gson.exclusionStrategies.PasswordExclusionStrategy.java

Source

/**
 * Project:   warnme-server
 * File:      PasswordExclusionStrategy.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright: Bartosz Cichecki [ cichecki.bartosz@gmail.com ]
 * Date:      19-03-2014
 */

package dtu.ds.warnme.ws.rest.json.gson.exclusionStrategies;

import java.lang.reflect.Field;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;

/**
 * @author Bartosz Cichecki
 */
public class PasswordExclusionStrategy implements ExclusionStrategy {

    private Class<?> clazz;

    private Field field;

    public PasswordExclusionStrategy(Class<?> clazz, Field field) {
        this.clazz = clazz;
        this.field = field;
    }

    @Override
    public boolean shouldSkipClass(Class<?> clazz) {
        return false;
    }

    @Override
    public boolean shouldSkipField(FieldAttributes f) {
        return f.getDeclaringClass().equals(clazz) && f.getName().equals(field.getName());
    }

}