001package myproject.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 void add(String prompt, UIFormTest test) {
009                menu.add(new UIForm.Pair(prompt, test));
010        }
011        public UIForm toUIForm(String heading) {
012                if (null == heading)
013                        throw new IllegalArgumentException();
014                if (menu.size() < 1)
015                        throw new IllegalStateException();
016                UIForm.Pair[] array = new UIForm.Pair[menu.size()];
017                for (int i = 0; i < menu.size(); i++)
018                        array[i] = menu.get(i);
019                return new UIForm(heading, array);
020        }
021}