58bf6d81d44e768035a46840e3aa26947206e1c7
[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 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 /**
17  * Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
18  */
19 public final class FlowUtil {
20
21     private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
22     private static final AtomicInteger unaccountedFlowsCounter = new AtomicInteger(0);
23     private static final Logger LOG = LoggerFactory.getLogger(FlowUtil.class);
24
25
26     private FlowUtil() {
27         throw new IllegalStateException("This class should not be instantiated.");
28     }
29
30     public static FlowId createAlienFlowId(final short tableId) {
31         final StringBuilder sBuilder = new StringBuilder(ALIEN_SYSTEM_FLOW_ID)
32                 .append(tableId).append('-').append(unaccountedFlowsCounter.incrementAndGet());
33         String alienId =  sBuilder.toString();
34         return new FlowId(alienId);
35
36     }
37 }