package com.speedment.runtime.config.internal.identifier;

import com.speedment.runtime.config.identifier.ColumnIdentifier;

import static java.util.Objects.requireNonNull;

/**
 * Default implementation of the {@link ColumnIdentifier}. Note that for
 * performance reasons, usually the interface is implemented using a generated
 * {@code enum} and not by this class. This implementation should only be used
 * when fully dynamic identifiers are required.
 * <p>
 * This implementation is immutable and may be used as key in a
 * {@link java.util.Map}.
 *
 * @author Emil Forslund
 * @since  3.0.15
 */
public final class ColumnIdentifierImpl<ENTITY>
implements ColumnIdentifier<ENTITY> {

    private final String dbmsName;
    private final String schemaName;
    private final String tableName;
    private final String columnName;

    public ColumnIdentifierImpl(
            final String dbmsName,
            final String schemaName,
            final String tableName,
            final String columnName) {
        this.dbmsName   = requireNonNull(dbmsName);
        this.schemaName = requireNonNull(schemaName);
        this.tableName  = requireNonNull(tableName);
        this.columnName = requireNonNull(columnName);
    }

    @Override
    public String getDbmsName() {
        return dbmsName;
    }

    @Override
    public String getSchemaName() {
        return schemaName;
    }

    @Override
    public String getTableName() {
        return tableName;
    }

    @Override
    public String getColumnName() {
        return columnName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ColumnIdentifier)) return false;

        final ColumnIdentifier<?> that = (ColumnIdentifier<?>) o;
        return getDbmsName().equals(that.getDbmsName())
            && getSchemaName().equals(that.getSchemaName())
            && getTableName().equals(that.getTableName())
            && getColumnName().equals(that.getColumnName());
    }

    @Override
    public int hashCode() {
        int result = getDbmsName().hashCode();
        result = 31 * result + getSchemaName().hashCode();
        result = 31 * result + getTableName().hashCode();
        result = 31 * result + getColumnName().hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "ColumnIdentifier{" +
            dbmsName + '.' +
            schemaName + '.' +
            tableName + '.' +
            columnName + '}';
    }
}

@@ -1,8 +1,639 @@
+/**%0A *%0A * Copyright (c) 2006-2017, Speedment, Inc. All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); You may not%0A * use this file except in compliance with the License. You may obtain a copy of%0A * the License at:%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A
 package 

Add license headers