Hash.java
001 /*
002  * Java Genetic Algorithm Library (jenetics-3.5.0).
003  * Copyright (c) 2007-2016 Franz Wilhelmstötter
004  *
005  * Licensed under the Apache License, Version 2.0 (the "License");
006  * you may not use this file except in compliance with the License.
007  * You may obtain a copy of the License at
008  *
009  *      http://www.apache.org/licenses/LICENSE-2.0
010  *
011  * Unless required by applicable law or agreed to in writing, software
012  * distributed under the License is distributed on an "AS IS" BASIS,
013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014  * See the License for the specific language governing permissions and
015  * limitations under the License.
016  *
017  * Author:
018  *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
019  */
020 package org.jenetics.internal.util;
021 
022 import org.jenetics.util.Seq;
023 
024 /**
025  * Interface for calculating the object hash value.
026  *
027  * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
028  * @since 1.6
029  * @version 3.0
030  */
031 public interface Hash {
032 
033     /**
034      * Add hash code for a {@code boolean} value.
035      *
036      * @param value the value to add to the hash code.
037      * @return {@code this}
038      */
039     public Hash and(final boolean value);
040 
041     /**
042      * Add hash code for an {@code boolean} array.
043      *
044      * @param values the value to add to the hash code.
045      * @return {@code this}
046      */
047     public Hash and(final boolean[] values);
048 
049     /**
050      * Add hash code for a {@code byte}.
051      *
052      * @param value the value to add to the hash code.
053      * @return {@code this}
054      */
055     public Hash and(final byte value);
056 
057     /**
058      * Add hash code for an {@code byte} arrays.
059      *
060      * @param values the value to add to the hash code.
061      * @return {@code this}
062      */
063     public Hash and(final byte[] values);
064 
065     /**
066      * Add hash code for a {@code char}.
067      *
068      * @param value the value to add to the hash code.
069      * @return {@code this}
070      */
071     public Hash and(final char value);
072 
073     /**
074      * Add hash code for an {@code char} array.
075      *
076      * @param values the value to add to the hash code.
077      * @return {@code this}
078      */
079     public Hash and(final char[] values);
080 
081     /**
082      * Add hash code for a {@code short}.
083      *
084      * @param value the value to add to the hash code.
085      * @return {@code this}
086      */
087     public Hash and(final short value);
088 
089     /**
090      * Add hash code for an {@code short} array.
091      *
092      * @param values the value to add to the hash code.
093      * @return {@code this}
094      */
095     public Hash and(final short[] values);
096 
097     /**
098      * Add hash code for an {@code int}.
099      *
100      * @param value the value to add to the hash code.
101      * @return {@code this}
102      */
103     public Hash and(final int value);
104 
105     /**
106      * Add hash code for an {@code int} array.
107      *
108      * @param values the value to add to the hash code.
109      * @return {@code this}
110      */
111     public Hash and(final int[] values);
112 
113     /**
114      * Add hash code for a {@code long}.
115      *
116      * @param value the value to add to the hash code.
117      * @return {@code this}
118      */
119     public Hash and(final long value);
120 
121     /**
122      * Add hash code for an {@code long} array.
123      *
124      * @param values the value to add to the hash code.
125      * @return {@code this}
126      */
127     public Hash and(final long[] values);
128 
129     /**
130      * Add hash code for a {@code float}.
131      *
132      * @param value the value to add to the hash code.
133      * @return {@code this}
134      */
135     public Hash and(final float value);
136 
137     /**
138      * Add hash code for an {@code float} array.
139      *
140      * @param values the value to add to the hash code.
141      * @return {@code this}
142      */
143     public Hash and(final float[] values);
144 
145     /**
146      * Add hash code for a {@code double}.
147      *
148      * @param value the value to add to the hash code.
149      * @return {@code this}
150      */
151     public Hash and(final double value);
152 
153     /**
154      * Add hash code for an {@code double} array.
155      *
156      * @param values the value to add to the hash code.
157      * @return {@code this}
158      */
159     public Hash and(final double[] values);
160 
161     /**
162      * Add hash code for a {@code Object}.
163      *
164      * @param value the value to add to the hash code.
165      * @return {@code this}
166      */
167     public Hash and(final Object value);
168 
169     /**
170      * Add hash code for an {@code Object}.
171      *
172      * @param values the value to add to the hash code.
173      * @return {@code this}
174      */
175     public Hash and(final Object[] values);
176 
177     /**
178      * Add hash code for a {@code Seq}.
179      *
180      * @param values the value to add to the hash code.
181      * @return {@code this}
182      */
183     public Hash and(final Seq<?> values);
184 
185     /**
186      * Return the calculated hash value.
187      *
188      * @return the calculated hash value.
189      */
190     public int value();
191 
192     /**
193      * Create a HashCodeBuilder for the given type.
194      *
195      * @param type the type the {@code Hash} is created for.
196      * @return a new default {@code Hash} implementation.
197      */
198     public static Hash of(final Class<?> type) {
199         return new DefaultHashCodeBuilder(type);
200     }
201 }