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;
16 import org.opendaylight.controller.configuration.ConfigurationObject;
19 * PortGroupConfig class represents the User's Configuration with a Opaque
20 * Regular Expression String that is parsed and handled by PortGroupProvider.
22 * Typically, the opaque matchString will be a Regular Expression String
23 * supported by a particular PortGroupProvider based on Customer requirements.
28 public class PortGroupConfig extends ConfigurationObject implements Serializable {
29 private static final long serialVersionUID = 1L;
30 private static final String prettyFields[] = { "Name", "Match Criteria" };
33 private String matchString;
36 * Default Constructor with regular expression string defaulted to ".*"
38 public PortGroupConfig() {
44 * Constructor to create a Port Group Configuration using a Group Name and
45 * an Opaque String that is managed by PortGroupProvider.
48 * Group Name representing a Port Group configuration
50 * An Opaque String managed by PortGroupProvider
52 public PortGroupConfig(String name, String matchString) {
55 this.matchString = matchString;
59 * Returns the user configured PortGroup Configuration name.
61 * @return Configuration Name
63 public String getName() {
68 * Assigns a name to the configuration
73 public void setName(String name) {
78 * Returns the Opaque string
82 public String getMatchString() {
87 * Assigns an opaque String to the Configuration.
90 * Opaque string handled by PortGroupProvider
92 public void setMatchString(String matchString) {
93 this.matchString = matchString;
97 * Returns the names of all the configurable fields in PortGroupConfig. This
98 * method is typically used by NorthBound apis.
100 * @return List of Field names that can be configured.
102 public static List<String> getFieldsNames() {
103 List<String> fieldList = new ArrayList<String>();
104 for (Field fld : PortGroupConfig.class.getDeclaredFields()) {
105 fieldList.add(fld.getName());
107 // remove static field(s)
115 * Returns the names of all the configurable fields in PortGroupConfig in
116 * human readable format for UI purposes. This method is typically used by
119 * @return List of Human readable Strings that corresponds to the
120 * configurable field names.
122 public static List<String> getPrettyFieldsNames() {
123 List<String> fieldList = new ArrayList<String>();
124 for (String str : prettyFields) {
131 public int hashCode() {
132 final int prime = 31;
134 result = prime * result + ((matchString == null) ? 0 : matchString.hashCode());
135 result = prime * result + ((name == null) ? 0 : name.hashCode());
140 public boolean equals(Object obj) {
147 if (getClass() != obj.getClass()) {
150 PortGroupConfig other = (PortGroupConfig) obj;
151 if (matchString == null) {
152 if (other.matchString != null) {
155 } else if (!matchString.equals(other.matchString)) {
159 if (other.name != null) {
162 } else if (!name.equals(other.name)) {
169 public String toString() {
170 return "PortGroupConfig [name=" + name + ", matchString=" + matchString + "]";