[rules-users] Evaluator 'matches' does not support type 'ValueType = 'Object'

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jan 31 05:18:46 EST 2013


Revert to eval() which lets you write plain old Java code:

  $sc: StringCapability(name=="data.modelCode",
         eval( $sc.getValue().matches( "^5G1.*") ) )

Perhaps you may have to add a cast.
-W

On 31/01/2013, CAK <carsten.kaiser at valtech.de> wrote:
> Hello forum,
>
> we currently encounter the following problem on Drools 5.1.1:
>
> Evaluator 'matches' does not support type 'ValueType = 'Object' for the
> following rule:
>
> rule "Create_License"
> when
> 	StringCapability(name=="service", value=="service_v1")
> 	StringCapability(name=="data.modelCode", value matches "^5G1.*")
> then
> 	License license = new License();
> 	license.setDuration("30 years");
> 	license.setName("30Years");
> 	license.setState(State.NOTACTIVATED);
> 	license.setType(Type.IMPLICIT);
> 	license.setWarn(false);
> 	insert(license);
> end
>
> StringCapability derives from a generic class and is defined as follows:
>
> public class StringCapability extends Capability <String>
> {
>     public StringCapability(String name, String value)
>     {
>         super(name, value);
>     }
> }
>
> whereas the superclass looks like this
>
> public abstract class Capability<T>
> {
>     private final String name;
>     private final T value;
>
>     protected Capability(String name, T value)
>     {
>         this.name = name;
>         this.value = value;
>     }
>
>     @Override
>     public boolean equals(Object object)
>     {
>         if (this == object)
>         {
>             return true;
>         }
>
>         if (object == null)
>         {
>             return false;
>         }
>
>         if (getClass() != object.getClass())
>         {
>             return false;
>         }
>
>         Capability <?> other = (Capability <?>) object;
>
>         if (name == null)
>         {
>             if (other.name != null)
>             {
>                 return false;
>             }
>         }
>         else if (!name.equals(other.name))
>         {
>             return false;
>         }
>
>         if (value == null)
>         {
>             if (other.value != null)
>             {
>                 return false;
>             }
>         }
>         else if (!value.equals(other.value))
>         {
>             return false;
>         }
>
>         return true;
>     }
>
>     public String getName()
>     {
>         return name;
>     }
>
>     public T getValue()
>     {
>         return value;
>     }
>
>     @Override
>     public int hashCode()
>     {
>         final int prime = 31;
>         int result = 1;
>
>         result = prime * result + getClass().hashCode();
>         result = prime * result + ((name == null) ? 0 : name.hashCode());
>         result = prime * result + ((value == null) ? 0 : value.hashCode());
>
>         return result;
>     }
>
>     @Override
>     public String toString()
>     {
>         return new StringBuilder(getClass().getSimpleName()).append(" -
> name:").append(name).append(", value:")
>                 .append(String.valueOf(value)).toString();
>     }
>
> The problem occurs when the rule is supposed to be compiled on
> initialization of the knowledge base. So from my point of view, the value
> returned by class StringCapability is of type String. Why do I get this
> error? How can I workaround this problem without any code change (I just
> can
> provide another rule file)
>
> Any help appreciated!
>
> Thank you,
> CAK
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Evaluator-matches-does-not-support-type-ValueType-Object-tp4021987.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list