Bug 3302: fix for GroupTable
[groupbasedpolicy.git] / renderers / ofoverlay / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ofoverlay / equivalence / EquivalenceFabric.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.groupbasedpolicy.renderer.ofoverlay.equivalence;
10
11 import javax.annotation.Nullable;
12
13 import com.google.common.base.Equivalence;
14 import com.google.common.base.Function;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
17
18 /**
19  * A simple fabric for equivalence rules and for functions used<br>
20  *     in converting Lists to Sets with our own equivalence rules
21  */
22 public class EquivalenceFabric {
23
24     private EquivalenceFabric() {
25         throw new UnsupportedOperationException("Can not create an instance");
26     }
27
28     // Flow
29     public static final FlowEquivalence FLOW_EQUIVALENCE = new FlowEquivalence();
30     public static final MatchEquivalence MATCH_EQUIVALENCE = new MatchEquivalence();
31
32     public static final Function<Flow, Equivalence.Wrapper<Flow>> FLOW_WRAPPER_FUNCTION =
33             new Function<Flow, Equivalence.Wrapper<Flow>>() {
34
35                 @Nullable
36                 @Override
37                 public Equivalence.Wrapper<Flow> apply(@Nullable Flow input) {
38                     return FLOW_EQUIVALENCE.wrap(input);
39                 }
40             };
41
42     // Group
43     public static final BucketsEquivalence BUCKETS_EQUIVALENCE = new BucketsEquivalence();
44     public static final GroupEquivalence GROUP_EQUIVALENCE = new GroupEquivalence();
45
46     public static final Function<Group, Equivalence.Wrapper<Group>> GROUP_WRAPPER_FUNCTION =
47             new Function<Group, Equivalence.Wrapper<Group>>() {
48
49                 @Nullable
50                 @Override
51                 public Equivalence.Wrapper<Group> apply(@Nullable Group input) {
52                     return GROUP_EQUIVALENCE.wrap(input);
53                 }
54             };
55
56 }