Jess Information

Jess Home
Jess 7 Features
Download Now!
Online Demo

Documentation
FAQ
Manual
Mailing List
Jess Wiki

More information Related Web Sites
User Contributions
JSR94 Info
Developer's Log
About This Site

JESS ®, the Rule Engine for the JavaTM Platform

Jess Wiki: Enumerated Types

I received a private email asking if Jess could work with Java 5 enumerated types. There's no specific code to deal with them, but I wondered if the existing "static import" feature would work. It turns out that it does. I wrote this Java enum class:

public enum MyEnum {
  FOO, BAR, BAZ;
}
Then in Jess 7, I tried this:
Jess> (import MyEnum)
TRUE
Jess> (MyEnum.FOO)
<Java-Object:MyEnum>
Jess> (eq (MyEnum.FOO) (MyEnum.BAR))
FALSE
Jess> (eq (MyEnum.FOO) (MyEnum.FOO))
TRUE

So importing an enum class will make the values available as the functions (EnumName?.FOO), (EnumName?.BAR), etc. Thought this might be of interest to some of you.


Front Page | Sandbox | Recent Changes | Powered by Friki | Last Edited: 13 October 2005