/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2002 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
package org.apache.commons.lang.builder;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
/**
 * <code>HashCode</code> を生成する処理です。
 * {@primary <code>HashCode</code> generation routines.}
 * <p>
 * このクラスはより良いハッシュコードをクラス内で生成する事を可能にします。
 * これは Joshua Bloch の Effective Java で説明されているルールに従います。
 * 良い hashCode を書くことは、実際には非常に困難です。
 * このクラスはこれを簡単にする事を目的とします。
 * {@primary This class enables a good hashcode to be built for any class. It follows
 * the rules laid out in the book Effective Java, by Joshua Bloch. Writing a 
 * good hashCode is actually quite difficult. This class aims to simplify the 
 * process.}
 * <p>
 * オブジェクト内の関連する全てのフィールドをハッシュコードに含めるべきです。
 * 取得されたフィールドは除外されるかもしれません(訳注 意味がわからず直訳です)。
 * 一般的に equals メソッドで使用される全てのフィールドを hashCode メソッド内で使用する必要があります。
 * {@primary All relevant fields from the object should be included in the hashCode. Derived
 * fields may be excluded. In general, any field used in the equals method must be
 * used in the hashCode method. }
 * <p>
 * 一般的な使用方法を以下に示します:
 * {@primary Typical use for the code is as follows:}
 * <pre>
 * public class Person {
 *   String name;
 *   int age;
 *   boolean isSmoker;
 *   ...
 * 
 *   public int hashCode() {
 *     // you pick a hard-coded, randomly chosen, non-zero, odd number
 *     // ideally different for each class
 *     return new HashCodeBuilder(17, 37).   
 *       append(name).
 *       append(age).
 *       append(smoker).
 *       toHashCode();
 *   }
 * }
 * </pre>
 * <p>
 * もう一つの方法として、リフレクションを使用してフィールドを比較するメソッドがあります。
 * 普通、対象となるフィールドは private であるため、この <code>reflectionHashCode</code>
 * メソッドは フィールドのアクセス制限を変更するために  <code>Field.setAccessible</code> 
 * を使用します。
 * これは適切なパーミッションが設定されていない限り、セキュリティマネージャが稼動している状態では行うことができません。
 * また、この方法は明らかに低速です。
 * {@primary Alternatively, there is a method that uses reflection to determine
 * the fields to test. Because these fields are usually private, the method, 
 * <code>reflectionHashCode</code>, uses <code>Field.setAccessible</code> to
 * change the visibility of the fields. This will fail under a security manager, 
 * unless the appropriate permissions are set. It is also slower than testing 
 * explicitly.}
 * <p>
 * このメソッドの一般的な使用方法は以下の様になります:
 * {@primary A typical invocation for this method would look like:}
 * <pre>
 * public boolean hashCode(Object o) {
 *   return HashCodeBuilder.reflectionHashCode(this);
 * }
 * </pre>
 * 
 * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
 * @translator 日置 聡
 * @status firstdraft
 * @update 2003/08/18
 * @version $Id: HashCodeBuilder.java,v 1.1.1.1 2004/02/13 10:02:04 hioki Exp $
 */
public class HashCodeBuilder {
    
    /**
     * ハッシュコードを作成する際に使用される定数。
     * {@primary Constant to use in building the hashCode}
     */
    private final int iConstant;
    /**
     * ハッシュコードの処理された総計。
     * {@primary Running total of the hashCode}
     */
    private int iTotal = 0;
    
    /**
     * HashCodeBuilder のコンストラクタです。
     * このコンストラクタはハードコーディングされた2つの値をハッシュコードを生成する際に使用するために設定します。
     * {@primary Constructor for HashCodeBuilder.
     * This constructor uses two hard coded choices for the constants needed
     * to build a hashCode.}
     */
    public HashCodeBuilder() {
        super();
        iConstant = 37;
        iTotal = 17;
    }
    
