summaryrefslogtreecommitdiff
path: root/dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java
blob: 467ba4be93216ddd7aa284b5dc5a2424e4c353ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.dico.dicore.command.annotation;

import io.dico.dicore.command.parameter.type.ParameterConfig;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface BigRange {
    Class<?> MEMORY_CLASS = Memory.class;
    ParameterConfig<BigRange, Memory> CONFIG = ParameterConfig.getMemoryClassFromField(BigRange.class);
    Memory DEFAULT = new Memory("MIN", "MAX", "0");

    String min() default "MIN";

    String max() default "MAX";

    String defaultValue() default "0";

    class Memory {
        private final String min;
        private final String max;
        private final String defaultValue;

        public Memory(BigRange range) {
            this(range.min(), range.max(), range.defaultValue());
        }

        public Memory(String min, String max, String defaultValue) {
            this.min = min;
            this.max = max;
            this.defaultValue = defaultValue;
        }

        public String min() {
            return min;
        }

        public String max() {
            return max;
        }

        public String defaultValue() {
            return defaultValue;
        }

    }

}