001 /**
002 * Property of Hammurapi Group
003 */
004 package com.hammurapi.reasoning.spi;
005
006 import java.lang.annotation.ElementType;
007 import java.lang.annotation.Retention;
008 import java.lang.annotation.RetentionPolicy;
009 import java.lang.annotation.Target;
010
011 /**
012 * This annotation indicates that method is an inference method.
013 *
014 * Rule methods can return facts and post facts (conclusions). Reasoning engine
015 * needs to know types of rule outputs. From rule class introspection
016 * the rule system knows about rule method return type, but it doesn't know
017 * about types posted through <code>post()</code>.
018 *
019 * Also, return type might not be enough, as returned instances may implement
020 * interfaces which other rules are interested in, but which are not declared
021 * in the rule return type.
022 *
023 * Annotation parameter allows rules to inform the inference system about posted types.
024 * <P>
025 * For methods without fact types information
026 * provided through annotation parameter, the rule system uses method return type.
027 *
028 * @author Pavel
029 *
030 */
031 @Target(ElementType.METHOD)
032 @Retention(RetentionPolicy.RUNTIME)
033 public @interface Infer {
034
035 /**
036 * @return Conclusion types posted by this method.
037 */
038 Class<?>[] value() default {};
039
040 /**
041 * @return Inference method priority. Methods with higher priority value get invoked before methods with lower priority value.
042 * Inference method can invoke consume() method from InferenceContext to "consume" source fact(s) and prevent invocation
043 * of subsequent inference methods.
044 */
045 int priority() default 0;
046
047 }