2 * ===========LICENSE_START========================================================
3 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
21 package org.onap.dcae.analytics.tca.model.util.json;
23 import com.fasterxml.jackson.core.type.TypeReference;
24 import com.fasterxml.jackson.databind.ObjectMapper;
26 import java.util.Optional;
27 import java.util.function.Function;
28 import java.util.List;
30 import org.onap.dcae.analytics.model.util.function.JsonToJavaObjectBiFunction;
31 import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
32 import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
35 * @author Rajiv Singla
37 public abstract class TcaModelJsonConversion {
40 public static final ObjectMapper TCA_OBJECT_MAPPER = new TcaObjectMapperSupplier().get();
42 // Type reference to convert tca policy string to tca policy object
43 private static final TypeReference<List<TcaPolicy>> TCA_POLICY_TYPE_REF = new TypeReference<List<TcaPolicy>>() {
46 // Type reference to convert tca alert string to tca alert
47 private static final TypeReference<TcaAlert> TCA_ALERT_TYPE_REF = new TypeReference<TcaAlert>() {
50 // Tca Policy JSON conversion function
51 public static final Function<String, Optional<List<TcaPolicy>>> TCA_POLICY_JSON_FUNCTION = new
52 JsonToJavaObjectBiFunction<List<TcaPolicy>>(TCA_OBJECT_MAPPER).curry(TCA_POLICY_TYPE_REF);
54 // Tca Alert JSON conversion function
55 public static final Function<String, Optional<TcaAlert>> TCA_ALERT_JSON_FUNCTION = new
56 JsonToJavaObjectBiFunction<TcaAlert>(TCA_OBJECT_MAPPER).curry(TCA_ALERT_TYPE_REF);
58 private TcaModelJsonConversion() {
59 // private constructor