Android注解约束参数为固定的某几个值
package com.z.z.bean; import androidx.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import static com.z.z.bean.MustPosition.FIRST; import static com.z.z.bean.MustPosition.SECOND; @IntDef({FIRST, SECOND}) @Retention(RetentionPolicy.SOURCE) public @interface MustPosition { public static final int FIRST = 0; public static final int SECOND = 1; }
注解被使用的位置:
/* * 供外部调用,改变此view的被选中条目 */ public void setSlect(@MustPosition int posi) { }