Setting

enum.use.name

Used to set name as the value when using @see with enum types.

This setting has lower priority than enum.use.custom and enum.use.by.type. Therefore, to use enum.use.name, you need to first disable enum.use.by.type in the recommended configuration.

Assuming the following enum class exists

public enum UserType {
    // Administrator
    ADMIN(1, "Administrator"),

    // Member
    MEMBER(2, "Member"),

    // Guest
    GUEST(3, "Guest");

    private int code;
    private String desc;

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    UserType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
}

For the following field:

/**
* User type
*
* @see UserType
*/
private int type;

Default Case

  • Since the UserType class does not have a type field, by default, the @see UserType in this case will be ignored.

Adding Configuration

  • Configure the default value for @see UserType to use the name field:
enum.use.name[com.itangcent.common.constant.UserType]=true
  • With this configuration, the above comment will be equivalent to:
/**
* User type
* @see UserType#name()
*/
private String type;
  • The exported API result would be:
name type required default desc other
type string Optional User type Enum: ADMIN, MEMBER, GUESTEnum Remarks: ADMIN: Administrator, MEMBER: Member, GUEST: GuestMock: @pick([ADMIN,MEMBER,GUEST])

Unified Handling

  • Declare the following interface:
package com.itangcent.common.constant;

public interface BaseEnum {
}
  • Modify the UserType class to implement the BaseEnum interface:
public enum UserType implements BaseEnum {
    ...
}
  • With this, you can configure all classes that implement BaseEnum to use the name field as the default value:
enum.use.name[groovy:it.isExtend("com.itangcent.common.constant.BaseEnum")]=true

Defaulting to use name for all @see with enum types in the entire project

enum.use.name=true