@Override
public Data deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) {
final JsonObject obj = json.getAsJsonObject();
final Set<Map.Entry<String, JsonElement>> entrySet = obj.entrySet();
final DataBuilder builder = new DataBuilder();
for (final Map.Entry<String, JsonElement> entry : entrySet) {
final List<BrowserPattern> browserPatterns = deserializeType(context, entry, SerializableDataField.BROWSERPATTERNS,
BrowserPattern.class);
for (final BrowserPattern browserPattern : browserPatterns) {
builder.appendBrowserPattern(browserPattern);
}
final List<BrowserType> browserTypes = deserializeType(context, entry, SerializableDataField.BROWSERTYPES, BrowserType.class);
for (final BrowserType browserType : browserTypes) {
builder.appendBrowserType(browserType);
}
final List<Browser> browsers = deserializeType(context, entry, SerializableDataField.BROWSERS, Browser.class);
for (final Browser browser : browsers) {
builder.appendBrowser(browser);
}
final List<OperatingSystemPattern> operatingSystemPatterns = deserializeType(context, entry,
SerializableDataField.OPERATINGSYSTEMPATTERNS, OperatingSystemPattern.class);
for (final OperatingSystemPattern operatingSystemPattern : operatingSystemPatterns) {
builder.appendOperatingSystemPattern(operatingSystemPattern);
}
final List<OperatingSystem> operatingSystems = deserializeType(context, entry, SerializableDataField.OPERATINGSYSTEMS,
OperatingSystem.class);
for (final OperatingSystem operatingSystem : operatingSystems) {
builder.appendOperatingSystem(operatingSystem);
}
final List<Robot> robots = deserializeType(context, entry, SerializableDataField.ROBOTS, Robot.class);
for (final Robot robot : robots) {
builder.appendRobot(robot);
}
final List<DevicePattern> devicePatterns = deserializeType(context, entry, SerializableDataField.DEVICEPATTERNS,
DevicePattern.class);
for (final DevicePattern devicePattern : devicePatterns) {
builder.appendDevicePattern(devicePattern);
}
final List<Device> devices = deserializeType(context, entry, SerializableDataField.DEVICES, Device.class);
for (final Device device : devices) {
builder.appendDevice(device);
}
if (SerializableDataField.VERSION.getName().equals(entry.getKey())) {
builder.setVersion(entry.getValue().getAsString());
}
}
// create data
Data data = Data.EMPTY;
try {
data = builder.build();
} catch (final Exception e) {
addWarning(e.getLocalizedMessage());
}
return data;