    /**
     * HashCodeBuilder のコンストラクタです。
     * 2つのランダムに選ばれた0でない奇数の値を指定する必要があります。
     * 理想をいえばこの値はクラス毎に異なった方が良いのですが、これはさほど重要ではありません。
     * 乗数より素数の方がより好まれます。
     * {@primary Constructor for HashCodeBuilder.
     * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally
     * these should be different for each class, however this is not vital.
     * Prime numbers are preferred, especially for the multiplier.}
     * 
     * @param initialNonZeroOddNumber  初期値として使用される0でない奇数
     * {@primary a non-zero, odd number used as the initial value}
     * @param multiplierNonZeroOddNumber  乗数として使用される0でない奇数
     * {@primary a non-zero, odd number used as the multiplier}
     * @throws IllegalArgumentException 指定された数値が0または偶数だった場合
     * {@primary if the number is zero or even}
     */
    public HashCodeBuilder(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber) {
        super();
        if (initialNonZeroOddNumber == 0) {
            throw new IllegalArgumentException("HashCodeBuilder requires a non zero initial value");
        }
        if (initialNonZeroOddNumber % 2 == 0) {
            throw new IllegalArgumentException("HashCodeBuilder requires an odd initial value");
        }
        if (multiplierNonZeroOddNumber == 0) {
            throw new IllegalArgumentException("HashCodeBuilder requires a non zero multiplier");
        }
        if (multiplierNonZeroOddNumber % 2 == 0) {
            throw new IllegalArgumentException("HashCodeBuilder requires an odd multiplier");
        }
        iConstant = multiplierNonZeroOddNumber;
        iTotal = initialNonZeroOddNumber;
    }

    //-------------------------------------------------------------------------
    
    /**
     * このメソッドはハッシュコードを生成するためにリフレクションを使用します。
     * {@primary This method uses reflection to build a valid hash code. }
     * <p>
     * このメソッドは private フィールドの値を取得するために Field.setAccessible を使用します。
     * これはセキュリティマネージャが稼動していて、適切なパーミッションが設定されていない場合、
     * セキュリティ例外が投げられることを意味します。
     * このメソッドは明らかに非効率です。
     * transient メンバーは、おそらくフィールドの値から取得されたものでオブジェクトの値とはならないと考え、
     * 処理の対象としません。
     * static フィールドは処理の対象にはなりません。
     * このメソッドはコンストラクタで設定された2つの定数をハッシュコードの生成に使用します。
     * {@primary It uses Field.setAccessible to gain access to private fields. This means
     * that it will throw a security exception if run under a security manger, if
     * the permissions are not set up.
     * It is also not as efficient as testing explicitly. 
     * Transient members will be not be used, as they are likely derived 
     * fields, and not part of the value of the object. 
     * Static fields will not be tested.
     * This constructor uses two hard coded choices for the constants needed
     * to build a hash code.}
     * 
     * @param object  ハッシュコードを生成する対象となるオブジェクト
     * {@primary the object to create a hash code for}
     * @return ハッシュコードの int
     * {@primary int hash code}
     * @throws IllegalArgumentException オブジェクトが null だった場合
     * {@primary if the object is null}
     */
    public static int reflectionHashCode(Object object) {
        return reflectionHashCode(object, false);
    }

    /**
     * このメソッドはハッシュコードを生成するためにリフレクションを使用します。
     * {@primary This method uses reflection to build a valid hash code. }
     * <p>
     * このメソッドは private フィールドの値を取得するために Field.setAccessible を使用します。
     * これはセキュリティマネージャが稼動していて、適切なパーミッションが設定されていない場合、
     * セキュリティ例外が投げられることを意味します。
     * このメソッドは明らかに非効率です。
     * testTransients 引数に true が設定された場合 transient メンバーを処理の対象とし、
     * false が設定された場合にはフィールドの値から取得されたものでオブジェクトの値とはならないとみなし、
     * transient メンバーを無視します。
     * static フィールドは処理の対象にはなりません。
     * このメソッドはハードコーディングされた2つの定数をハッシュコードの生成に使用します。
     * {@primary It uses Field.setAccessible to gain access to private fields. This means
     * that it will throw a security exception if run under a security manger, if
     * the permissions are not set up.
     * It is also not as efficient as testing explicitly. 
     * If the TestTransients parameter is set to true, transient members will be
     * tested, otherwise they are ignored, as they are likely derived fields, and
     * not part of the value of the object. 
     * Static fields will not be tested.
     * This constructor uses two hard coded choices for the constants needed
     * to build a hash code.}
     * 
     * @param object  ハッシュコードを生成する対象となるオブジェクト
     * {@primary the object to create a hash code for}
     * @param testTransients transient フィールドを含めるかどうか
     * {@primary whether to include transient fields}
     * @return ハッシュコードの int
     * {@primary int hash code}
     * @throws IllegalArgumentException オブジェクトが null だった場合
     * {@primary if the object is null}
     */
    public static int reflectionHashCode(Object object, boolean testTransients) {
        return reflectionHashCode(17, 37, object, testTransients);
    }
        
