Structures and Fields

In order to reference fields and re-use them, GreenLightning convention specifies to use enums for the field type (although any other object could work as well).

The same idea is applied to routes, which are referred to structures inside GreenLighting. To reference a route, we can simply use the enum.

For this tutorial, we need to have two different enums: HelloField, which will contain the fields we are expecting, and HelloStruct, which references the two different routes we have.

Edit two files named HelloField and HelloStruct the following content:

HelloFields.java
package com.ociweb;

public enum HelloField {
    NAME, MONEY, AGE
}
HelloStruct.java
package com.ociweb

public enum HelloStruct {
    HELLO_WORLD, ABOUT
}

The errors from before should now disappear.

On the next page, we will start creating our behaviors and the core logic of our REST API.

Last updated