Skip to content

Commit

Permalink
study annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
deepcloudlabs committed Mar 4, 2021
1 parent 0bc3124 commit d23bf79
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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());

}

}
Original file line number Diff line number Diff line change
@@ -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<Integer> numbers;

public LotteryViewModel() {
}

public List<Integer> getNumbers() {
return numbers;
}

}
25 changes: 25 additions & 0 deletions study-annotations/src/com/example/lottery/model/RandomNumber.java
Original file line number Diff line number Diff line change
@@ -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;

}

0 comments on commit d23bf79

Please sign in to comment.