Future-proof OvsdbTypesIdResolver
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / notation / OvsdbSet.java
1 /*
2  * Copyright (c) 2013, 2015 EBay Software Foundation and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.ovsdb.lib.notation;
10
11 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
12 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
13 import com.google.common.collect.ForwardingSet;
14 import com.google.common.collect.Sets;
15
16 import org.opendaylight.ovsdb.lib.notation.json.Converter;
17 import org.opendaylight.ovsdb.lib.notation.json.OvsdbSetSerializer;
18
19 import java.util.Set;
20
21 @JsonDeserialize(converter = Converter.SetConverter.class)
22 @JsonSerialize(using = OvsdbSetSerializer.class)
23 public class OvsdbSet<T> extends ForwardingSet<T> {
24
25     Set<T> target = null;
26
27     public OvsdbSet() {
28         this(Sets.<T>newHashSet());
29     }
30
31     public OvsdbSet(Set<T> backing) {
32         this.target = backing;
33     }
34
35     @Override
36     public Set<T> delegate() {
37         return target;
38     }
39
40     public static <D> OvsdbSet<D> fromSet(Set<D> value) {
41         return new OvsdbSet<>(value);
42     }
43 }