| 1 | /*- | |
| 2 | * #%L | |
| 3 | * io.earcam.utilitarian.site.search.offline | |
| 4 | * %% | |
| 5 | * Copyright (C) 2017 earcam | |
| 6 | * %% | |
| 7 | * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT) | |
| 8 | * | |
| 9 | * You <b>must</b> choose to accept, in full - any individual or combination of | |
| 10 | * the following licenses: | |
| 11 | * <ul> | |
| 12 | * <li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li> | |
| 13 | * <li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li> | |
| 14 | * <li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li> | |
| 15 | * <li><a href="https://opensource.org/licenses/MIT">MIT</a></li> | |
| 16 | * </ul> | |
| 17 | * #L% | |
| 18 | */ | |
| 19 | package io.earcam.utilitarian.site.search.offline.jsonb; | |
| 20 | ||
| 21 | import java.io.StringWriter; | |
| 22 | ||
| 23 | import javax.json.bind.Jsonb; | |
| 24 | import javax.json.bind.JsonbBuilder; | |
| 25 | import javax.json.bind.JsonbConfig; | |
| 26 | ||
| 27 | public final class JsonBind { | |
| 28 | ||
| 29 | private JsonBind() | |
| 30 | {} | |
| 31 | ||
| 32 | private static final JsonbConfig CONFIGURATION = new JsonbConfig() | |
| 33 | .withNullValues(true) | |
| 34 | .withFormatting(true) | |
| 35 | .withAdapters( | |
| 36 | new JsonbFileAdapter() {}, | |
| 37 | new JsonbUriAdapter() {}); | |
| 38 | ||
| 39 | private static final Jsonb JSONB = JsonbBuilder.create(CONFIGURATION); | |
| 40 | ||
| 41 | ||
| 42 | public static String writeJson(Object instance) | |
| 43 | { | |
| 44 |
1
1. writeJson : mutated return of Object value for io/earcam/utilitarian/site/search/offline/jsonb/JsonBind::writeJson to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return writeJson(JSONB, instance); |
| 45 | } | |
| 46 | ||
| 47 | ||
| 48 | public static String writeJson(Jsonb jsonb, Object instance) | |
| 49 | { | |
| 50 | StringWriter writer = new StringWriter(); | |
| 51 |
1
1. writeJson : removed call to javax/json/bind/Jsonb::toJson → KILLED |
jsonb.toJson(instance, writer); |
| 52 |
1
1. writeJson : mutated return of Object value for io/earcam/utilitarian/site/search/offline/jsonb/JsonBind::writeJson to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return writer.toString(); |
| 53 | } | |
| 54 | ||
| 55 | ||
| 56 | public static <T> T readJson(String json, Class<T> type) | |
| 57 | { | |
| 58 |
1
1. readJson : mutated return of Object value for io/earcam/utilitarian/site/search/offline/jsonb/JsonBind::readJson to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return JSONB.fromJson(json, type); |
| 59 | } | |
| 60 | } | |
Mutations | ||
| 44 |
1.1 |
|
| 51 |
1.1 |
|
| 52 |
1.1 |
|
| 58 |
1.1 |