AbstractNumericGene.java
01 /*
02  * Java Genetic Algorithm Library (jenetics-1.6.0).
03  * Copyright (c) 2007-2014 Franz Wilhelmstötter
04  *
05  * Licensed under the Apache License, Version 2.0 (the "License");
06  * you may not use this file except in compliance with the License.
07  * You may obtain a copy of the License at
08  *
09  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * Author:
18  *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
19  */
20 package org.jenetics;
21 
22 /**
23  * Abstract base class for implementing concrete NumericGenes.
24  *
25  @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
26  @version 1.6 &mdash; <em>$Date: 2014-03-05 $</em>
27  @since 1.6
28  */
29 abstract class AbstractNumericGene<
30     extends Number & Comparable<? super N>,
31     extends AbstractNumericGene<N, G>
32 >
33     extends AbstractBoundedGene<N, G>
34     implements NumericGene<N, G>
35 {
36     private static final long serialVersionUID = 1L;
37 
38     /**
39      * Create new {@code NumericGene}.
40      *
41      @param value The value of the gene.
42      @param min The allowed min value of the gene.
43      @param max The allows max value of the gene.
44      @throws NullPointerException if one of the given arguments is
45      *         {@code null}.
46      */
47     protected AbstractNumericGene(final N value, final N min, final N max) {
48         super(value, min, max);
49     }
50 
51     @Override
52     public byte byteValue() {
53         return _value.byteValue();
54     }
55 
56     @Override
57     public short shortValue() {
58         return _value.shortValue();
59     }
60 
61     @Override
62     public int intValue() {
63         return _value.intValue();
64     }
65 
66     @Override
67     public long longValue() {
68         return _value.longValue();
69     }
70 
71     @Override
72     public float floatValue() {
73         return _value.floatValue();
74     }
75 
76     @Override
77     public double doubleValue() {
78         return _value.doubleValue();
79     }
80 
81     @Override
82     public abstract G newInstance(final Number number);
83 
84 }