[rules-users] Evaluator 'matches' does not support type 'ValueType = 'Object'
CAK
carsten.kaiser at valtech.de
Thu Jan 31 04:54:21 EST 2013
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.
More information about the rules-users
mailing list