001package state.ui;
002
003import java.util.ArrayList;
004import java.util.List;
005
006public final class UIFormBuilder {
007        private final List<UIForm.Pair> menu = new ArrayList<UIForm.Pair>();
008        public UIForm toUIForm(String heading) {
009                if (null == heading)
010                        throw new IllegalArgumentException();
011                if (menu.size() <= 1)
012                        throw new IllegalStateException();
013                UIForm.Pair[] array = new UIForm.Pair[menu.size()];
014                for (int i = 0; i < menu.size(); i++)
015                        array[i] = menu.get(i);
016                return new UIForm(heading, array);
017        }
018        public void add(String prompt, UIFormTest test) {
019                menu.add(new UIForm.Pair(prompt, test));
020        }
021}