Bug 6235 - Cookie compare in FlowRegistryKeyFactory
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / registry / flow / FlowDescriptorFactory.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.openflowplugin.impl.registry.flow;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
15
16 /**
17  * This class serves as factory for creating {@link org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor}
18  * Created by Martin Bobak <mbobak@cisco.com> on 9.4.2015.
19  */
20 public class FlowDescriptorFactory {
21
22     public static FlowDescriptor create(final short tableId, final FlowId fLowId) {
23         final TableKey tableKey = new TableKey(tableId);
24         return new FlowDescriptorDto(tableKey, fLowId);
25     }
26
27     private static final class FlowDescriptorDto implements FlowDescriptor {
28
29         private final FlowId flowId;
30         private final TableKey tableKey;
31
32         public FlowDescriptorDto(final TableKey tableKey, final FlowId flowId) {
33             Preconditions.checkNotNull(tableKey);
34             Preconditions.checkNotNull(flowId);
35             this.flowId = flowId;
36             this.tableKey = tableKey;
37         }
38
39         @Override
40         public FlowId getFlowId() {
41             return flowId;
42         }
43
44         @Override
45         public TableKey getTableKey() {
46             return tableKey;
47         }
48     }
49 }