package cn.cerc.ui.fields;

import cn.cerc.core.Record;
import cn.cerc.ui.parts.UIComponent;

import java.util.ArrayList;
import java.util.List;

public class RadioField extends AbstractField {
    private List<String> items = new ArrayList<>();

    public RadioField(UIComponent owner, String name, String field, int width) {
        super(owner, name, width);
        this.setField(field);
    }

    @Override
    public String getText(Record record) {
        if (record == null) {
            return null;
        }
        int val = record.getInt(field);
        if (val < 0 || val > items.size() - 1) {
            return "" + val;
        }
        String result = items.get(val);
        if (result == null) {
            return "" + val;
        } else {
            return result;
        }
    }

    public RadioField add(String... items) {
        for (String item : items) {
            this.items.add(item);
        }
        return this;
    }
}

@@ -115,16 +115,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -212,16 +212,17 @@
 Field %7B%0A
+%0A
     priv
@@ -225,16 +225,22 @@
 private 
+final 
 List%3CStr
@@ -892,79 +892,48 @@
     
-for (String item : items) %7B%0A            this.items.add(item);%0A        %7D
+this.items.addAll(Arrays.asList(items));
 %0A   
@@ -956,10 +956,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Update RadioField.java