You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/01/23 22:42:39 UTC
svn commit: r1235005 - in /commons/sandbox/graph/trunk/src: changes/
main/java/org/apache/commons/graph/model/
test/java/org/apache/commons/graph/model/
Author: simonetripodi
Date: Mon Jan 23 21:42:39 2012
New Revision: 1235005
URL: http://svn.apache.org/viewvc?rev=1235005&view=rev
Log:
[SANDBOX-367] Move base implementations from test to main - patch submitted by Claudio Squarcella
Added:
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java (with props)
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java (with props)
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java (with props)
Removed:
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledEdge.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledVertex.java
commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
Modified:
commons/sandbox/graph/trunk/src/changes/changes.xml
Modified: commons/sandbox/graph/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/changes/changes.xml?rev=1235005&r1=1235004&r2=1235005&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/graph/trunk/src/changes/changes.xml Mon Jan 23 21:42:39 2012
@@ -23,6 +23,9 @@
</properties>
<body>
<release version="0.1" date="201?-??-??" description="First release.">
+ <action dev="simonetripodi" type="update" issue="SANDBOX-367" due-to="Claudio Squarcella">
+ Move base implementations from test to main
+ </action>
<action dev="simonetripodi" type="update" issue="SANDBOX-366">
Move Graph algorithms APIs to fluent APIs
</action>
Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java?rev=1235005&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java Mon Jan 23 21:42:39 2012
@@ -0,0 +1,99 @@
+package org.apache.commons.graph.model;
+
+/*
+ * 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 static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.Edge;
+import org.apache.commons.graph.Labeled;
+
+public class BaseLabeledEdge
+ implements Edge, Labeled
+{
+
+ private final String label;
+
+ public BaseLabeledEdge( String label )
+ {
+ this.label = checkNotNull( label, "Argument 'label' must not be null" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + label.hashCode();
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ BaseLabeledEdge other = (BaseLabeledEdge) obj;
+
+ if ( !label.equals( other.label ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return format( "%s()", getLabel() );
+ }
+
+}
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledEdge.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java?rev=1235005&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java Mon Jan 23 21:42:39 2012
@@ -0,0 +1,98 @@
+package org.apache.commons.graph.model;
+
+/*
+ * 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 static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.Labeled;
+import org.apache.commons.graph.Vertex;
+
+public class BaseLabeledVertex
+ implements Labeled, Vertex
+{
+
+ private final String label;
+
+ public BaseLabeledVertex( String label )
+ {
+ this.label = checkNotNull( label, "Argument 'label' must not be null" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + label.hashCode();
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ BaseLabeledVertex other = (BaseLabeledVertex) obj;
+ if ( !label.equals( other.getLabel() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return format( "{ %s }", label );
+ }
+
+}
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledVertex.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java?rev=1235005&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java (added)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java Mon Jan 23 21:42:39 2012
@@ -0,0 +1,102 @@
+package org.apache.commons.graph.model;
+
+/*
+ * 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 static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
+import org.apache.commons.graph.WeightedEdge;
+
+/**
+ *
+ */
+public class BaseLabeledWeightedEdge<W>
+ extends BaseLabeledEdge
+ implements WeightedEdge<W>
+{
+
+ private final W weight;
+
+ public BaseLabeledWeightedEdge( String label, W weight )
+ {
+ super( label );
+ this.weight = checkNotNull( weight, "Argument 'weight' must not be null" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public W getWeight()
+ {
+ return weight;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + weight.hashCode();
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( !super.equals( obj ) )
+ {
+ return false;
+ }
+
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+ @SuppressWarnings( "unchecked" )
+ BaseLabeledWeightedEdge<W> other = (BaseLabeledWeightedEdge<W>) obj;
+ if ( !weight.equals( other.getWeight() ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return format( "%s( %s )", getLabel(), weight );
+ }
+
+}
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/model/BaseLabeledWeightedEdge.java
------------------------------------------------------------------------------
svn:mime-type = text/plain