2 * Copyright (c) 2013, 2015 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.lib.notation.json;
11 import java.io.IOException;
14 import org.opendaylight.ovsdb.lib.notation.OvsdbSet;
16 import com.fasterxml.jackson.core.JsonGenerator;
17 import com.fasterxml.jackson.core.JsonProcessingException;
18 import com.fasterxml.jackson.databind.JsonSerializer;
19 import com.fasterxml.jackson.databind.SerializerProvider;
21 public class OvsdbSetSerializer extends JsonSerializer<OvsdbSet<?>> {
23 public void serialize(OvsdbSet<?> set, JsonGenerator generator,
24 SerializerProvider provider) throws IOException,
25 JsonProcessingException {
26 generator.writeStartArray();
27 generator.writeString("set");
28 generator.writeStartArray();
29 Set<?> javaSet = set.delegate();
30 for (Object setObject : javaSet) {
31 generator.writeObject(setObject);
33 generator.writeEndArray();
34 generator.writeEndArray();