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

import com.hammurapi.reasoning.spi.Infer;
import com.hammurapi.reasoning.tutorial.objectmodel.Father;
import com.hammurapi.reasoning.tutorial.objectmodel.Mother;
import com.hammurapi.reasoning.tutorial.objectmodel.Parent;

public class ParentRules {	
	
	/**
	 * Male parent is father, female parent is mother.
	 * @param parent
	 * @return Brother or Sister.
	 */
	@Infer({Father.class, Mother.class})
	public Parent infer(Parent parent) {	
		
		if (parent.getSubject().isMale()) {
			if (!(parent instanceof Father)) {
				return new  Father(parent.getSubject(), parent.getObject());
			}			
		} else {
			if (!(parent instanceof Mother)) {
				return new Mother(parent.getSubject(), parent.getObject());
			}			
		}
		return null;
	}
}
