// Path: src/main/java/org/easycassandra/EasyCassandraException.java
// public class EasyCassandraException extends RuntimeException {
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = -5116386811420121860L;
// 
//     /**
//      * The Constructor for Exception.
//      * @param message information to log
//      */
//     public EasyCassandraException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/org/easycassandra/ReplicaStrategy.java
// public enum ReplicaStrategy {
//     /**
//      * SimpleStrategy places the first replica on a node determined by the
//      * partitioner. Additional replicas are placed on the next nodes clockwise
//      * in the ring without considering rack or data center location.
//      */
//     SIMPLES_TRATEGY("'SimpleStrategy'"),
//     /**
//      * is the preferred replication placement strategy when you have information
//      * about how nodes are grouped in your data center, or when you have (or
//      * plan to have) your cluster deployed across multiple data centers. This
//      * strategy allows you to specify how many replicas you want in each data
//      * center.
//      */
//     NETWORK_TOPOLOGY_STRATEGY("'NetworkTopologyStrategy'"),
//     /**
//      * use a custom query.
//      */
//     CUSTOM_STRATEGY("");
// 
//     private String value;
// 
//     ReplicaStrategy(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// 
// }


import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.easycassandra.EasyCassandraException;
import org.easycassandra.ReplicaStrategy;

        private static final String BEGIN_QUERY = "CREATE KEYSPACE IF NOT EXISTS";
        private static final String ERRO_QUERY_MANDATORY = "When you define custom type to Create "
                + "keyspace you must inform the query.";
        private static final String ERRO_QUERY_BEGIN_MANDATORY = "On custom query you must use "
                + BEGIN_QUERY + " to create your query.";

        @Override
        public String createQuery(KeySpaceQueryInformation information) {
            if (information.customQuery == null
                    || information.customQuery.isEmpty()) {
                throw new CreateKeySpaceException(ERRO_QUERY_MANDATORY);
            }
            if (!findBeginQuery(information)) {
                throw new CreateKeySpaceException(ERRO_QUERY_BEGIN_MANDATORY);
            }
            return information.customQuery;
        }

        private boolean findBeginQuery(KeySpaceQueryInformation information) {
            return Pattern
                    .compile(Pattern.quote(BEGIN_QUERY),
                            Pattern.CASE_INSENSITIVE).matcher(information.customQuery)
                    .find();
        }
    }
    /**
     * Exception to create keySpace.
     * @author otaviojava
     */
// Path: src/main/java/org/easycassandra/EasyCassandraException.java
// public class EasyCassandraException extends RuntimeException {
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = -5116386811420121860L;
// 
//     /**
//      * The Constructor for Exception.
//      * @param message information to log
//      */
//     public EasyCassandraException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/org/easycassandra/ReplicaStrategy.java
// public enum ReplicaStrategy {
//     /**
//      * SimpleStrategy places the first replica on a node determined by the
//      * partitioner. Additional replicas are placed on the next nodes clockwise
//      * in the ring without considering rack or data center location.
//      */
//     SIMPLES_TRATEGY("'SimpleStrategy'"),
//     /**
//      * is the preferred replication placement strategy when you have information
//      * about how nodes are grouped in your data center, or when you have (or
//      * plan to have) your cluster deployed across multiple data centers. This
//      * strategy allows you to specify how many replicas you want in each data
//      * center.
//      */
//     NETWORK_TOPOLOGY_STRATEGY("'NetworkTopologyStrategy'"),
//     /**
//      * use a custom query.
//      */
//     CUSTOM_STRATEGY("");
// 
//     private String value;
// 
//     ReplicaStrategy(String value) {
//         this.value = value;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// 
// }


// Path: src/main/java/org/easycassandra/persistence/cassandra/FixKeySpaceUtil.java
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.easycassandra.EasyCassandraException;
import org.easycassandra.ReplicaStrategy;


        private static final String BEGIN_QUERY = "CREATE KEYSPACE IF NOT EXISTS";
        private static final String ERRO_QUERY_MANDATORY = "When you define custom type to Create "
                + "keyspace you must inform the query.";
        private static final String ERRO_QUERY_BEGIN_MANDATORY = "On custom query you must use "
                + BEGIN_QUERY + " to create your query.";

        @Override
        public String createQuery(KeySpaceQueryInformation information) {
            if (information.customQuery == null
                    || information.customQuery.isEmpty()) {
                throw new CreateKeySpaceException(ERRO_QUERY_MANDATORY);
            }
            if (!findBeginQuery(information)) {
                throw new CreateKeySpaceException(ERRO_QUERY_BEGIN_MANDATORY);
            }
            return information.customQuery;
        }

        private boolean findBeginQuery(KeySpaceQueryInformation information) {
            return Pattern
                    .compile(Pattern.quote(BEGIN_QUERY),
                            Pattern.CASE_INSENSITIVE).matcher(information.customQuery)
                    .find();
        }
    }
    /**
     * Exception to create keySpace.
     * @author otaviojava
     */
    static class CreateKeySpaceException extends EasyCassandraException {