Interface CqlDataSet
-
- All Superinterfaces:
CqlScript
- All Known Implementing Classes:
DefaultCqlDataSet
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface CqlDataSet extends CqlScript
ACqlDataSetrepresents a collection ofCqlScriptinstances, providing functionality to group and manage multiple CQL scripts that can be executed sequentially.This interface provides several factory methods for creating
CqlDataSetinstances, as well as aCqlDataSet.Builderclass for more customizable configurations.Example Usage:
// Creating a CqlDataSet from classpath resources CqlDataSet dataSet = CqlDataSet.ofClassPaths("schema.cql", "data.cql"); // Using a builder to combine multiple resources and scripts CqlDataSet dataSet = CqlDataSet.builder() .addResource(new ClassPathResource("schema.cql")) .addScript("CREATE KEYSPACE test WITH replication = {...};") .build(); // Iterating over CQL statements dataSet.getStatements().forEach(System.out::println);- Since:
- 4.0.1
- Author:
- Dmytro Nosan
- See Also:
CqlScript,DefaultCqlDataSet
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceCqlDataSet.BuilderA builder for constructing instances ofCqlDataSet.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static CqlDataSet.Builderbuilder()Creates a newCqlDataSet.Builderinstance for constructingCqlDataSetobjects.default voidforEachScript(Consumer<? super CqlScript> callback)List<? extends CqlScript>getScripts()Retrieves all theCqlScriptinstances contained within thisCqlDataSet.default List<String>getStatements()Retrieves all the CQL statements from every script in theCqlDataSet.static CqlDataSetofClassPaths(String... names)Creates aCqlDataSetfrom the specified classpath resource names, using the default charset.static CqlDataSetofClassPaths(Charset charset, String... names)Creates aCqlDataSetfrom the specified classpath resource names, using the providedCharset.static CqlDataSetofResources(Resource... resources)Creates aCqlDataSetfrom the specifiedResourceinstances, using the default charset.static CqlDataSetofResources(Charset charset, Resource... resources)static CqlDataSetofScripts(CqlScript... scripts)Creates aCqlDataSetfrom the specifiedCqlScriptinstances.-
Methods inherited from interface com.github.nosan.embedded.cassandra.cql.CqlScript
forEachStatement
-
-
-
-
Method Detail
-
builder
static CqlDataSet.Builder builder()
Creates a newCqlDataSet.Builderinstance for constructingCqlDataSetobjects.- Returns:
- a new
CqlDataSet.Builder - Since:
- 5.0.0
-
ofClassPaths
static CqlDataSet ofClassPaths(String... names)
Creates aCqlDataSetfrom the specified classpath resource names, using the default charset.- Parameters:
names- the resource names (must not benull)- Returns:
- a new
CqlDataSetinstance - Throws:
NullPointerException- ifnamesisnull
-
ofClassPaths
static CqlDataSet ofClassPaths(Charset charset, String... names)
Creates aCqlDataSetfrom the specified classpath resource names, using the providedCharset.- Parameters:
names- the resource names (must not benull)charset- the character encoding to use when reading the resources (must not benull)- Returns:
- a new
CqlDataSetinstance - Throws:
NullPointerException- ifnamesorcharsetisnull
-
ofResources
static CqlDataSet ofResources(Resource... resources)
Creates aCqlDataSetfrom the specifiedResourceinstances, using the default charset.- Parameters:
resources- the resources to use (must not benull)- Returns:
- a new
CqlDataSetinstance - Throws:
NullPointerException- ifresourcesisnull
-
ofResources
static CqlDataSet ofResources(Charset charset, Resource... resources)
- Parameters:
resources- the resources to use (must not benull)charset- the character encoding to use when reading the resources (must not benull)- Returns:
- a new
CqlDataSetinstance - Throws:
NullPointerException- ifresourcesorcharsetisnull
-
ofScripts
static CqlDataSet ofScripts(CqlScript... scripts)
Creates aCqlDataSetfrom the specifiedCqlScriptinstances.If one or more
CqlScriptinstances are themselves instances ofCqlDataSet, their individual scripts are flattened into the resulting dataset.- Parameters:
scripts- the scripts to include (must not benull)- Returns:
- a new
CqlDataSetinstance - Throws:
NullPointerException- ifscriptsisnull
-
forEachScript
default void forEachScript(Consumer<? super CqlScript> callback)
- Parameters:
callback- the action to perform on each script (must not benull)- Throws:
NullPointerException- ifcallbackisnull
-
getStatements
default List<String> getStatements()
Retrieves all the CQL statements from every script in theCqlDataSet.- Specified by:
getStatementsin interfaceCqlScript- Returns:
- an unmodifiable list of all CQL statements (never
null)
-
getScripts
List<? extends CqlScript> getScripts()
Retrieves all theCqlScriptinstances contained within thisCqlDataSet.- Returns:
- a list of
CqlScriptinstances (nevernull)
-
-