ZenMembers and ZenProperties

ZenMembers are a ZenObject’s members.
They can be accesses using object.member. Members can be settable, gettable or both.

Getters and Setters

There are two Types of ZenGetters: ZenGetters and ZenMemberGetters.
So what’s the difference?

Normally you use @ZenGetter(value), unless you have something which has either many members that return the same type or if you don’t know the exact members yourself.
In that case you can use @ZenMemberGetter.
So what’s the difference?

The same applies for ZenSetters/ZenMemberSetters.

ZenProperty

The @ZenProperty combines both, @ZenGetter(value) and @ZenSetter in one annotation.
This annotation can only be applied to public fields (e.g. public String name).

This Annotation can have these arguments:

You can even omit the getter/setter method alltogether if you use @ZenProperty.
If you do use those methods, however, you will need to add @ZenMethod should you want this functionality, if you omit the methods, they will be generated automatically.

Examples

ZenGetters Example

Crafttweaker’s IOreDict

@ZenClass("crafttweaker.oredict.IOreDict")
@IterableSimple("crafttweaker.oredict.IOreDictEntry")
@ZenRegister
public interface IOreDict extends Iterable<IOreDictEntry> {


    @ZenMemberGetter
    @ZenOperator(OperatorType.INDEXGET)
    @ZenMethod
    IOreDictEntry get(String name);

    @ZenGetter("entries")
    List<IOreDictEntry> getEntries();

    @ZenOperator(OperatorType.CONTAINS)
    @ZenMethod
    boolean contains(String name);
}

ZenProperties Example

ContentTweaker’s MCAxisAlignedBB

@ZenRegister
@ZenClass("mods.contenttweaker.AxisAlignedBB")
public class MCAxisAlignedBB implements ICTObject<AxisAlignedBB> {
    @ZenProperty
    public double minX = 0.0;

    ...

    @ZenMethod
    public double getMinX() {
        return minX;
    }

    @ZenMethod
    public void setMinX(double minX) {
        this.minX = minX;
    }

    ...

}