Class ColumnName

java.lang.Object
org.springframework.data.cassandra.core.query.ColumnName

public abstract class ColumnName extends Object
Value object representing a column name. Column names can be expressed either through CqlIdentifier or a String literal. Using a String literal preserves case and is suitable to reference properties.

Equality and hash code are based on toCql() representation.

Implementing classes must provide either getColumnName() or getCqlIdentifier().

Since:
2.0
Author:
Mark Paluch
See Also:
  • CqlIdentifier
  • Constructor Details

    • ColumnName

      public ColumnName()
  • Method Details

    • from

      public static <T,P> ColumnName from(TypedPropertyPath<T,P> property)
      Create a ColumnName given a property.
      Parameters:
      property - must not be null.
      Returns:
      the ColumnName for PropertyPath
      Since:
      5.1
    • from

      public static ColumnName from(PropertyPath propertyPath)
      Create a ColumnName given a property.
      Parameters:
      propertyPath - must not be null.
      Returns:
      the ColumnName for PropertyPath
      Since:
      5.1
    • from

      public static ColumnName from(com.datastax.oss.driver.api.core.CqlIdentifier cqlIdentifier)
      Create a ColumnName given CqlIdentifier. The resulting instance uses CQL identifier rules to identify column names (quoting, case-sensitivity).
      Parameters:
      cqlIdentifier - must not be null.
      Returns:
      the ColumnName for CqlIdentifier
      See Also:
      • CqlIdentifier
    • from

      public static ColumnName from(String columnName)
      Create a ColumnName given a string columnName. The resulting instance uses String rules to identify column names (case-sensitivity).
      Parameters:
      columnName - must not be null or empty.
      Returns:
      the ColumnName for columnName
    • getColumnName

      public Optional<String> getColumnName()
      Returns:
      the optional column name.
    • hasColumnName

      public boolean hasColumnName()
      Indicates whether a column name is available.
      Returns:
      true if a (string or CqlIdentifier) column name is available; false otherwise.
      Since:
      5.1
    • getPropertyPath

      public @Nullable PropertyPath getPropertyPath()
      Returns:
      the optional PropertyPath.
    • hasPropertyPath

      public boolean hasPropertyPath()
      Indicates whether a PropertyPath is available.
      Returns:
      true if a PropertyPath is available; false otherwise.
      Since:
      5.1
    • getRequiredPropertyPath

      public PropertyPath getRequiredPropertyPath()
      Returns the required PropertyPath or throws an IllegalStateException if not available.
      Returns:
      the required PropertyPath.
      Throws:
      IllegalStateException - if no PropertyPath is available.
      Since:
      5.1
    • getCqlIdentifier

      public Optional<com.datastax.oss.driver.api.core.CqlIdentifier> getCqlIdentifier()
      Returns:
      the optional CqlIdentifier.
    • getRequiredCqlIdentifier

      public com.datastax.oss.driver.api.core.CqlIdentifier getRequiredCqlIdentifier()
      Returns the required CqlIdentifier or constructs one from available information.
      Returns:
      the required CqlIdentifier.
      Since:
      5.1
    • toCql

      public abstract String toCql()
      Represent the column name as CQL.
      Returns:
      CQL representation of the column name.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object