001package state.ui; 002 003/** 004 * @see UIFormBuilder 005 */ 006public final class UIForm { 007 private final String heading; 008 private final Pair[] form; 009 010 static final class Pair { 011 final String prompt; 012 final UIFormTest test; 013 014 Pair(String prompt, UIFormTest test) { 015 this.prompt = prompt; 016 this.test = test; 017 } 018 } 019 020 UIForm(String heading, Pair[] menu) { 021 this.heading = heading; 022 this.form = menu; 023 } 024 public int size() { 025 return form.length; 026 } 027 public String getHeading() { 028 return heading; 029 } 030 public String getPrompt(int i) { 031 return form[i].prompt; 032 } 033 public boolean checkInput(int i, String input) { 034 if (null == form[i]) 035 return true; 036 return form[i].test.run(input); 037 } 038}