[rules-users] Drools causes switch(enum e) to break?

Wolfgang Laun wolfgang.laun at gmail.com
Mon Apr 14 06:45:34 EDT 2014


RuleType*s* or RuleType?

Also, you are posting Java code. How is this related to Drools?

Above all, post error messages in full, stating when and due to which
command they are emitted.

-W


On 14/04/2014, Leonard93 <leonardlindenau at hotmail.com> wrote:
> So I have a really weird problem and I think it could be relate-able to
> Drools, or maybe not but maybe some people here have seen it before.
>
> I have a simple enum called 'RuleTypes' which is defined in its own file.
> I have somewhere in my class a switch statement where I use the enum like
> this:
>
> (The method is not finished, but its enough to show the problem)
>
> 	public IResult EvaluateRule(Object obj, RuleType type)
> 	{
> 		//TODO
> 		switch(type)
> 		{
> 			case Discount :
> 				TripRequest lr = (TripRequest) obj;
> 				_Session.execute(lr);
> 				return lr.getResult();
> 			case Content:
> 				break;
> 			case None:
> 				break;
> 			default:
> 				break;
> 		}
> 		
> 		return null;
> 	}
>
> But I get an error saying 'Cannot switch on a value of type RuleType. Only
> convertible int values or enum variables are permitted'. While RuleType an
> enum is 100% sure.
>
> Yet if I make a new project (with no drools libraries), make the same
> RuleType enum in its own file and have an empty class doing:
>
> 	public Test(RuleType type)
> 	{
> 		switch(type)
> 		{
> 			case Discount :
> 				break;
> 			case Content:
> 				break;
> 			case None:
> 				break;
> 			default:
> 				break;
> 		}
> 	}
>
> There are no compiler errors. Anyone know here what could possibly happen?
> The only thing I could find was a possible Eclipse bug but that one had a
> fix that does not work for me (
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=413368 ).
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp4029233.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