/*
@license.text@
 */
package com.hammurapi.reasoning.tutorial.rules;

import com.hammurapi.reasoning.spi.Condition;
import com.hammurapi.reasoning.spi.Infer;
import com.hammurapi.reasoning.tutorial.objectmodel.Child;
import com.hammurapi.reasoning.tutorial.objectmodel.Daughter;
import com.hammurapi.reasoning.tutorial.objectmodel.Father;
import com.hammurapi.reasoning.tutorial.objectmodel.GrandDaughter;
import com.hammurapi.reasoning.tutorial.objectmodel.GrandFather;
import com.hammurapi.reasoning.tutorial.objectmodel.GrandMother;
import com.hammurapi.reasoning.tutorial.objectmodel.GrandSon;
import com.hammurapi.reasoning.tutorial.objectmodel.Mother;
import com.hammurapi.reasoning.tutorial.objectmodel.Parent;
import com.hammurapi.reasoning.tutorial.objectmodel.Son;

public class GrandRules {
		
	/**
	 * Son of child is a grandson.
	 * @param son
	 * @param parent
	 * @return
	 */
	@Infer
	@Condition("son, parent: son.getObject().equals(parent.getObject())")
	public GrandSon infer(Son son, Parent parent) {
		return new GrandSon(son.getSubject(), parent.getSubject());
	}
	
	/**
	 * Daughter of child is a granddaughter.
	 * @param daughter
	 * @param parent
	 * @return
	 */
	@Infer
	@Condition("daughter, parent: daughter.getObject().equals(parent.getObject())")
	public GrandDaughter infer(Daughter daughter, Parent parent) {
		return new GrandDaughter(daughter.getSubject(), parent.getSubject()); 
	}
	
	/**
	 * Father of parent is grandparent.
	 * @param child
	 * @param father
	 * @return
	 */
	@Infer
	@Condition("child, father: child.getObject().equals(father.getObject())")
	public GrandFather infer(Child child, Father father) {
		return new GrandFather(father.getSubject(), child.getSubject());
	}
	
	/**
	 * Mother of parent is grandmother.
	 * @param child
	 * @param mother
	 * @return
	 */
	@Infer
	@Condition("child, mother: child.getObject().equals(mother.getObject())")
	public GrandMother infer(Child child, Mother mother) {
		return new GrandMother(mother.getSubject(), child.getSubject());
	}
	
}
