Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.util.dialogrunner

File Response.java

 

Coverage histogram

../../../img/srcFileCovDistChart1.png
53% of files have more coverage

Code metrics

8
43
7
1
124
88
21
0.49
6.14
7
3

Classes

Class Line # Actions
Response 23 43 21 55
0.051724145.2%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.util.dialogrunner;
22   
 
23    public class Response
24    {
25    int type = 0; // int = 0, String = 1, Object = 2;
26   
27    int intresp;
28   
29    String stringresp;
30   
31    Object objresp;
32   
 
33  11 toggle public Response(int response)
34    {
35  11 type = 0;
36  11 intresp = response;
37    }
38   
 
39  0 toggle public Response(String response)
40    {
41  0 type = 1;
42  0 stringresp = response;
43    }
44   
 
45  0 toggle public Response(Object response)
46    {
47  0 if (response instanceof String)
48    {
49  0 type = 1;
50  0 stringresp = (String) response;
51  0 return;
52    }
53  0 if (response instanceof Integer)
54    {
55  0 type = 0;
56  0 intresp = ((Integer) response).intValue();
57  0 return;
58    }
59  0 objresp = response;
60  0 type = 2;
61    }
62   
 
63  0 toggle @Override
64    public boolean equals(Object obj)
65    {
66  0 if (obj == null || !(obj instanceof Response))
67    {
68  0 return false;
69    }
70  0 ;
71  0 if (((Response) obj).type == type)
72    {
73  0 switch (type)
74    {
75  0 case 0:
76  0 return ((((Response) obj).intresp) == intresp);
77  0 case 1:
78  0 return (((Response) obj).stringresp.equals(stringresp));
79  0 case 2:
80  0 return (((Response) obj).objresp).equals(objresp);
81    }
82    }
83  0 return false;
84    }
85   
 
86  0 toggle @Override
87    public int hashCode()
88    {
89  0 switch (type)
90    {
91  0 case 0:
92  0 return Integer.valueOf(intresp).hashCode();
93  0 case 1:
94  0 return stringresp.hashCode();
95  0 case 2:
96  0 return objresp.hashCode();
97    }
98  0 return super.hashCode();
99    }
100   
 
101  0 toggle @Override
102    public String toString()
103    {
104  0 switch (type)
105    {
106  0 case 0:
107  0 return "DialogRunner int: " + intresp;
108  0 case 1:
109  0 return "DialogRunner str: '" + stringresp + "'";
110  0 case 2:
111  0 return "DialogRunner obj: " + String.valueOf(objresp);
112    }
113  0 return "Unconfigured response.";
114    }
115   
116    /**
117    * null response - triggers the default response
118    * @return
119    */
 
120  0 toggle public boolean isNull()
121    {
122  0 return (type==2 && objresp==null) || (type==1 && (stringresp==null || stringresp.equals("")));
123    }
124    }