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

com.gkutiel.github.flip.graph.Edge Maven / Gradle / Ivy

There is a newer version: 10-RELEASE
Show newest version
package com.gkutiel.github.flip.graph;

import java.util.Map;

public class Edge implements Properties {

	private final String v1;
	private final String v2;
	private final String label;
	private final Db db;

	public Edge(final String v1, final String v2, final String label, final Db db) {
		this.v1 = v1;
		this.v2 = v2;
		this.label = label;
		this.db = db;
	}

	@Override
	public boolean equals(final Object obj) {
		if (obj instanceof Edge) {
			final Edge e = (Edge) obj;
			return v1.equals(v1) && v2.equals(e.v2) && label.equals(e.label);
		}
		return false;
	}

	public Vertex getDestenationVertex() {
		return new Vertex(v2, db);
	}

	@Override
	public Map getProperties() {
		return db.getEdgeProperties(v1, v2, label);
	}

	@Override
	public String getProperty(final String key) {
		return db.getEdgeProperty(v1, v2, label, key);
	}

	public Vertex getSourceVertex() {
		return new Vertex(v1, db);
	}

	@Override
	public int hashCode() {
		return (v1 + v2 + label).hashCode();
	}

	@Override
	public void setProperty(final String key, final Object value) {
		db.setEdgeProperty(v1, v2, label, key, value.toString());
	}

	@Override
	public String toString() {
		return "(" + v1 + " " + v2 + ") " + getProperties();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy