2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.forwardingrulesmanager;
11 import java.io.Serializable;
12 import java.lang.reflect.Field;
13 import java.util.ArrayList;
14 import java.util.List;
17 * PortGroupConfig class represents the User's Configuration with a Opaque
18 * Regular Expression String that is parsed and handled by PortGroupProvider.
20 * Typically, the opaque matchString will be a Regular Expression String
21 * supported by a particular PortGroupProvider based on Customer requirements.
26 public class PortGroupConfig implements Serializable {
27 private static final long serialVersionUID = 1L;
28 private static final String prettyFields[] = { "Name", "Match Criteria" };
31 private String matchString;
34 * Default Constructor with regular expression string defaulted to ".*"
36 public PortGroupConfig() {
42 * Constructor to create a Port Group Configuration using a Group Name and
43 * an Opaque String that is managed by PortGroupProvider.
46 * Group Name representing a Port Group configuration
48 * An Opaque String managed by PortGroupProvider
50 public PortGroupConfig(String name, String matchString) {
53 this.matchString = matchString;
57 * Returns the user configured PortGroup Configuration name.
59 * @return Configuration Name
61 public String getName() {
66 * Assigns a name to the configuration
71 public void setName(String name) {
76 * Returns the Opaque string
80 public String getMatchString() {
85 * Assigns an opaque String to the Configuration.
88 * Opaque string handled by PortGroupProvider
90 public void setMatchString(String matchString) {
91 this.matchString = matchString;
95 * Returns the names of all the configurable fields in PortGroupConfig. This
96 * method is typically used by NorthBound apis.
98 * @return List of Field names that can be configured.
100 public static List<String> getFieldsNames() {
101 List<String> fieldList = new ArrayList<String>();
102 for (Field fld : PortGroupConfig.class.getDeclaredFields()) {
103 fieldList.add(fld.getName());
105 // remove static field(s)
113 * Returns the names of all the configurable fields in PortGroupConfig in
114 * human readable format for UI purposes. This method is typically used by
117 * @return List of Human readable Strings that corresponds to the
118 * configurable field names.
120 public static List<String> getPrettyFieldsNames() {
121 List<String> fieldList = new ArrayList<String>();
122 for (String str : prettyFields) {
129 public int hashCode() {
130 final int prime = 31;
132 result = prime * result + ((matchString == null) ? 0 : matchString.hashCode());
133 result = prime * result + ((name == null) ? 0 : name.hashCode());
138 public boolean equals(Object obj) {
143 if (getClass() != obj.getClass())
145 PortGroupConfig other = (PortGroupConfig) obj;
146 if (matchString == null) {
147 if (other.matchString != null)
149 } else if (!matchString.equals(other.matchString))
152 if (other.name != null)
154 } else if (!name.equals(other.name))
160 public String toString() {
161 return "PortGroupConfig [name=" + name + ", matchString=" + matchString + "]";