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

Ensure that SwitchPort is immutable

it pretty much was immutable already but it wasn't explicit since
members weren't private final. Now they are.
parent 234817aa
No related branches found
No related tags found
No related merge requests found
/**
* Copyright 2012 Big Switch Networks, Inc.
* Copyright 2012 Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
......@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/**
* A simple switch DPID/port pair
* This class is immutable
* @author readams
*
*/
......@@ -31,12 +32,12 @@ public class SwitchPort {
@JsonSerialize(using=ToStringSerializer.class)
public enum ErrorStatus {
DUPLICATE_DEVICE("duplicate-device");
private String value;
ErrorStatus(String v) {
value = v;
}
@Override
public String toString() {
return value;
......@@ -51,10 +52,10 @@ public class SwitchPort {
return null;
}
}
protected long switchDPID;
protected int port;
ErrorStatus errorStatus;
private final long switchDPID;
private final int port;
private final ErrorStatus errorStatus;
/**
* Simple constructor
......@@ -80,7 +81,7 @@ public class SwitchPort {
this.port = port;
this.errorStatus = null;
}
// ***************
// Getters/Setters
// ***************
......@@ -89,11 +90,11 @@ public class SwitchPort {
public long getSwitchDPID() {
return switchDPID;
}
public int getPort() {
return port;
}
public ErrorStatus getErrorStatus() {
return errorStatus;
}
......@@ -101,7 +102,7 @@ public class SwitchPort {
// ******
// Object
// ******
@Override
public int hashCode() {
final int prime = 31;
......
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