2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.tplinksmarthome.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import com.google.gson.FieldNamingPolicy;
18 import com.google.gson.Gson;
19 import com.google.gson.GsonBuilder;
20 import com.google.gson.annotations.Expose;
23 * Util class to create a {@link Gson} object.
25 * @author Hilbrand Bouwkamp - Initial contribution
28 public final class GsonUtil {
35 * Creates a new {@link Gson} object.
37 * @return new {@link Gson} object.
39 public static Gson createGson() {
40 return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
44 * Creates a new {@link Gson} object that uses the {@link Expose} annotation..
46 * @return new {@link Gson} object.
48 public static Gson createGsonWithExpose() {
49 return new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
50 .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();