Interface FactType

  • All Superinterfaces:
    java.io.Externalizable, java.io.Serializable

    public interface FactType
    extends java.io.Externalizable
    FactType declarations are fact definitions (like classes) that are managed alongside the rules. You then communicate with the KieBase by using instances created by this. There are utility set and get methods on this, as well as in the FactFields. The Object that is used is a javabean (which was generated by the engine). You can also use reflection on it as normal.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object get​(java.lang.Object bean, java.lang.String field)
      Gets the value of the specified field on the dynamic fact.
      java.util.Map<java.lang.String,​java.lang.Object> getAsMap​(java.lang.Object bean)
      Get a map of the fields and their values for the bean.
      java.util.List<Annotation> getClassAnnotations()
      Returns the list of class-level annotations used in this class definition
      java.lang.Class<?> getFactClass()
      Returns the Class<?
      FactField getField​(java.lang.String name)
      Returns the FactField identified by the given name.
      java.util.List<FactField> getFields()
      Returns the list of FactField in this FactType
      java.util.Map<java.lang.String,​java.lang.Object> getMetaData()
      Returns the annotations of this class definition as key-value pairs.
      java.lang.String getName()
      Returns the name of the FactType.
      java.lang.String getPackageName()
      Returns the package this FactType is defined in.
      java.lang.String getSimpleName()
      Returns the unqualified name of the FactType.
      java.lang.String getSuperClass()
      Returns the name of the FactType's super type
      java.lang.Object newInstance()
      Create a new fact based on the declared fact type.
      void set​(java.lang.Object bean, java.lang.String field, java.lang.Object value)
      Sets the value of the field on a fact.
      void setFromMap​(java.lang.Object bean, java.util.Map<java.lang.String,​java.lang.Object> values)
      Sets the values of the bean from a map.
      • Methods inherited from interface java.io.Externalizable

        readExternal, writeExternal
    • Method Detail

      • getName

        java.lang.String getName()
        Returns the name of the FactType.
        Returns:
        the name of the fact type.
      • getSimpleName

        java.lang.String getSimpleName()
        Returns the unqualified name of the FactType.
        Returns:
        the name of the fact type.
      • getPackageName

        java.lang.String getPackageName()
        Returns the package this FactType is defined in.
        Returns:
        the name of the fact type's package.
      • getSuperClass

        java.lang.String getSuperClass()
        Returns the name of the FactType's super type
        Returns:
        the name of the fact type's super type.
      • getFields

        java.util.List<FactField> getFields()
        Returns the list of FactField in this FactType
        Returns:
        the list of the fields in this FactType
      • getField

        FactField getField​(java.lang.String name)
        Returns the FactField identified by the given name.
        Parameters:
        name - the name of the FactField
        Returns:
        the FactField instance identified by the given name or null if none is found.
      • getFactClass

        java.lang.Class<?> getFactClass()
        Returns the Class<?> for this FactType. The class object can be used through reflection.
        Returns:
        the generated class for this FactType
      • newInstance

        java.lang.Object newInstance()
                              throws java.lang.InstantiationException,
                                     java.lang.IllegalAccessException
        Create a new fact based on the declared fact type. This object will usually be a javabean.
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • set

        void set​(java.lang.Object bean,
                 java.lang.String field,
                 java.lang.Object value)
        Sets the value of the field on a fact.
        Parameters:
        bean - the object on which the field will be set.
        field - the name of the field to set.
        value - the value to be set on the field.
      • get

        java.lang.Object get​(java.lang.Object bean,
                             java.lang.String field)
        Gets the value of the specified field on the dynamic fact.
        Parameters:
        bean - the fact to read the field value from.
        field - the name of the field to read.
        Returns:
        the value of the field read from the fact
      • getAsMap

        java.util.Map<java.lang.String,​java.lang.Object> getAsMap​(java.lang.Object bean)
        Get a map of the fields and their values for the bean.
        Parameters:
        bean - the bean to read the fields from.
        Returns:
        a map of field names and corresponding values on the bean.
      • setFromMap

        void setFromMap​(java.lang.Object bean,
                        java.util.Map<java.lang.String,​java.lang.Object> values)
        Sets the values of the bean from a map.
        Parameters:
        bean - the fact to set the values of the fields on
        values - a map of field names and values to set
      • getClassAnnotations

        java.util.List<Annotation> getClassAnnotations()
        Returns the list of class-level annotations used in this class definition
        Returns:
        the list of class-level annotations
      • getMetaData

        java.util.Map<java.lang.String,​java.lang.Object> getMetaData()
        Returns the annotations of this class definition as key-value pairs.
        Returns:
        a key-value map of the class-level annotations