@ -15,8 +15,12 @@
* /
* /
package org.springframework.data.relational.core.sql ;
package org.springframework.data.relational.core.sql ;
import java.util.Collections ;
import java.util.Iterator ;
import java.util.function.UnaryOperator ;
import java.util.function.UnaryOperator ;
import org.springframework.data.util.Streamable ;
/ * *
/ * *
* Represents a named object that exists in the database like a table name or a column name . SQL identifiers are created
* Represents a named object that exists in the database like a table name or a column name . SQL identifiers are created
* from a { @link String name } with specifying whether the name should be quoted or unquoted .
* from a { @link String name } with specifying whether the name should be quoted or unquoted .
@ -28,18 +32,27 @@ import java.util.function.UnaryOperator;
* < p >
* < p >
* { @link SqlIdentifier } objects are immutable . Calling transformational methods such as
* { @link SqlIdentifier } objects are immutable . Calling transformational methods such as
* { @link # transform ( UnaryOperator ) } creates a new instance .
* { @link # transform ( UnaryOperator ) } creates a new instance .
* < p >
* { @link SqlIdentifier } are composable so an identifier may consist of a single identifier part or can be composed from
* multiple parts . Composed identifier can be traversed with { @link # stream ( ) } or { @link # iterator ( ) } . The iteration
* order depends on the actual composition ordering .
*
*
* @author Jens Schauder
* @author Jens Schauder
* @author Mark Paluch
* @author Mark Paluch
* @since 2 . 0
* @since 2 . 0
* /
* /
public interface SqlIdentifier {
public interface SqlIdentifier extends Streamable < SqlIdentifier > {
/ * *
/ * *
* Null - object .
* Null - object .
* /
* /
SqlIdentifier EMPTY = new SqlIdentifier ( ) {
SqlIdentifier EMPTY = new SqlIdentifier ( ) {
@Override
public Iterator < SqlIdentifier > iterator ( ) {
return Collections . emptyIterator ( ) ;
}
@Override
@Override
public SqlIdentifier transform ( UnaryOperator < String > transformationFunction ) {
public SqlIdentifier transform ( UnaryOperator < String > transformationFunction ) {
return this ;
return this ;
@ -99,16 +112,6 @@ public interface SqlIdentifier {
* /
* /
SqlIdentifier transform ( UnaryOperator < String > transformationFunction ) ;
SqlIdentifier transform ( UnaryOperator < String > transformationFunction ) ;
/ * *
* Returns the last part of an identifier . For a fully qualified column name { @literal schema . table . column } it will
* just return the column part . If the identifier consists of only a single part , that part is returned .
*
* @return Guaranteed to be not { @literal null } .
* /
default SqlIdentifier getSimpleIdentifier ( ) {
return this ;
}
/ * *
/ * *
* Create a new quoted identifier given { @code name } .
* Create a new quoted identifier given { @code name } .
*
*