Merge "Topology manager - implementation of NodeChangeListener"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / util / FlowUtil.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.util;
10
11 import java.util.concurrent.atomic.AtomicInteger;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
13
14 /**
15  * Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
16  */
17 public final class FlowUtil {
18
19     private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
20     private static final AtomicInteger unaccountedFlowsCounter = new AtomicInteger(0);
21
22
23     private FlowUtil() {
24         throw new IllegalStateException("This class should not be instantiated.");
25     }
26
27     public static FlowId createAlienFlowId(final Short tableId) {
28         final StringBuilder sBuilder = new StringBuilder(ALIEN_SYSTEM_FLOW_ID)
29                 .append(tableId).append("-").append(unaccountedFlowsCounter.incrementAndGet());
30         return new FlowId(sBuilder.toString());
31
32     }
33 }