All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sf.util.graph.DirectedEdge Maven / Gradle / Ivy

Go to download

SchemaCrawler is an open-source Java API that makes working with database metadata as easy as working with plain old Java objects. SchemaCrawler is also a database schema discovery and comprehension, and schema documentation tool. You can search for database schema objects using regular expressions, and output the schema and data in a readable text format. The output is designed to be diff-ed against other database schemas.

There is a newer version: 16.22.2
Show newest version
/*
========================================================================
SchemaCrawler
http://www.schemacrawler.com
Copyright (c) 2000-2016, Sualeh Fatehi .
All rights reserved.
------------------------------------------------------------------------

SchemaCrawler is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SchemaCrawler and the accompanying materials are made available under
the terms of the Eclipse Public License v1.0, GNU General Public License
v3 or GNU Lesser General Public License v3.

You may elect to redistribute this code under any of these licenses.

The Eclipse Public License is available at:
http://www.eclipse.org/legal/epl-v10.html

The GNU General Public License v3 and the GNU Lesser General Public
License v3 are available at:
http://www.gnu.org/licenses/

========================================================================
*/
package sf.util.graph;


/**
 * Directed edge in a graph.
 */
public final class DirectedEdge
{

  private final Vertex from;
  private final Vertex to;

  DirectedEdge(final Vertex from, final Vertex to)
  {
    this.from = from;
    this.to = to;
  }

  /**
   * {@inheritDoc}
   *
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(final Object obj)
  {
    if (this == obj)
    {
      return true;
    }
    if (obj == null)
    {
      return false;
    }
    if (getClass() != obj.getClass())
    {
      return false;
    }
    final DirectedEdge other = (DirectedEdge) obj;
    if (from == null)
    {
      if (other.from != null)
      {
        return false;
      }
    }
    else if (!from.equals(other.from))
    {
      return false;
    }
    if (to == null)
    {
      if (other.to != null)
      {
        return false;
      }
    }
    else if (!to.equals(other.to))
    {
      return false;
    }
    return true;
  }

  public Vertex getFrom()
  {
    return from;
  }

  public Vertex getTo()
  {
    return to;
  }

  /**
   * {@inheritDoc}
   *
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode()
  {
    final int prime = 31;
    int result = 1;
    result = prime * result + (from == null? 0: from.hashCode());
    result = prime * result + (to == null? 0: to.hashCode());
    return result;
  }

  public boolean isFrom(final Vertex vertex)
  {
    return vertex != null && vertex.equals(from);
  }

  public boolean isTo(final Vertex vertex)
  {
    return vertex != null && vertex.equals(to);
  }

  @Override
  public String toString()
  {
    return from + " -> " + to;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy