f8b61b0dc470b3cd92c9999224d5f4a4df8690b9
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / utils / TierHelper.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.utils;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15 public final class TierHelper {
16     private static TierHelper tierHelper;
17     public static final int unknownTierNumber = 0;
18     private List<String> tierNames;
19
20     static {
21         tierHelper = new TierHelper();
22     }
23
24     private TierHelper() {
25         tierNames = new ArrayList<String>();
26         tierNames.add("Unknown");
27         tierNames.add("Access");
28         tierNames.add("Distribution");
29         tierNames.add("Core");
30     }
31
32     public static void setTierName(int tier, String name) {
33         if (tier > tierHelper.tierNames.size() - 1) {
34             for (int i = tierHelper.tierNames.size() - 1; i < tier; i++) {
35                 tierHelper.tierNames.add("Unknown");
36             }
37         }
38         tierHelper.tierNames.set(tier, name);
39     }
40
41     public static String getTierName(int tier) {
42         if ((tier < 0) || (tier > tierHelper.tierNames.size() - 1)) {
43             return "Unknown";
44         }
45         return tierHelper.tierNames.get(tier);
46     }
47
48     public static List<String> getTiers() {
49         return tierHelper.tierNames;
50     }
51 }