Author: simonetripodi
Date: Sat Jun 18 00:09:10 2011
New Revision: 1137091
URL: http://svn.apache.org/viewvc?rev=1137091&view=rev
Log:
first checkin of utilities package
Added:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
(with props)
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
(with props)
Added:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java?rev=1137091&view=auto
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
(added)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
Sat Jun 18 00:09:10 2011
@@ -0,0 +1,72 @@
+package org.apache.commons.graph.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.lang.String.format;
+
+import org.apache.commons.graph.Edge;
+import org.apache.commons.graph.Vertex;
+
+/**
+ * Commons utility methods for {@link Edge} manipulation.
+ */
+public final class Edges
+{
+
+ /**
+ * This class can't be instantiated.
+ */
+ private Edges()
+ {
+ // do nothing
+ }
+
+ /**
+ *
+ *
+ * @param <V> the Graph vertices type
+ * @param <E> the Graph edges type
+ * @param vertex
+ * @param edge
+ * @return
+ */
+ public static <V extends Vertex, E extends Edge<V>> V getConnectedVertex(
V vertex, E edge )
+ {
+ if ( vertex == null )
+ {
+ throw new IllegalArgumentException( "Argument 'vertex' must be not
null." );
+ }
+ if ( edge == null )
+ {
+ throw new IllegalArgumentException( "Argument 'edge' must be not
null." );
+ }
+
+ if ( vertex.equals( edge.getHead() ) )
+ {
+ return edge.getTail();
+ }
+ else if ( vertex.equals( edge.getTail() ) )
+ {
+ return edge.getHead();
+ }
+ throw new IllegalArgumentException( format( "Input Vertex %s not
contained in Edge %s", vertex, edge ) );
+ }
+
+}
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/Edges.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java?rev=1137091&view=auto
==============================================================================
---
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
(added)
+++
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
Sat Jun 18 00:09:10 2011
@@ -0,0 +1,23 @@
+/**
+ * Utility tools.
+ */
+package org.apache.commons.graph.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/utils/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain