class CharacterType extends StringType {

    public static final String NAME = "character";
    public static final int ID = 27;
    public static final CharacterType INSTANCE = new CharacterType();

    public static CharacterType of(List<Integer> parameters) {
        if (parameters.size() != 1) {
            throw new IllegalArgumentException(
                "The character type can only have a single parameter value, received: " +
                    parameters.size()
            );
        }
        return CharacterType.of(parameters.get(0));
    }

    public static CharacterType of(int lengthLimit) {
        if (lengthLimit <= 0) {
            throw new IllegalArgumentException(
                "The character type length must be at least 1, received: " + lengthLimit);
        }
        return new CharacterType(lengthLimit);
    }

    private final int lengthLimit;

    public CharacterType(StreamInput in) throws IOException {
        lengthLimit = in.readInt();
    }

    public CharacterType(int lengthLimit) {
        this.lengthLimit = lengthLimit;
    }

    private CharacterType() {
        this(1);
    }

    @Override
    public String getName() {
        return NAME;
    }

    @Override
    public int id() {
        return ID;
    }

    @Override
    public int lengthLimit() {
        return lengthLimit;
    }

    @Override
    public boolean unbound() {
        return false;
    }

    @Override
    public String valueForInsert(String value) {
        if (value == null) {
            return null;
        }
        if (value.length() == lengthLimit) {
            return value;
        } else if (value.length() < lengthLimit) {
            return padEnd(value, lengthLimit, ' ');
        } else {
            if (isBlank(value, lengthLimit, value.length())) {
                return value.substring(0, lengthLimit);
            } else {
                if (value.length() > 20) {
                    value = value.substring(0, 20) + "...";
                }
                throw new IllegalArgumentException(
                    "'" + value + "' is too long for the character type of length: " + lengthLimit);
            }
        }
    }

    @Override
    public String implicitCast(Object value) throws IllegalArgumentException, ClassCastException {
        var s = cast(value);
        if (s != null) {
            return padEnd(s, lengthLimit, ' ');
        }
        return s;
    }

    @Override
    public String explicitCast(Object value, SessionSettings sessionSettings) throws IllegalArgumentException, ClassCastException {<FILL_FUNCTION_BODY>}

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        out.writeInt(lengthLimit);
    }

    @Override
    public ColumnType<Expression> toColumnType(ColumnPolicy columnPolicy,
                                               @Nullable Supplier<List<ColumnDefinition<Expression>>> convertChildColumn) {
        return new ColumnType<>(NAME, List.of(lengthLimit));
    }

    @Override
    public Integer characterMaximumLength() {
        return lengthLimit;
    }

    @Override
    public TypeSignature getTypeSignature() {
        return new TypeSignature(NAME, List.of(TypeSignature.of(lengthLimit)));
    }

    @Override
    public List<DataType<?>> getTypeParameters() {
        return List.of(DataTypes.INTEGER);
    }

    @Override
    public Precedence precedence() {
        return Precedence.CHARACTER;
    }

    @Override
    public void addMappingOptions(Map<String, Object> mapping) {
        mapping.put("length_limit", lengthLimit);
        mapping.put("blank_padding", true);
    }
}

        if (value == null) {
            return null;
        }
        var string = cast(value);
        if (string.length() <= lengthLimit()) {
            return string;
        } else {
            return string.substring(0, lengthLimit());
        }
    
<methods>public void <init>(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public void addMappingOptions(Map<java.lang.String,java.lang.Object>) ,public java.lang.Integer characterMaximumLength() ,public ColumnStatsSupport<java.lang.String> columnStatsSupport() ,public int compare(java.lang.String, java.lang.String) ,public boolean equals(java.lang.Object) ,public java.lang.String explicitCast(java.lang.Object, io.crate.metadata.settings.SessionSettings) throws java.lang.IllegalArgumentException, java.lang.ClassCastException,public java.lang.String getName() ,public List<DataType<?>> getTypeParameters() ,public io.crate.types.TypeSignature getTypeSignature() ,public int hashCode() ,public int id() ,public java.lang.String implicitCast(java.lang.Object) throws java.lang.IllegalArgumentException, java.lang.ClassCastException,public boolean isConvertableTo(DataType<?>, boolean) ,public int lengthLimit() ,public static io.crate.types.StringType of(List<java.lang.Integer>) ,public static io.crate.types.StringType of(int) ,public io.crate.types.DataType.Precedence precedence() ,public java.lang.String readValueFrom(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public java.lang.String sanitizeValue(java.lang.Object) ,public StorageSupport<java.lang.Object> storageSupport() ,public Streamer<java.lang.String> streamer() ,public ColumnType<io.crate.sql.tree.Expression> toColumnType(io.crate.sql.tree.ColumnPolicy, Supplier<List<ColumnDefinition<io.crate.sql.tree.Expression>>>) ,public java.lang.String toString() ,public boolean unbound() ,public long valueBytes(java.lang.String) ,public java.lang.String valueForInsert(java.lang.String) ,public void writeTo(org.elasticsearch.common.io.stream.StreamOutput) throws java.io.IOException,public void writeValueTo(org.elasticsearch.common.io.stream.StreamOutput, java.lang.String) throws java.io.IOException<variables>public static final java.lang.String F,public static final int ID,public static final io.crate.types.StringType INSTANCE,private static final StorageSupport<java.lang.Object> STORAGE,public static final java.lang.String T,private final non-sealed int lengthLimit