01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.datatypes;
11:
12: /**
13: * DataType associated with {@link java.lang.Float}, as NumberDataType, but provides getMin and getMax as float.
14: *
15: * @author Pierre van Rooden
16: * @version $Id: FloatDataType.java,v 1.10 2007/08/28 10:04:49 michiel Exp $
17: * @since MMBase-1.8
18: */
19: public class FloatDataType extends NumberDataType<Float> {
20:
21: private static final long serialVersionUID = 1L; // increase this if object serialization changes (which we shouldn't do!)
22:
23: /**
24: * @param primitive indicate if a primitive type should be used
25: */
26: public FloatDataType(String name, boolean primitive) {
27: super (name, primitive ? Float.TYPE : Float.class);
28: setMin(Float.valueOf(-1 * Float.MAX_VALUE), true);
29: setMax(Float.valueOf(Float.MAX_VALUE), true);
30: }
31:
32: /**
33: * @return the minimum value as a <code>float</code>, or {@link Float#NEGATIVE_INFINITY} if there is no minimum.
34: */
35: public float getMin() {
36: Number min = getMinRestriction().getValue();
37: return min == null ? Float.NEGATIVE_INFINITY : min.floatValue();
38: }
39:
40: /**
41: * @return the maximum value as a <code>float</code>, or {@link Float#POSITIVE_INFINITY} if there is no maximum.
42: */
43: public float getMax() {
44: Number max = getMaxRestriction().getValue();
45: return max == null ? Float.POSITIVE_INFINITY : max.floatValue();
46: }
47: }
|