package com.tandbergtv.metadatamanager.factoryImpl;

import com.tandbergtv.metadatamanager.model.RelationType;
import com.tandbergtv.metadatamanager.model.ChildParentRelation;
import com.tandbergtv.metadatamanager.model.ParentChildRelation;
import com.tandbergtv.metadatamanager.model.Relation;

public class RelationFactory {

	public static Relation getInstance(String name) {
		if (name.equals(RelationType.PARENT_CHILD.toString())) {
			return new ParentChildRelation();
		} else if (name.equals(RelationType.CHILD_PARENT.toString())) {
			return new ChildParentRelation();
		} else {
			return null;
		}
	}

	public static String getType(Relation relation) {
		if (relation instanceof ParentChildRelation) {
			return RelationType.PARENT_CHILD.toString();
		} else if (relation instanceof ChildParentRelation) {
			return RelationType.CHILD_PARENT.toString();
		} else {
			return null;
		}
	}

	public static Relation getInstance(RelationType type) {
		if (type == RelationType.PARENT_CHILD) {
			return new ParentChildRelation();
		} else if (type == RelationType.CHILD_PARENT) {
			return new ChildParentRelation();
		} else {
			return null;
		}
	}
}
