update author list in license for (JAL-826)
[jalview.git] / src / jalview / ws / params / simple / IntegerParameter.java
1 /*******************************************************************************
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
10  *
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  *******************************************************************************/
18 /**
19  * 
20  */
21 package jalview.ws.params.simple;
22
23 import jalview.ws.params.ParameterI;
24 import jalview.ws.params.ValueConstrainI;
25
26 import compbio.metadata.ValueConstrain.Type;
27
28 /**
29  * @author jimp
30  *
31  */
32 public class IntegerParameter extends Option implements ParameterI 
33 {
34   int defval;
35   int min,max;
36   public ValueConstrainI getValidValue() {
37     return new ValueConstrainI()
38     {
39       
40       @Override
41       public ValueType getType()
42       {
43         return ValueType.Integer;
44       }
45       
46       @Override
47       public Number getMin()
48       {
49         if (min<max)
50         {
51         return min;
52         } else {
53           return null;
54         }
55       }
56       
57       @Override
58       public Number getMax()
59       {
60         if (min<max)
61         {
62           return max;
63         } else {
64           return null;
65         }
66       }
67     };
68   }
69   public IntegerParameter(IntegerParameter parm)
70   {
71     super(parm);
72     max = parm.max;
73     min = parm.min;
74   }
75
76   public IntegerParameter(String name, String description, boolean required, int defValue,
77           int min, int max)
78   {
79     super(name, description, required, String.valueOf(defValue), null, null, null);
80     defval = defValue;
81     this.min = min;
82     this.max = max;
83   }
84
85   public IntegerParameter(String name, String description, boolean required, int defValue, int value,
86           int min, int max)
87   {
88     super(name, description, required, String.valueOf(defValue), String.valueOf(value), null, null);
89     defval = defValue;
90     this.min = min;
91     this.max = max;
92   }
93   @Override
94   public IntegerParameter copy()
95   {
96     return new IntegerParameter(this);    
97   }
98   
99 }