2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.util.dialogrunner;
25 int type = 0; // int = 0, String = 1, Object = 2;
33 public Response(int response)
39 public Response(String response)
42 stringresp = response;
45 public Response(Object response)
47 if (response instanceof String)
50 stringresp = (String) response;
53 if (response instanceof Integer)
56 intresp = ((Integer) response).intValue();
64 public boolean equals(Object obj)
66 if (obj == null || !(obj instanceof Response))
71 if (((Response) obj).type == type)
76 return ((((Response) obj).intresp) == intresp);
78 return (((Response) obj).stringresp.equals(stringresp));
80 return (((Response) obj).objresp).equals(objresp);
92 return Integer.valueOf(intresp).hashCode();
94 return stringresp.hashCode();
96 return objresp.hashCode();
98 return super.hashCode();
102 public String toString()
107 return "DialogRunner int: " + intresp;
109 return "DialogRunner str: '" + stringresp + "'";
111 return "DialogRunner obj: " + String.valueOf(objresp);
113 return "Unconfigured response.";
117 * null response - triggers the default response
120 public boolean isNull()
122 return (type==2 && objresp==null) || (type==1 && (stringresp==null || stringresp.equals("")));