/*
 * This is free and unencumbered software released into the public domain.
 *
 * Anyone is free to copy, modify, publish, use, compile, sell, or
 * distribute this software, either in source code form or as a compiled
 * binary, for any purpose, commercial or non-commercial, and by any
 * means.
 *
 * In jurisdictions that recognize copyright laws, the author or authors
 * of this software dedicate any and all copyright interest in the
 * software to the public domain. We make this dedication for the benefit
 * of the public at large and to the detriment of our heirs and
 * successors. We intend this dedication to be an overt act of
 * relinquishment in perpetuity of all present and future rights to this
 * software under copyright law.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * For more information, please refer to <http://unlicense.org/>
 */

package java.util.tuple;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

import jxtn.core.axi.comparators.ArrayComparators;

/**
 * 基本的Tuple型態
 * <ul>
 * <li>子項目長度、順序及型態固定</li>
 * <li>子項目值可為null</li>
 * <li>不可異動</li>
 * <li>支援透過子項目進行比較</li>
 * </ul>
 *
 * @author AqD
 * @param <T> 最終類別型態
 */
public abstract class BaseTuple<T extends BaseTuple<T>> implements Comparable<T>, Serializable
{
    private static final long serialVersionUID = -7698222474647340866L;

    private final Object[] array;
    private final List<Object> list;

    protected BaseTuple(Object... values)
    {
        this.array = values;
        this.list = Arrays.asList(values);
    }

    @Override
    public int compareTo(T other)
    {
        return ArrayComparators.compare(this.getInternalArray(), other.getInternalArray());
    }

    @Override
    public boolean equals(Object other)
    {
        if (other instanceof BaseTuple)
            return Arrays.equals(this.getInternalArray(), ((BaseTuple<?>) other).getInternalArray());
        else
            return false;
    }

    @Override
    public int hashCode()
    {
        return Arrays.hashCode(this.getInternalArray());
    }

    /**
     * 取得包含所有子項目的內部陣列
     *
     * @return 包含所有子項目的內部陣列，不應修改
     */
    public Object[] getInternalArray()
    {
        return this.array;
    }

    /**
     * 取得包含所有子項目的內部清單
     *
     * @return 包含所有子項目的內部清單，不應修改
     */
    public List<Object> getInternalList()
    {
        return this.list;
    }
}

@@ -1394,32 +1394,8 @@
 ys;%0D
-%0Aimport java.util.List;%0D
 %0A%0D%0Ai
@@ -1832,51 +1832,18 @@
 t%5B%5D 
-array;%0D%0A    private final List%3CObject%3E list
+valueArray
 ;%0D%0A%0D
@@ -1910,66 +1910,27 @@
 his.
-array = values;%0D%0A        this.list = Arrays.asList(
+valueArray = 
 values
-)
 ;%0D%0A 
@@ -2038,32 +2038,29 @@
 are(this.get
-Internal
+Value
 Array(), oth
@@ -2061,32 +2061,29 @@
 ), other.get
-Internal
+Value
 Array());%0D%0A 
@@ -2231,32 +2231,29 @@
 als(this.get
-Internal
+Value
 Array(), ((B
@@ -2271,32 +2271,29 @@
 ) other).get
-Internal
+Value
 Array());%0D%0A 
@@ -2429,24 +2429,21 @@
 this.get
-Internal
+Value
 Array())
@@ -2560,24 +2560,21 @@
 ct%5B%5D get
-Internal
+Value
 Array()%0D
@@ -2605,182 +2605,18 @@
 his.
-array;%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * %E5%8F%96%E5%BE%97%E5%8C%85%E5%90%AB%E6%89%80%E6%9C%89%E5%AD%90%E9%A0%85%E7%9B%AE%E7%9A%84%E5%85%A7%E9%83%A8%E6%B8%85%E5%96%AE%0D%0A     *%0D%0A     * @return %E5%8C%85%E5%90%AB%E6%89%80%E6%9C%89%E5%AD%90%E9%A0%85%E7%9B%AE%E7%9A%84%E5%85%A7%E9%83%A8%E6%B8%85%E5%96%AE%EF%BC%8C%E4%B8%8D%E6%87%89%E4%BF%AE%E6%94%B9%0D%0A     */%0D%0A    public List%3CObject%3E getInternalList()%0D%0A    %7B%0D%0A        return this.list
+valueArray
 ;%0D%0A 

remove getInternalList