/*
@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.Husband;
import com.hammurapi.reasoning.tutorial.objectmodel.Spouse;
import com.hammurapi.reasoning.tutorial.objectmodel.Wife;

public class SpouseRules {	
		
	/**
	 * If A is a spouse of B then B is a spouse of A. 
	 * @param spouse
	 */
	@Infer
	public Spouse inferSpouse(Spouse spouse) {
		return new Spouse(spouse.getObject(), spouse.getSubject());
	}
		
	/**
	 * Male spouse is husband.
	 * @param spouse
	 */
	@Infer 
	public Husband inferHusband(@Condition("arg.getSubject().isMale() && !(arg instanceof com.hammurapi.reasoning.tutorial.objectmodel.Husband)") Spouse spouse) {
		return new Husband(spouse.getSubject(), spouse.getObject());
	}
	
	/**
	 * Female spouse is wife.
	 * @param spouse
	 */
	@Infer 
	public Wife inferWife(@Condition("!arg.getSubject().isMale() && !(arg instanceof com.hammurapi.reasoning.tutorial.objectmodel.Wife)") Spouse spouse) {
		return new Wife(spouse.getSubject(), spouse.getObject());
	}
}
