Author: simonetripodi
Date: Thu Jun 16 16:23:00 2011
New Revision: 1136528
URL: http://svn.apache.org/viewvc?rev=1136528&view=rev
Log:
fixed method interception
added missing javadoc
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InvertedEdgeAdapter.java
Modified:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InvertedEdgeAdapter.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InvertedEdgeAdapter.java?rev=1136528&r1=1136527&r2=1136528&view=diff
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InvertedEdgeAdapter.java
(original)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/InvertedEdgeAdapter.java
Thu Jun 16 16:23:00 2011
@@ -28,14 +28,22 @@ import org.apache.commons.graph.Edge;
import org.apache.commons.graph.Vertex;
/**
- *
+ * Simple {@link Edge} Proxy that inverts head/tail for undirectedGraph
implementations.
*
- * @param <V>
+ * @param <V> the Graph vertices type
*/
final class InvertedEdgeAdapter<V extends Vertex>
implements Edge<V>, InvocationHandler
{
+ /**
+ * Creates a new inverted {@link Edge}.
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param edge the edge has to be inverted
+ * @return
+ */
public static <V extends Vertex, E extends Edge<V>> E invertHeadAndTail( E
edge )
{
@SuppressWarnings( "unchecked" ) // type driven by input
@@ -46,6 +54,11 @@ final class InvertedEdgeAdapter<V extend
private final Edge<V> adapted;
+ /**
+ * Creates a new inverted {@link Edge}, wrapping a default one.
+ *
+ * @param adapted the wrapped Edge
+ */
private InvertedEdgeAdapter( Edge<V> adapted )
{
this.adapted = adapted;
@@ -68,17 +81,19 @@ final class InvertedEdgeAdapter<V extend
}
/**
- *
- * @param arg0
- * @param arg1
- * @param arg2
- * @return
- * @throws Throwable
+ * {@inheritDoc}
*/
public Object invoke( Object proxy, Method method, Object[] args )
throws Throwable
{
- return method.invoke( this, args );
+ try
+ {
+ return method.invoke( this, args );
+ }
+ catch ( Throwable t )
+ {
+ return method.invoke( adapted, args );
+ }
}
}