2 * Copyright (C) 2013 Red Hat, Inc.
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
8 * Authors : Madhu Venugopal, Ashwin Raveendran
10 package org.opendaylight.ovsdb.lib.notation.json;
12 import java.io.IOException;
15 import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
17 import com.fasterxml.jackson.core.JsonGenerator;
18 import com.fasterxml.jackson.core.JsonProcessingException;
19 import com.fasterxml.jackson.databind.JsonSerializer;
20 import com.fasterxml.jackson.databind.SerializerProvider;
22 public class OvsDBSetSerializer extends JsonSerializer<OvsDBSet<?>> {
24 public void serialize(OvsDBSet<?> set, JsonGenerator generator,
25 SerializerProvider provider) throws IOException,
26 JsonProcessingException {
27 generator.writeStartArray();
28 generator.writeString("set");
29 generator.writeStartArray();
30 Set<?> javaSet = set.delegate();
31 for (Object t : javaSet) {
32 generator.writeObject(t);
34 generator.writeEndArray();
35 generator.writeEndArray();