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 * Originally created by David Erickson, Stanford University
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may * 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 * not use this file except in compliance with the License. You may obtain
* a copy of the License at * a copy of the License at
...@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; ...@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/** /**
* A simple switch DPID/port pair * A simple switch DPID/port pair
* This class is immutable
* @author readams * @author readams
* *
*/ */
...@@ -31,12 +32,12 @@ public class SwitchPort { ...@@ -31,12 +32,12 @@ public class SwitchPort {
@JsonSerialize(using=ToStringSerializer.class) @JsonSerialize(using=ToStringSerializer.class)
public enum ErrorStatus { public enum ErrorStatus {
DUPLICATE_DEVICE("duplicate-device"); DUPLICATE_DEVICE("duplicate-device");
private String value; private String value;
ErrorStatus(String v) { ErrorStatus(String v) {
value = v; value = v;
} }
@Override @Override
public String toString() { public String toString() {
return value; return value;
...@@ -51,10 +52,10 @@ public class SwitchPort { ...@@ -51,10 +52,10 @@ public class SwitchPort {
return null; return null;
} }
} }
protected long switchDPID; private final long switchDPID;
protected int port; private final int port;
ErrorStatus errorStatus; private final ErrorStatus errorStatus;
/** /**
* Simple constructor * Simple constructor
...@@ -80,7 +81,7 @@ public class SwitchPort { ...@@ -80,7 +81,7 @@ public class SwitchPort {
this.port = port; this.port = port;
this.errorStatus = null; this.errorStatus = null;
} }
// *************** // ***************
// Getters/Setters // Getters/Setters
// *************** // ***************
...@@ -89,11 +90,11 @@ public class SwitchPort { ...@@ -89,11 +90,11 @@ public class SwitchPort {
public long getSwitchDPID() { public long getSwitchDPID() {
return switchDPID; return switchDPID;
} }
public int getPort() { public int getPort() {
return port; return port;
} }
public ErrorStatus getErrorStatus() { public ErrorStatus getErrorStatus() {
return errorStatus; return errorStatus;
} }
...@@ -101,7 +102,7 @@ public class SwitchPort { ...@@ -101,7 +102,7 @@ public class SwitchPort {
// ****** // ******
// Object // Object
// ****** // ******
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; 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