    /**
     * このメソッドはハッシュコードを生成するためにリフレクションを使用します。
     * {@primary This method uses reflection to build a valid hash code. }
     * <p>
     * このメソッドは private フィールドの値を取得するために Field.setAccessible を使用します。
     * これはセキュリティマネージャが稼動していて、適切なパーミッションが設定されていない場合、
     * セキュリティ例外が投げられることを意味します。
     * このメソッドは明らかに非効率です。
     * transient メンバーは、おそらくフィールドの値から取得されたものでオブジェクトの値とはならないと考え、
     * 処理の対象としません。
     * static フィールドは処理の対象にはなりません。
     * {@primary It uses Field.setAccessible to gain access to private fields. This means
     * that it will throw a security exception if run under a security manger, if
     * the permissions are not set up.
     * It is also not as efficient as testing explicitly. 
     * Transient members will be not be used, as they are likely derived 
     * fields, and not part of the value of the object. 
     * Static fields will not be tested.}
     * <p>
     * 2つのランダムに選ばれた0でない奇数の値を指定する必要があります。
     * 理想をいえばこの値はクラス毎に異なった方が良いのですが、これはさほど重要ではありません。
     * 乗数より素数の方がより好まれます。
     * {@primary Two randomly chosen, non-zero, odd numbers must be passed in. Ideally
     * these should be different for each class, however this is not vital.
     * Prime numbers are preferred, especially for the multiplier.}
     * 
     * @param initialNonZeroOddNumber  初期値として使用される0でない奇数
     * {@primary a non-zero, odd number used as the initial value}
     * @param multiplierNonZeroOddNumber  乗数として使用される0でない奇数
     * {@primary a non-zero, odd number used as the multiplier}
     * @param object  ハッシュコードを生成する対象となるオブジェクト
     * {@primary the object to create a hash code for}
     * @return ハッシュコードの int
     * {@primary int hash code}
     * @throws IllegalArgumentException オブジェクトが null だった場合
     * {@primary if the object is null}
     * @throws IllegalArgumentException 指定された数値が0または偶数だった場合
     * {@primary if the number is zero or even}
     */
    public static int reflectionHashCode(
            int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, 
            Object object) {
        return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, false);
    }
    
    /**
     * このメソッドはハッシュコードを生成するためにリフレクションを使用します。
     * {@primary This method uses reflection to build a valid hash code. }
     * <p>
     * このメソッドは private フィールドの値を取得するために Field.setAccessible を使用します。
     * これはセキュリティマネージャが稼動していて、適切なパーミッションが設定されていない場合、
     * セキュリティ例外が投げられることを意味します。
     * このメソッドは明らかに非効率です。
     * testTransients 引数に true が設定された場合 transient メンバーを処理の対象とし、
     * false が設定された場合にはフィールドの値から取得されたものでオブジェクトの値とはならないとみなし、
     * transient メンバーを無視します。
     * static フィールドは処理の対象にはなりません。
     * {@primary It uses Field.setAccessible to gain access to private fields. This means
     * that it will throw a security exception if run under a security manger, if
     * the permissions are not set up.
     * It is also not as efficient as testing explicitly. 
     * If the TestTransients parameter is set to true, transient members will be
     * tested, otherwise they are ignored, as they are likely derived fields, and
     * not part of the value of the object. 
     * Static fields will not be tested.}
     * <p>
     * 2つのランダムに選ばれた0でない奇数の値を指定する必要があります。
     * 理想をいえばこの値はクラス毎に異なった方が良いのですが、これはさほど重要ではありません。
     * 乗数より素数の方がより好まれます。
     * {@primary Two randomly chosen, non-zero, odd numbers must be passed in. Ideally
     * these should be different for each class, however this is not vital.
     * Prime numbers are preferred, especially for the multiplier.}
     * 
     * @param initialNonZeroOddNumber  初期値として使用される0でない奇数
     * {@primary a non-zero, odd number used as the initial value}
     * @param multiplierNonZeroOddNumber  乗数として使用される0でない奇数
     * {@primary a non-zero, odd number used as the multiplier}
     * @param object  ハッシュコードを生成する対象となるオブジェクト
     * {@primary the object to create a hash code for}
     * @param testTransients transient フィールドを含めるかどうか
     * {@primary whether to include transient fields}
     * @return ハッシュコードの int
     * {@primary int hash code}
     * @throws IllegalArgumentException オブジェクトが null だった場合
     * {@primary if the object is null}
     * @throws IllegalArgumentException 指定された数値が0または偶数だった場合
     * {@primary if the number is zero or even}
     */
    public static int reflectionHashCode(
            int initialNonZeroOddNumber, int multiplierNonZeroOddNumber,
            Object object, boolean testTransients) {
                
        if (object == null) {
            throw new IllegalArgumentException("The object to build a hash code for must not be null");
        }
        HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
        Field[] fields = object.getClass().getDeclaredFields();
        Field.setAccessible(fields, true);
        for (int i = 0; i < fields.length; ++i) {
            Field f = fields[i];
            if (testTransients || !Modifier.isTransient(f.getModifiers())) {
                if (!Modifier.isStatic(f.getModifiers())) {
                    try {
                        hashCodeBuilder.append(f.get(object));
                    } catch (IllegalAccessException e) {
                        //this can't happen. Would get a Security exception instead
                        //throw a runtime exception in case the impossible happens.
                        throw new InternalError("Unexpected IllegalAccessException");
                    }
                }
            }
        }
        return hashCodeBuilder.toHashCode();
    }

    //-------------------------------------------------------------------------
    
    /**
     * Object をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for an Object.}
     *
     * @param object  ハッシュコードに加えるオブジェクト
     * {@primary the object to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(Object object) {
        if (object == null) {
            iTotal = iTotal * iConstant;
            
        } else {
            if (object.getClass().isArray() == false) {
                //the simple case, not an array, just the element 
                iTotal = iTotal * iConstant + object.hashCode();
                
            } else {
                //'Switch' on type of array, to dispatch to the correct handler
                // This handles multi dimensional arrays
                if (object instanceof long[]) {
                    append((long[]) object);
                } else if (object instanceof int[]) {
                    append((int[]) object);
                } else if (object instanceof short[]) {
                    append((short[]) object);
                } else if (object instanceof char[]) {
                    append((char[]) object);
                } else if (object instanceof byte[]) {
                    append((byte[]) object);
                } else if (object instanceof double[]) {
                    append((double[]) object);
                } else if (object instanceof float[]) {
                    append((float[]) object);
                } else if (object instanceof boolean[]) {
                    append((boolean[]) object);
                } else { 
                    // Not an array of primitives
                    append((Object[]) object);
                }
            }
        }
        return this;
    }

    /**
     * long をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a long.}
     *
     * @param value  ハッシュコードに加える long の値
     * {@primary  the long to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(long value) {
        iTotal = iTotal * iConstant + ((int) (value ^ (value >> 32)));
        return this;
    }

    /**
     * int をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for an int.}
     *
     * @param value  ハッシュコードに加える int の値
     * {@primary  the int to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(int value) {
        iTotal = iTotal * iConstant + value;
        return this;
    }

    /**
     * short をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a short.}
     *
     * @param value  ハッシュコードに加える short の値
     * {@primary  the short to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(short value) {
        iTotal = iTotal * iConstant + (int) value;
        return this;
    }

    /**
     * char をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a char.}
     *
     * @param value  ハッシュコードに加える char の値
     * {@primary  the char to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(char value) {
        iTotal = iTotal * iConstant + (int) value;
        return this;
    }

    /**
     * byte をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a byte.}
     *
     * @param value  ハッシュコードに加える byte の値
     * {@primary  the byte to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(byte value) {
        iTotal = iTotal * iConstant + (int) value;
        return this;
    }

    /**
     * double をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a double.}
     *
     * @param value  ハッシュコードに加える double の値
     * {@primary  the double to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(double value) {
        return append(Double.doubleToLongBits(value));
    }

    /**
     * float をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a float.}
     *
     * @param value  ハッシュコードに加える float の値
     * {@primary  the float to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(float value) {
        iTotal = iTotal * iConstant + Float.floatToIntBits(value);
        return this;
    }

    /**
     * boolean をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a boolean.}
     *
     * @param value  ハッシュコードに加える boolean の値
     * {@primary  the boolean to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(boolean value) {
        iTotal = iTotal * iConstant + (value ? 0 : 1);
        return this;
    }

    /**
     * Object の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for an Object array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(Object[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * long の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a long array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(long[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * int の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for an int array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(int[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * short の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a short array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(short[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * char の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a char array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(char[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * byte の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a byte array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(byte[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * double の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a double array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(double[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * float の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a float array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(float[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * boolean の配列をハッシュコードを生成するための対象に加えます。
     * {@primary Append a hashCode for a boolean array.}
     *
     * @param array  ハッシュコードに加える配列
     * {@primary the array to add to the hashCode}
     * @return this
     */
    public HashCodeBuilder append(boolean[] array) {
        if (array == null) {
            iTotal = iTotal * iConstant;
        } else {
            for (int i = 0; i < array.length; i++) {
                append(array[i]);
            }
        }
        return this;
    }

    /**
     * 計算されたハッシュコードを返します。
     * {@primary Return the computed hashCode}
     * 
     * @return 処理の対象に加えられたフィールドを元にしたハッシュコードの int の値
     * {@primary int hashCode based on the fields appended}
     */    
    public int toHashCode() {
        return iTotal;
    }

}
