public abstract class StringConvertingCodec<T> extends ConvertingCodec<String,T>
internalCodec, javaType| Modifier | Constructor and Description |
|---|---|
protected |
StringConvertingCodec(TypeCodec<T> targetCodec,
List<String> nullStrings) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isNull(String s)
Whether the input is null.
|
protected boolean |
isNullOrEmpty(String s)
Whether the input is null or empty.
|
protected String |
nullString()
The string to use when formatting internal inputs.
|
decode, encode, externalToInternal, format, getCqlType, getInternalCodec, getInternalJavaType, getJavaType, internalToExternal, parseprotected boolean isNull(String s)
This method should be used to inspect external inputs that are meant to be converted to textual CQL types only (text, varchar and ascii).
It always considers the empty string as NOT equivalent to NULL, unless the user clearly
specifies that the empty string is to be considered as NULL, through the
codec.nullStrings setting.
Do NOT use this method for non-textual CQL types; use isNullOrEmpty(String)
instead.
protected boolean isNullOrEmpty(String s)
This method should be used to inspect external inputs that are meant to be converted to non-textual CQL types only.
It always considers the empty string as equivalent to NULL, which is in compliance with the
documentation of codec.nullStrings: "Note that, regardless of this setting, DSBulk
will always convert empty strings to `null` if the target CQL type is not textual (i.e. not
text, varchar or ascii)."
Do NOT use this method for textual CQL types; use isNull(String) instead.
protected String nullString()
According to the documentation of codec.nullStrings, we must use the first
string specified there, or simply return null, if that setting is empty.
Copyright © 2017–2021 DataStax. All rights reserved.