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.internal.util;
21
22 /**
23 * Interface for building hash codes. The HashCodeBuilder is created via a
24 * factory method in the {@link org.jenetics.util.object} class.
25 * <p/>
26 * Example for calculating the hash code for a given class:
27 * [code]
28 * \@Override
29 * public int hashCode() {
30 * return object.hashCodeOf(getClass())
31 * .and(_prop1)
32 * .and(_prop2).value();
33 * }
34 * [/code]
35 *
36 * @see org.jenetics.util.object#hashCodeOf(Class)
37 *
38 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
39 * @version 1.6 — <em>$Date: 2014-02-27 $</em>
40 * @since 1.6
41 */
42 public abstract class HashBuilder {
43
44 public static Hash of(final Class<?> type) {
45 return new DefaultHashCodeBuilder(type);
46 }
47
48 }
|