blob: 92cbf4cf2960f0a74afb9bc4e40368de7af851ec [file] [log] [blame]
Sean Condon87b78502018-09-17 20:53:24 +01001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.ui.impl.gui2;
18
19import com.fasterxml.jackson.core.JsonGenerator;
20import com.fasterxml.jackson.databind.SerializerProvider;
21import com.fasterxml.jackson.databind.ser.std.StdSerializer;
22import org.onosproject.ui.UiExtension;
23import org.onosproject.ui.UiView;
24
25import java.io.IOException;
26
27public class UiViewSerializer extends StdSerializer<UiView> {
28
29 public UiViewSerializer(Class<UiView> t) {
30 super(t);
31 }
32
33 @Override
34 public void serialize(UiView view,
35 JsonGenerator jsonGenerator,
36 SerializerProvider serializerProvider)
37 throws IOException {
38 jsonGenerator.writeStartObject();
39 jsonGenerator.writeStringField("id", view.id());
40 jsonGenerator.writeStringField("icon", view.iconId());
41 jsonGenerator.writeStringField("cat", view.category().toString());
42 jsonGenerator.writeStringField("label", view.label());
43 jsonGenerator.writeEndObject();
44 }
45}