Make fields private to get classes immutable
Change-Id: Ib2d6c013b8c027b2ddc6a7d1cb204627a2dd7b19
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
index 004964d..f4279e5 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
@@ -69,15 +69,15 @@
@Override
public List<Object> components() {
- return id.components;
+ return id.components();
}
@Override
public Object last() {
- if (id.components.isEmpty()) {
+ if (id.components().isEmpty()) {
return null;
}
- return id.components.get(id.components.size() - 1);
+ return id.components().get(id.components().size() - 1);
}
@Override
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java
index b0937bc..19a9162 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java
@@ -30,7 +30,7 @@
*/
@Beta
public final class ContinuousResourceId extends ResourceId {
- final ImmutableList<Object> components;
+ private final ImmutableList<Object> components;
// for printing purpose only (used in toString() implementation)
private final String name;
@@ -45,6 +45,10 @@
this.name = last.getSimpleName();
}
+ ImmutableList<Object> components() {
+ return components;
+ }
+
/**
* {@inheritDoc}
*
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
index a988989..e88a2a3 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
@@ -65,15 +65,15 @@
@Override
public List<Object> components() {
- return id.components;
+ return id.components();
}
@Override
public Object last() {
- if (id.components.isEmpty()) {
+ if (id.components().isEmpty()) {
return null;
}
- return id.components.get(id.components.size() - 1);
+ return id.components().get(id.components().size() - 1);
}
@Override
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java
index 035561d..92a98b8 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java
@@ -31,7 +31,7 @@
*/
@Beta
public final class DiscreteResourceId extends ResourceId {
- final ImmutableList<Object> components;
+ private final ImmutableList<Object> components;
DiscreteResourceId(ImmutableList<Object> components) {
this.components = components;
@@ -41,6 +41,10 @@
this.components = ImmutableList.of();
}
+ ImmutableList<Object> components() {
+ return components;
+ }
+
@Override
public DiscreteResourceId child(Object child) {
checkArgument(!(child instanceof Class<?>));