diff --git a/study-annotations/src/com/example/lottery/application/LotteryApplication.java b/study-annotations/src/com/example/lottery/application/LotteryApplication.java new file mode 100644 index 0000000..fff5065 --- /dev/null +++ b/study-annotations/src/com/example/lottery/application/LotteryApplication.java @@ -0,0 +1,13 @@ +package com.example.lottery.application; + +import com.example.lottery.model.LotteryViewModel; + +public class LotteryApplication { + + public static void main(String[] args) { + LotteryViewModel model = new LotteryViewModel(); + System.out.println(model.getNumbers()); + + } + +} diff --git a/study-annotations/src/com/example/lottery/model/LotteryViewModel.java b/study-annotations/src/com/example/lottery/model/LotteryViewModel.java new file mode 100644 index 0000000..888e90a --- /dev/null +++ b/study-annotations/src/com/example/lottery/model/LotteryViewModel.java @@ -0,0 +1,18 @@ +package com.example.lottery.model; + +import java.util.List; + +public class LotteryViewModel { + // metadata + // @RandomNumber(min=1,max=60,size=6,sorted=true,unique=true) + @RandomNumber + private List numbers; + + public LotteryViewModel() { + } + + public List getNumbers() { + return numbers; + } + +} diff --git a/study-annotations/src/com/example/lottery/model/RandomNumber.java b/study-annotations/src/com/example/lottery/model/RandomNumber.java new file mode 100644 index 0000000..4c579f7 --- /dev/null +++ b/study-annotations/src/com/example/lottery/model/RandomNumber.java @@ -0,0 +1,25 @@ +package com.example.lottery.model; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD,ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface RandomNumber { + int min() default 1; + + int max() default 60 ; + + int size() default 6; + + boolean unique() default true; + + boolean sorted() default true; + +}