01: package org.osbl.item;
02:
03: import java.util.*;
04:
05: public class EnumLocalizationCollector extends AbstractItemCollector {
06: Class enumClass;
07: List<String> items;
08:
09: public EnumLocalizationCollector(Class enumClass) {
10: this .enumClass = enumClass;
11: }
12:
13: public Collection<String> getItems() {
14: if (items == null) {
15: try {
16: Object[] constants = enumClass.getEnumConstants();
17:
18: items = new ArrayList<String>(constants.length);
19: StringBuilder builder = new StringBuilder(enumClass
20: .getName());
21:
22: for (Object o : constants) {
23: items.add(build(builder, ".", ((Enum) o).name()));
24: }
25: } catch (Exception e) {
26: throw new RuntimeException(e);
27: }
28: }
29: return items;
30: }
31: }
|