忽略java枚举的json中的getter

nzkunb0c  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(257)

这是我的枚举:

public enum BundleStatus {
    NEW,
    SUCCESS,
    CANCEL,
    FAIL,
    WAIT_CANCEL,
    PARTIAL_SUCCESS,
    PROCESSING,
    NO_FUNDS,
    HOLD_PAY,
    WAIT_PAY;

    public static final Set<BundleStatus> NO_ACTIVE_STATUSES = new HashSet<>(Arrays.asList(CANCEL, FAIL));

    public static final Set<BundleStatus> SUCCESS_STATUSES = new HashSet<>(Arrays.asList(SUCCESS, PARTIAL_SUCCESS));

    private static final Set<BundleStatus> FAIL_CANCEL_STATUSES = new HashSet<>(Arrays.asList(FAIL, WAIT_CANCEL, CANCEL));

    public static final Set<BundleStatus> STATUS_BUNDLE_FOR_EXECUTE_MAIN = new HashSet<>(
            Arrays.asList(SUCCESS, PARTIAL_SUCCESS, WAIT_CANCEL)
    );

    public static final Set<BundleStatus> STATUS_BUNDLE_FOR_EXECUTE_DEPENDENT = new HashSet<>(
            Arrays.asList(SUCCESS, PARTIAL_SUCCESS, WAIT_CANCEL, CANCEL, FAIL)
    );

    public static final Set<BundleStatus> STATUS_BUNDLE_FOR_GET_PRIMARY = new HashSet<>(
            Arrays.asList(PROCESSING, WAIT_CANCEL, SUCCESS, PARTIAL_SUCCESS)
    );

    public static final Map<String, BundleStatus> EVENT_TYPE_MAPPING = ImmutableMap.of(
            "noFunds", NO_FUNDS,
            "holdPay", HOLD_PAY
    );

    public static final Set<BundleStatus> WAITING_PAY_BUNDLE_STATUSES = new HashSet<>(
            Arrays.asList(WAIT_PAY, HOLD_PAY, NO_FUNDS));

    public boolean isFailCancel() {
        return FAIL_CANCEL_STATUSES.contains(this);
    }

    public boolean isFailCreate() {
        return NO_ACTIVE_STATUSES.contains(this);
    }

    public boolean isSuccessStatus() {
        return SUCCESS_STATUSES.contains(this);
    }

    public boolean isHasActivePayProcess() {
        return WAITING_PAY_BUNDLE_STATUSES.contains(this);
    }
}

当我试图将其序列化为json对象时,我使用map获取对象,其中key是字段的名称(此对象是另一个类的字段),value是包含所有布尔getter的数组:

{
"clientId":"siebel_id_one",
"code":"premium",
"newStatus":{"failCreate":false,"failCancel":false,"hasActivePayProcess":false,"successStatus":true}
}

我希望“newstatus”字段只显示为 "newStatus": "SUCCESS" . 如何修复?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题