ETimeConstraint is a (Java) identifier, for the enum type. There is no
way this can be "contains"-ed in any collection.
ETimeConstraint.name isn't any proper way of accessing anything in
connection with enum type ETimeConstraint.
Correct would be
descriptor contains ETimeConstraint.TODAY
and, provided that contextIntention is of type ETimeConstraint, so is
$cm: Condition( $timeConstraint: contextIntention )
$sentences: ArrayList() from
collect (IPhoneSentences.Sentence(descriptor contains $timeConstraint
Notice that a List<Object> descriptor could contain
ETimeConstraint.TODAY.name()
which is a String value.
-W
2011/9/13 Hezi Stern <hezis(a)delegatecom.com>:
I have encountered the following problem using enums in drools.
I have an enum defined called ETimeConstraint, something of the sort:
public enum ETimeConstraint {
NO_CONSTRAINT,
TODAY,
TOMORROW,
;
}
Now I wish to filter sentences which reside in the working memory based on a
time constraint which is of this enum type.
I created the following test rule
rule "My Test"
when
$sentences: ArrayList()
from collect (IPhoneSentences.Sentence(
descriptor contains ETimeConstraint
))
then
//something
end
this does not work meaning no sentence are selected although I know that
there are sentences in the working memory.
but when I add ETimeConstraint.name it does:
rule "My Test"
when
$sentences: ArrayList()
from collect (IPhoneSentences.Sentence(
descriptor contains ETimeConstraint.name
))
then
//something
end
I can stick to this workaround but it becomes very problematic to work this
way. Furthermore once I wish to define a variable for example defining
$timeConstraint :
rule "My Test"
when
$cm: Condition(
$timeConstraint:
contextIntention,
)
$sentences: ArrayList()
from collect (IPhoneSentences.Sentence(
descriptor contains $timeConstraint
))
then
//something
end
this will not work because I can’t put $timeConstraint.name
any suggestions?
I am running:
- Drools 5.2.0
- Eclipse Helios
- JBoss 5.1.0
Thanks
Hezi
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users