package dkohl.onthology;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

import com.google.common.base.Preconditions;

public class Ontology {

	/**
	 * Thing <- Class
	 */
	private HashMap<String, String> inheritance;

	private HashMap<String, LinkedList<String>> classes2thing;

	public Ontology(HashSet<String> classes) {
		inheritance = new HashMap<String, String>();
		this.classes2thing = new HashMap<String, LinkedList<String>>();
		for (String key : classes) {
			classes2thing.put(key, new LinkedList<String>());
		}
	}

	public void define(String thing, String isA) {
		Preconditions.checkArgument(classes2thing.containsKey(isA), "Class: "
				+ isA + "notDefined");
		LinkedList<String> things = classes2thing.get(isA);
		things.add(thing);
		classes2thing.put(isA, things);
		inheritance.put(thing, isA);
	}

	public HashMap<String, String> getInheritance() {
		return inheritance;
	}

	public HashMap<String, LinkedList<String>> getClasses2thing() {
		return classes2thing;
	}

	public Set<String> getClasses() {
		return classes2thing.keySet();
	}
}
