Example usage for com.google.gson GsonBuilder setExclusionStrategies

List of usage examples for com.google.gson GsonBuilder setExclusionStrategies

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder setExclusionStrategies.

Prototype

public GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies) 

Source Link

Document

Configures Gson to apply a set of exclusion strategies during both serialization and deserialization.

Usage

From source file:pl.datamatica.traccar.api.Context.java

License:Open Source License

private Context() {
    emf = Persistence.createEntityManagerFactory("release");
    Map<String, String> properties = getApiConnectionData();

    if (properties.size() > 0) {
        // Use properties obtained from 'debug.xml' or PRODUCTION_TRACCAR_CONFIG_FILE if possible
        emfMetadata = Persistence.createEntityManagerFactory("traccar_api_metadata_persistence", properties);
    } else {/*  w  w w.j a v a  2 s  . c o m*/
        // Otherwise settings from 'persistence.xml' will be used
        emfMetadata = Persistence.createEntityManagerFactory("traccar_api_metadata_persistence");
    }

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.setDateFormat(Application.DATE_FORMAT);
    gsonBuilder.setExclusionStrategies(new AnnotationExclusionStrategy());
    if (isInDevMode())
        gsonBuilder.setPrettyPrinting();
    gson = gsonBuilder.create();

    daemonExecutor = Executors.newScheduledThreadPool(2);
}