| 3032 | } |
| 3033 | |
| 3034 | private static class EnumElementRule<V extends Enum<V>> |
| 3035 | implements ElementRule<PlainDate, V> { |
| 3036 | |
| 3037 | //~ Instanzvariablen ---------------------------------------------- |
| 3038 | |
| 3039 | private final String name; |
| 3040 | private final Class<V> type; |
| 3041 | private final V min; |
| 3042 | private final V max; |
| 3043 | private final int index; |
| 3044 | |
| 3045 | //~ Konstruktoren ------------------------------------------------- |
| 3046 | |
| 3047 | EnumElementRule( |
| 3048 | String name, |
| 3049 | Class<V> type, |
| 3050 | V min, |
| 3051 | V max, |
| 3052 | int index |
| 3053 | ) { |
| 3054 | super(); |
| 3055 | |
| 3056 | this.name = name; |
| 3057 | this.type = type; |
| 3058 | this.min = min; |
| 3059 | this.max = max; |
| 3060 | this.index = index; |
| 3061 | |
| 3062 | } |
| 3063 | |
| 3064 | //~ Methoden ------------------------------------------------------ |
| 3065 | |
| 3066 | static <V extends Enum<V>> EnumElementRule<V> of(ChronoElement<V> element) { |
| 3067 | |
| 3068 | return new EnumElementRule<>( |
| 3069 | element.name(), |
| 3070 | element.getType(), |
| 3071 | element.getDefaultMinimum(), |
| 3072 | element.getDefaultMaximum(), |
| 3073 | ((EnumElement<?>) element).getIndex() |
| 3074 | ); |
| 3075 | |
| 3076 | } |
| 3077 | |
| 3078 | @Override |
| 3079 | public V getValue(PlainDate context) { |
| 3080 | |
| 3081 | Object ret; |
| 3082 | |
| 3083 | switch (this.index) { |
| 3084 | case EnumElement.MONTH: |
| 3085 | ret = Month.valueOf(context.month); |
| 3086 | break; |
| 3087 | case EnumElement.DAY_OF_WEEK: |
| 3088 | ret = context.getDayOfWeek(); |
| 3089 | break; |
| 3090 | case EnumElement.QUARTER_OF_YEAR: |
| 3091 | ret = Quarter.valueOf(((context.month - 1) / 3) + 1); |
nothing calls this directly
no outgoing calls
no test coverage detected