Skip to content
Snippets Groups Projects
Commit 49207d43 authored by Gregor Maier's avatar Gregor Maier
Browse files

Add helper method that checks if an attribute equals a given object.

parent cf054f2c
No related branches found
No related tags found
No related merge requests found
...@@ -374,6 +374,16 @@ public interface IOFSwitch { ...@@ -374,6 +374,16 @@ public interface IOFSwitch {
* @return value for name * @return value for name
*/ */
Object getAttribute(String name); Object getAttribute(String name);
/**
* Check if the given attribute is present and if so whether it is equal
* to "other"
* @param name the name of the attribute to check
* @param other the object to compare the attribute against.
* @return true iff the specified attribute is set and equals() the given
* other object.
*/
boolean attributeEquals(String name, Object other);
/** /**
* Set properties for switch specific behavior * Set properties for switch specific behavior
......
...@@ -147,13 +147,20 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -147,13 +147,20 @@ public abstract class OFSwitchBase implements IOFSwitch {
this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, new Boolean(true)); this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, new Boolean(true));
} }
@Override
public boolean attributeEquals(String name, Object other) {
Object attr = this.attributes.get(name);
if (attr == null)
return false;
return attr.equals(other);
}
@Override @Override
public Object getAttribute(String name) { public Object getAttribute(String name) {
if (this.attributes.containsKey(name)) { // returns null if key doesn't exist
return this.attributes.get(name); return this.attributes.get(name);
}
return null;
} }
@Override @Override
...@@ -172,6 +179,7 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -172,6 +179,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
return this.attributes.containsKey(name); return this.attributes.containsKey(name);
} }
@Override
@JsonIgnore @JsonIgnore
public void setChannel(Channel channel) { public void setChannel(Channel channel) {
this.channel = channel; this.channel = channel;
...@@ -452,6 +460,7 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -452,6 +460,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
this.floodlightProvider = floodlightProvider; this.floodlightProvider = floodlightProvider;
} }
@Override
@JsonIgnore @JsonIgnore
public void setThreadPoolService(IThreadPoolService tp) { public void setThreadPoolService(IThreadPoolService tp) {
this.threadPool = tp; this.threadPool = tp;
...@@ -560,6 +569,7 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -560,6 +569,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* switch list from being modified out from under the listeners. * switch list from being modified out from under the listeners.
* @return * @return
*/ */
@Override
@JsonIgnore @JsonIgnore
public Lock getListenerReadLock() { public Lock getListenerReadLock() {
return listenerLock.readLock(); return listenerLock.readLock();
...@@ -572,6 +582,7 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -572,6 +582,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* message from the switch. * message from the switch.
* @return * @return
*/ */
@Override
@JsonIgnore @JsonIgnore
public Lock getListenerWriteLock() { public Lock getListenerWriteLock() {
return listenerLock.writeLock(); return listenerLock.writeLock();
...@@ -581,6 +592,7 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -581,6 +592,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* Get the IP Address for the switch * Get the IP Address for the switch
* @return the inet address * @return the inet address
*/ */
@Override
@JsonSerialize(using=ToStringSerializer.class) @JsonSerialize(using=ToStringSerializer.class)
public SocketAddress getInetAddress() { public SocketAddress getInetAddress() {
return channel.getRemoteAddress(); return channel.getRemoteAddress();
......
...@@ -398,4 +398,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { ...@@ -398,4 +398,10 @@ public class OFMessageDamperMockSwitch implements IOFSwitch {
return null; return null;
} }
@Override
public boolean attributeEquals(String name, Object other) {
fail("Unexpected method call");
return false;
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment