DATACASS-68 : Move IndexOperations static methods to Specification objects

This commit is contained in:
Matthew Adams
2013-12-23 10:38:32 -06:00
parent 30f348126c
commit e5baf2af8f
5 changed files with 19 additions and 48 deletions

View File

@@ -108,4 +108,12 @@ public class CreateIndexSpecification extends IndexNameSpecification<CreateIndex
return this;
}
/**
* Entry point into the {@link CreateIndexSpecification}'s fluent API to create a index. Convenient if imported
* statically.
*/
public static CreateIndexSpecification createIndex() {
return new CreateIndexSpecification();
}
}

View File

@@ -25,6 +25,14 @@ public class DropIndexSpecification extends IndexNameSpecification<DropIndexSpec
private boolean ifExists;
/**
* Entry point into the {@link DropIndexSpecification}'s fluent API to drop a table. Convenient if imported
* statically.
*/
public static DropIndexSpecification dropIndex() {
return new DropIndexSpecification();
}
/*
* In CQL 3.1 this is supported so we can uncomment the exposure then.
* In the meantime, it will always be false and tests will pass.

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.springframework.cassandra.core.keyspace;
/**
* Class that offers static methods as entry points into the fluent API for building create, drop and alter index
* specifications. These methods are most convenient when imported statically.
*
* @author Matthew T. Adams
* @author David Webb
*/
public class IndexOperations {
/**
* Entry point into the {@link CreateIndexSpecification}'s fluent API to create a index. Convenient if imported
* statically.
*/
public static CreateIndexSpecification createIndex() {
return new CreateIndexSpecification();
}
/**
* Entry point into the {@link DropIndexSpecification}'s fluent API to drop a table. Convenient if imported
* statically.
*/
public static DropIndexSpecification dropIndex() {
return new DropIndexSpecification();
}
}

View File

@@ -1,7 +1,6 @@
package org.springframework.cassandra.test.unit.core.cql.generator;
import static org.junit.Assert.assertTrue;
import static org.springframework.cassandra.core.keyspace.IndexOperations.createIndex;
import org.junit.Test;
import org.springframework.cassandra.core.cql.generator.CreateIndexCqlGenerator;
@@ -44,7 +43,7 @@ public class CreateIndexCqlGeneratorTests {
public String column1 = "column1";
public CreateIndexSpecification specification() {
return createIndex().name(name).tableName(tableName).columnName(column1);
return CreateIndexSpecification.createIndex().name(name).tableName(tableName).columnName(column1);
}
@Test

View File

@@ -1,7 +1,6 @@
package org.springframework.cassandra.test.unit.core.cql.generator;
import static org.junit.Assert.assertTrue;
import static org.springframework.cassandra.core.keyspace.IndexOperations.dropIndex;
import org.junit.Test;
import org.springframework.cassandra.core.cql.generator.DropIndexCqlGenerator;
@@ -28,7 +27,7 @@ public class DropIndexCqlGeneratorTests {
public String name = "myindex";
public DropIndexSpecification specification() {
return dropIndex().name(name);
return DropIndexSpecification.dropIndex().name(name);
}
public DropIndexCqlGenerator generator() {
@@ -49,7 +48,7 @@ public class DropIndexCqlGeneratorTests {
public String name = "myindex";
public DropIndexSpecification specification() {
return dropIndex().name(name)
return DropIndexSpecification.dropIndex().name(name)
// .ifExists()
;
}