/**
 * Copyright 2015 Palantir Technologies
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.keyvalue.dbkvs;

import java.util.Optional;

import org.immutables.value.Value;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.palantir.atlasdb.keyvalue.dbkvs.impl.DbTableFactory;
import com.palantir.atlasdb.keyvalue.dbkvs.impl.OracleDbTableFactory;
import com.palantir.atlasdb.keyvalue.dbkvs.impl.OverflowMigrationState;
import com.palantir.db.oracle.JdbcHandler;

@JsonDeserialize(as = ImmutableOracleDdlConfig.class)
@JsonSerialize(as = ImmutableOracleDdlConfig.class)
@JsonTypeName(OracleDdlConfig.TYPE)
@Value.Immutable
public abstract class OracleDdlConfig extends DdlConfig {
    public static final String TYPE = "oracle";

    public abstract JdbcHandler jdbcHandler();

    @Value.Default
    public String singleOverflowTable() {
        return "atlas_overflow";
    }

    @Value.Default
    public String overflowTablePrefix() {
        return "ao_";
    }

    @JsonIgnore
    public abstract Optional<Supplier<Long>> overflowIds();

    public abstract OverflowMigrationState overflowMigrationState();

    @Value.Default
    public boolean enableOracleEnterpriseFeatures() {
        return false;
    }

    @Override
    public Supplier<DbTableFactory> tableFactorySupplier() {
        return () -> new OracleDbTableFactory(this);
    }

    @Value.Default
    @Override
    public String tablePrefix() {
        return "a_";
    }

    @Override
    public final String type() {
        return TYPE;
    }

    @Value.Check
    protected final void check() {
        Preconditions.checkState(tablePrefix() != null && !tablePrefix().isEmpty(),
                "'tablePrefix' must not be an empty string");
    }
}

@@ -2314,32 +2314,79 @@
 rn TYPE;%0A    %7D%0A%0A
+    @%0A    String metadataTableName() %7B%0A%0A    %7D%0A%0A
     @Value.Check
@@ -2479,100 +2479,773 @@
 null
- && !tablePrefix().isEmpty(),%0A                %22'tablePrefix' must not be an empty string
+, %22Oracle 'tablePrefix' cannot be null.%22);%0A        Preconditions.checkState(!tablePrefix().isEmpty(), %22Oracle 'tablePrefix' must not be an empty string.%22);%0A        Preconditions.checkState(!tablePrefix().startsWith(%22_%22), %22Oracle 'tablePrefix' cannot begin with underscore.%22);%0A        Preconditions.checkState(%0A                tablePrefix().length() %3C= 7 ,%0A                %22Oracle 'tablePrefix' cannot be more than 7 characters long.%22);%0A%0A        Preconditions.checkState(%0A                !overflowTablePrefix().startsWith(%22_%22),%0A                %22Oracle 'overflowTablePrefix' cannot begin with underscore.%22);%0A        Preconditions.checkState(overflowTablePrefix().length() %3C= 6,%0A                %22Oracle 'overflowTablePrefix' cannot be more than 6 characters long.
 %22);%0A
+%0A
     

Add more checks on OracleDDlConfig table prefixes