/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CityDoctor2 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.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2.math.graph;

import java.util.HashSet;
import java.util.Set;

import de.hft.stuttgart.citydoctor2.datastructure.Polygon;

/**
 * Node in the polygon graph
 * 
 * @author Matthias Betz
 *
 */
public class PolygonNode {

	private Polygon content;
	private Set<PolygonNode> children;
	private boolean visited = false;

	public PolygonNode(Polygon p) {
		children = new HashSet<>();
		content = p;
	}

	public void addChild(PolygonNode node) {
		children.add(node);
	}

	public Set<PolygonNode> getChildren() {
		return children;
	}

	public Polygon getContent() {
		return content;
	}

	public void setVisited(boolean b) {
		this.visited = b;
	}

	public boolean visited() {
		return visited;
	}

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

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PolygonNode other = (PolygonNode) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return content.toString();
	}

}
