Clover icon

Coverage Report

  1. Project Clover database Wed Dec 3 2025 17:03:17 GMT
  2. Package jalview.ws.params.simple

File BooleanOption.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
37% of files have more coverage

Code metrics

20
16
11
2
109
73
26
1.62
1.45
5.5
2.36

Classes

Class Line # Actions
BooleanOption 29 11 19
0.4545454745.5%
BooleanOption.Builder 31 5 7
0.8571428785.7%
 

Contributing tests

This file is covered by 57 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.ws.params.simple;
22   
23    import java.net.URL;
24    import java.util.Arrays;
25    import java.util.List;
26   
27    import jalview.ws.params.ArgumentI;
28   
 
29    public class BooleanOption extends Option
30    {
 
31    public static class Builder extends Option.Builder
32    {
33    private boolean defaultValue = false;
34   
35    private boolean value = false;
36   
37    private String reprValue = null;
38   
 
39  5026 toggle public void setDefaultValue(Boolean defaultValue)
40    {
41  5026 this.defaultValue = defaultValue != null ? defaultValue : false;
42    }
43   
 
44  5026 toggle public void setValue(Boolean value)
45    {
46  5026 this.value = value != null ? value : false;
47    }
48   
 
49  1998 toggle public void setReprValue(String reprValue)
50    {
51  1998 this.reprValue = reprValue;
52    }
53   
 
54  0 toggle @Override
55    public void setPossibleValues(List<String> possibleValues)
56    {
57  0 throw new UnsupportedOperationException("cannot set possible values for boolean");
58    }
59   
 
60  5026 toggle @Override
61    public BooleanOption build()
62    {
63  5026 return new BooleanOption(this);
64    }
65    }
66   
 
67  3139 toggle public static Builder newBuilder()
68    {
69  3139 return new Builder();
70    }
71   
 
72  5026 toggle protected BooleanOption(Builder builder)
73    {
74  5026 super(builder);
75  5026 String reprValue = builder.reprValue != null ? builder.reprValue : name;
76  5026 defvalue = builder.defaultValue ? reprValue : null;
77  5026 value = builder.value ? reprValue : null;
78  5026 possibleVals = List.of(reprValue);
79  5026 displayVals = List.of(label);
80    }
81   
 
82  0 toggle public BooleanOption(String name, String descr, boolean required,
83    Boolean defVal, Boolean val, URL link)
84    {
85  0 super(name, descr, required, (defVal != null && defVal ? name : null),
86  0 (val != null && val ? name : null), Arrays.asList(name), link);
87    }
88   
 
89  0 toggle public BooleanOption(String name, String description, String label,
90    boolean isrequired, Boolean defValue, String reprValue, URL link)
91    {
92  0 super(name, description, label, isrequired,
93  0 defValue != null && defValue ? reprValue : null,
94  0 defValue != null && defValue ? reprValue : null,
95    Arrays.asList(reprValue), link);
96    }
97   
 
98  0 toggle public BooleanOption(String name, String description, String label,
99    boolean isrequired, Boolean defValue, URL link)
100    {
101  0 this(name, description, label, isrequired, defValue, String.valueOf(true), link);
102    }
103   
 
104  0 toggle public static Boolean parseBoolean(ArgumentI argument)
105    {
106  0 return argument.getValue() != null && !argument.getValue().isEmpty() ?
107    true : false;
108    }
109    }