Class SimpleColumnPattern<T,U>
java.lang.Object
bayern.steinbrecher.dbConnector.scheme.ColumnPattern<T,U>
bayern.steinbrecher.dbConnector.scheme.SimpleColumnPattern<T,U>
- Type Parameters:
T- The type of the contents this column holds.U- The type of object to set the content of this column to.
public class SimpleColumnPattern<T,U> extends ColumnPattern<T,U>
Represents a
ColumnPattern representing a specific column name instead of an actual pattern
for column names.- Since:
- 0.1
-
Constructor Summary
Constructors Constructor Description SimpleColumnPattern(@NotNull java.lang.String realColumnName, @NotNull ColumnParser<T> parser, @NotNull java.util.function.BiFunction<U,T,U> setter)Creates a new simple column pattern, i.e. a pattern which specifies a specific column name.SimpleColumnPattern(@NotNull java.lang.String realColumnName, @NotNull ColumnParser<T> parser, @NotNull java.util.function.BiFunction<U,T,U> setter, @NotNull java.util.Optional<java.util.Optional<T>> defaultValue, boolean isPrimaryKey, boolean allowNull)Creates a new simple column pattern, i.e. a pattern which specifies a specific column name. -
Method Summary
Modifier and Type Method Description protected UcombineImpl(U toSet, @NotNull java.lang.String columnName, T value)@NotNull java.util.Optional<java.util.Optional<T>>getDefaultValue()Returns the default value to set when creating a table containing this column.@NotNull java.lang.StringgetRealColumnName()Returns the real column name of this column.java.lang.StringgetSQLDefaultValue()booleanhasDefaultValue()Checks whether a default value is set for this columnbooleanisAllowNull()booleanisPrimaryKey()Methods inherited from class bayern.steinbrecher.dbConnector.scheme.ColumnPattern
combine, equals, getColumnNamePattern, getParser, hashCode, matches, toString
-
Constructor Details
-
SimpleColumnPattern
public SimpleColumnPattern(@NotNull @NotNull java.lang.String realColumnName, @NotNull @NotNull ColumnParser<T> parser, @NotNull @NotNull java.util.function.BiFunction<U,T,U> setter)Creates a new simple column pattern, i.e. a pattern which specifies a specific column name. This constructor may be used ifSimpleColumnPatternis an immutable type.- Parameters:
realColumnName- The exact name of the column to match.parser- The parser to convert values from and to a SQL representation.setter- The function used to set a parsed value to a given object. The setter should only return a new object of typeSimpleColumnPatternif the handed in one is immutable.- Since:
- 0.5
-
SimpleColumnPattern
public SimpleColumnPattern(@NotNull @NotNull java.lang.String realColumnName, @NotNull @NotNull ColumnParser<T> parser, @NotNull @NotNull java.util.function.BiFunction<U,T,U> setter, @NotNull @NotNull java.util.Optional<java.util.Optional<T>> defaultValue, boolean isPrimaryKey, boolean allowNull)Creates a new simple column pattern, i.e. a pattern which specifies a specific column name. This constructor may be used ifSimpleColumnPatternis an immutable type.- Parameters:
realColumnName- The exact name of the column to match.parser- The parser to convert values from and to a SQL representation.setter- The function used to set a parsed value to a given object. The setter should only return a new object of typeSimpleColumnPatternif the handed in one is immutable.defaultValue- The default value of this column.Optional.empty()represents explicitely no default value. AnOptionalof anOptional.empty()representsnullas default value. Otherwise the value of the innerOptionalrepresents the default value.- Since:
- 0.5
- See Also:
ColumnPattern(String, ColumnParser)
-
-
Method Details
-
combineImpl
@NotNull protected U combineImpl(@NotNull U toSet, @NotNull @NotNull java.lang.String columnName, @Nullable T value)- Specified by:
combineImplin classColumnPattern<T,U>- Since:
- 0.1
- See Also:
ColumnPattern.combine(Object, String, String)
-
getRealColumnName
@NotNull public @NotNull java.lang.String getRealColumnName()Returns the real column name of this column.- Returns:
- The real column name of this column.
- Since:
- 0.1
-
hasDefaultValue
public boolean hasDefaultValue()Checks whether a default value is set for this column- Returns:
trueonly if a default value is associated with this column.- Since:
- 0.1
-
getDefaultValue
Returns the default value to set when creating a table containing this column.- Returns:
- The default value to set when creating a table containing this column. See description of constructors.
- Since:
- 0.1
-
getSQLDefaultValue
public java.lang.String getSQLDefaultValue() -
isPrimaryKey
public boolean isPrimaryKey()- Since:
- 0.5
-
isAllowNull
public boolean isAllowNull()- Since:
- 0.5
-