Example usage for com.google.gson GsonBuilder disableInnerClassSerialization

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

Introduction

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

Prototype

public GsonBuilder disableInnerClassSerialization() 

Source Link

Document

Configures Gson to exclude inner classes during serialization.

Usage

From source file:net.sf.uadetector.json.internal.data.serializer.Serializers.java

License:Apache License

private Serializers(final EnumSet<SerDeOption> options) {
    Check.notNull(options);/*from   www  . j a  v a 2 s.  c o m*/
    final GsonBuilder gsonBuilder = new GsonBuilder();

    // setup serializers
    gsonBuilder.registerTypeAdapter(Data.class, new DataSerializer());
    gsonBuilder.registerTypeAdapter(Browser.class, new BrowserSerializer());
    gsonBuilder.registerTypeAdapter(BrowserPattern.class, new OrderedPatternSerializer<BrowserPattern>());
    gsonBuilder.registerTypeAdapter(BrowserType.class, new BrowserTypeSerializer());
    gsonBuilder.registerTypeAdapter(OperatingSystem.class, new OperatingSystemSerializer());
    gsonBuilder.registerTypeAdapter(OperatingSystemPattern.class,
            new OrderedPatternSerializer<OperatingSystemPattern>());
    gsonBuilder.registerTypeAdapter(Robot.class, new RobotSerializer());
    gsonBuilder.registerTypeAdapter(Pattern.class, new PatternSerializer());
    gsonBuilder.registerTypeAdapter(Device.class, new DeviceSerializer());
    gsonBuilder.registerTypeAdapter(DevicePattern.class, new OrderedPatternSerializer<DevicePattern>());

    // some settings
    if (options.contains(SerDeOption.PRETTY_PRINTING)) {
        gsonBuilder.setPrettyPrinting();
    }
    gsonBuilder.disableInnerClassSerialization();

    gson = gsonBuilder.create();
}