枚举

简介

xxx

示例一

Style

package com.github.ybq.android.spinkit;

public enum Style {
    ROTATING_PLANE(0),
    DOUBLE_BOUNCE(1),
    WAVE(2),
    WANDERING_CUBES(3),
    PULSE(4),
    CHASING_DOTS(5),
    THREE_BOUNCE(6),
    CIRCLE(7),
    CUBE_GRID(8),
    FADING_CIRCLE(9),
    FOLDING_CUBE(10),
    ROTATING_CIRCLE(11),
    MULTIPLE_PULSE(12),
    PULSE_RING(13),
    MULTIPLE_PULSE_RING(14);

    private int value;

    private Style(int value) {
        this.value = value;
    }
}

主代码

Style style = Style.values()[2];

示例二

Classification

package value;

/**
 * Created on 2019/7/23.
 *
 * @author 郑少鹏
 * @desc 类别
 */
public enum Classification {
    /**
     * 节日问候
     */
    HOLIDAY_GREETINGS("节日问候", 1),
    /**
     * 生日问候
     */
    BIRTHDAY_GREETINGS("生日问候", 2),
    /**
     * 用药回访
     */
    DRUG_RETURN_VISIT("用药回访", 3),
    /**
     * 活动通知
     */
    ACTIVITY_NOTICE("活动通知", 4),
    /**
     * 沉睡回访
     */
    SLEEPING_BACK("沉睡回访", 5);
    /**
     * 描述
     */
    private String description;
    /**
     * 标志
     */
    private int flag;

    /**
     * constructor
     *
     * @param description 描述
     * @param flag        标志
     */
    Classification(String description, int flag) {
        this.description = description;
        this.flag = flag;
    }

    /**
     * 类别
     *
     * @param flag 标志
     * @return 类别
     */
    public static Classification getClassification(int flag) {
        for (Classification c : Classification.values()) {
            if (c.flag == flag) {
                return c;
            }
        }
        return null;
    }

    /**
     * 描述
     *
     * @param flag 标志
     * @return 描述
     */
    public static String getDescription(int flag) {
        for (Classification classification : Classification.values()) {
            if (classification.flag == flag) {
                return classification.description;
            }
        }
        return null;
    }

    /**
     * 标志
     *
     * @param description 描述
     * @return 标志
     */
    public static int getFlag(String description) {
        for (Classification c : Classification.values()) {
            if (c.description.equals(description)) {
                return c.flag;
            }
        }
        return 0;
    }

    public String getDescription() {
        return description;
    }

    public int getFlag() {
        return flag;
    }}

主代码

Classification c = Classification.getClassification(flag);
if (null == c) {
    return;
}
switch (c) {
    // 节日问候
    case HOLIDAY_GREETINGS:
        break;
    // 生日问候
    case BIRTHDAY_GREETINGS:
        break;
    // 用药回访
    case DRUG_RETURN_VISIT:
        break;
    // 活动通知
    case ACTIVITY_NOTICE:                
        break;
    // 沉睡回访
    case SLEEPING_BACK:
        break;
    default:
        break;
}
Classification.getDescription(flag);
Classification.getFlag(description);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

snpmyn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值