Author: simonetripodi
Date: Sat Jun 11 22:17:23 2011
New Revision: 1134795
URL: http://svn.apache.org/viewvc?rev=1134795&view=rev
Log:
returned collections are read-only data structures
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java?rev=1134795&r1=1134794&r2=1134795&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/domain/basic/DirectedGraphImpl.java
Sat Jun 11 22:17:23 2011
@@ -19,6 +19,8 @@ package org.apache.commons.graph.domain.
* under the License.
*/
+import static java.util.Collections.unmodifiableSet;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -136,7 +138,7 @@ public class DirectedGraphImpl<V extends
*/
public Set<V> getVertices()
{
- return new HashSet(vertices);
+ return unmodifiableSet(vertices);
}
/**
@@ -163,7 +165,7 @@ public class DirectedGraphImpl<V extends
*/
public Set<WE> getEdges()
{
- return new HashSet(edges);
+ return unmodifiableSet(edges);
}
/**
@@ -209,7 +211,7 @@ public class DirectedGraphImpl<V extends
{
if (inbound.containsKey(v))
{
- return new HashSet(inbound.get(v));
+ return unmodifiableSet(inbound.get(v));
}
else
{
@@ -224,7 +226,7 @@ public class DirectedGraphImpl<V extends
{
if (outbound.containsKey(v))
{
- return new HashSet(outbound.get(v));
+ return unmodifiableSet(outbound.get(v));
}
else
{