X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fforwardingrulesmanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fforwardingrulesmanager%2FPortGroupConfig.java;fp=opendaylight%2Fforwardingrulesmanager%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fforwardingrulesmanager%2FPortGroupConfig.java;h=164f26484e24cd29eedc54e1707b5df8d63c1951;hp=0000000000000000000000000000000000000000;hb=30c334b11097201c8f8a68263bc01efb869c778b;hpb=f9de1cd89c17888a2bd02486d5f7519f0b391bba diff --git a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java new file mode 100644 index 0000000000..164f26484e --- /dev/null +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/PortGroupConfig.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.forwardingrulesmanager; + +import java.io.Serializable; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +/** + * PortGroupConfig class represents the User's Configuration with a Opaque + * Regular Expression String that is parsed and handled by PortGroupProvider. + * + * Typically, the opaque matchString will be a Regular Expression String + * supported by a particular PortGroupProvider based on Customer requirements. + * + * + * + */ +public class PortGroupConfig implements Serializable { + private static final long serialVersionUID = 1L; + private static final String prettyFields[] = { "Name", "Match Criteria" }; + + private String name; + private String matchString; + + /** + * Default Constructor with regular expression string defaulted to ".*" + */ + public PortGroupConfig() { + name = "default"; + matchString = ".*"; + } + + /** + * Constructor to create a Port Group Configuration using a Group Name and + * an Opaque String that is managed by PortGroupProvider. + * + * @param name + * Group Name representing a Port Group configuration + * @param matchString + * An Opaque String managed by PortGroupProvider + */ + public PortGroupConfig(String name, String matchString) { + super(); + this.name = name; + this.matchString = matchString; + } + + /** + * Returns the user configured PortGroup Configuration name. + * + * @return Configuration Name + */ + public String getName() { + return name; + } + + /** + * Assigns a name to the configuration + * + * @param name + * configuration name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the Opaque string + * + * @return + */ + public String getMatchString() { + return matchString; + } + + /** + * Assigns an opaque String to the Configuration. + * + * @param matchString + * Opaque string handled by PortGroupProvider + */ + public void setMatchString(String matchString) { + this.matchString = matchString; + } + + /** + * Returns the names of all the configurable fields in PortGroupConfig. This + * method is typically used by NorthBound apis. + * + * @return List of Field names that can be configured. + */ + public static List getFieldsNames() { + List fieldList = new ArrayList(); + for (Field fld : PortGroupConfig.class.getDeclaredFields()) { + fieldList.add(fld.getName()); + } + // remove static field(s) + fieldList.remove(0); + fieldList.remove(0); + + return fieldList; + } + + /** + * Returns the names of all the configurable fields in PortGroupConfig in + * human readable format for UI purposes. This method is typically used by + * Web/UI apis. + * + * @return List of Human readable Strings that corresponds to the + * configurable field names. + */ + public static List getPrettyFieldsNames() { + List fieldList = new ArrayList(); + for (String str : prettyFields) { + fieldList.add(str); + } + return fieldList; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((matchString == null) ? 0 : matchString.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PortGroupConfig other = (PortGroupConfig) obj; + if (matchString == null) { + if (other.matchString != null) + return false; + } else if (!matchString.equals(other.matchString)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + return "PortGroupConfig [name=" + name + ", matchString=" + matchString + + "]"; + } +}