[rules-users] List<String> wrongly coerced to Object
aitchnyu
jesvinj at technovia.co.in
Wed Mar 21 02:51:00 EDT 2012
I want to compare two List<String>'s if they have elements in common. I made
the following rule (actually two of them):
*----rule----*
rule "hardConflictIsIn"
when
$hc : HardConstraint(
$attribute : attribute,
operator == "is in",
$values : strAttributeValue,
$period : period
)
$stp : SubjectTeacherPeriod(
period == $period,
//Collections.disjoint( $t.attributes["tags"], values_list)
eval( Collections.disjoint( *strAttributeMap.get($attribute)*,
$values) == false )
)
then
insertLogical(new IntConstraintOccurrence("hardConflictIsIn",
ConstraintType.NEGATIVE_HARD,1,
$hc,$stp));
end
*----rule----*
But I get the following error:
*----error----*
Exception in thread "main" java.lang.IllegalStateException: There are errors
in the scoreDrl's:
Rule Compilation error : [Rule name='hardConflictNotIn']
in/co/technovia/timetabler/domain/Rule_hardConflictNotIn_8b50378322e744d883618db9941a8e66.java
(9:1204) : The method disjoint(Collection<?>, Collection<?>) in the type
Collections is not applicable for the arguments (*Object*, List)
Rule Compilation error : [Rule name='hardConflictIsIn']
in/co/technovia/timetabler/domain/Rule_hardConflictIsIn_d7f4ca0884754cf894e7cbdb96cee30e.java
(9:1203) : The method disjoint(Collection<?>, Collection<?>) in the type
Collections is not applicable for the arguments (Object, List)
at
org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
at
org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
at
org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
at
in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)
*----error----*
So something get'ted from the map SubjectTeacherPeriod.strAttributeMap is
wrongly coerced to an Object? I defined my SubjectTeacherPeriod class this
way:
*----class snippet----*
public class SubjectTeacherPeriod{
...
private Map<String, Integer> num_attribute_map = new HashMap<String,
Integer>();
private Map<String,List<String>> str_attribute_map = new
HashMap<String,List<String>>();
...
public Map<String,List<String>> getStrAttributeMap(){
return this.str_attribute_map;
}
...
*----class snippet----*
How can I fix this?
--
View this message in context: http://drools.46999.n3.nabble.com/List-String-wrongly-coerced-to-Object-tp3844867p3844867.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list