3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
10 package org.opendaylight.controller.forwardingrulesmanager;
12 import java.io.Serializable;
13 import java.lang.reflect.Field;
14 import java.util.ArrayList;
15 import java.util.List;
18 * PortGroupConfig class represents the User's Configuration with a Opaque Regular Expression
19 * String that is parsed and handled by PortGroupProvider.
21 * Typically, the opaque matchString will be a Regular Expression String supported by a particular
22 * PortGroupProvider based on Customer requirements.
27 public class PortGroupConfig implements Serializable {
28 private static final long serialVersionUID = 1L;
29 private static final String prettyFields[] = { "Name", "Match Criteria" };
32 private String matchString;
35 * Default Constructor with regular expression string defaulted to ".*"
37 public PortGroupConfig() {
43 * Constructor to create a Port Group Configuration using a Group Name and an Opaque
44 * String that is managed by PortGroupProvider.
46 * @param name Group Name representing a Port Group configuration
47 * @param matchString An Opaque String managed by PortGroupProvider
49 public PortGroupConfig(String name, String matchString) {
52 this.matchString = matchString;
56 * Returns the user configured PortGroup Configuration name.
58 * @return Configuration Name
60 public String getName() {
65 * Assigns a name to the configuration
66 * @param name configuration name
68 public void setName(String name) {
73 * Returns the Opaque string
76 public String getMatchString() {
81 * Assigns an opaque String to the Configuration.
83 * @param matchString Opaque string handled by PortGroupProvider
85 public void setMatchString(String matchString) {
86 this.matchString = matchString;
90 * Returns the names of all the configurable fields in PortGroupConfig.
91 * This method is typically used by NorthBound apis.
93 * @return List of Field names that can be configured.
95 public static List<String> getFieldsNames() {
96 List<String> fieldList = new ArrayList<String>();
97 for (Field fld : PortGroupConfig.class.getDeclaredFields()) {
98 fieldList.add(fld.getName());
100 //remove static field(s)
108 * Returns the names of all the configurable fields in PortGroupConfig in human readable format for UI purposes.
109 * This method is typically used by Web/UI apis.
111 * @return List of Human readable Strings that corresponds to the configurable field names.
113 public static List<String> getPrettyFieldsNames() {
114 List<String> fieldList = new ArrayList<String>();
115 for (String str : prettyFields) {
122 public int hashCode() {
123 final int prime = 31;
125 result = prime * result
126 + ((matchString == null) ? 0 : matchString.hashCode());
127 result = prime * result + ((name == null) ? 0 : name.hashCode());
132 public boolean equals(Object obj) {
137 if (getClass() != obj.getClass())
139 PortGroupConfig other = (PortGroupConfig) obj;
140 if (matchString == null) {
141 if (other.matchString != null)
143 } else if (!matchString.equals(other.matchString))
146 if (other.name != null)
148 } else if (!name.equals(other.name))
154 public String toString() {
155 return "PortGroupConfig [name=" + name + ", matchString=" + matchString