Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[misc] client side prepare parameter setting avoiding null check for …
…primitive parameter
- Loading branch information
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/org/mariadb/jdbc/codec/NonNullParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: LGPL-2.1-or-later | ||
// Copyright (c) 2012-2014 Monty Program Ab | ||
// Copyright (c) 2015-2021 MariaDB Corporation Ab | ||
|
||
package org.mariadb.jdbc.codec; | ||
|
||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
import org.mariadb.jdbc.client.Context; | ||
import org.mariadb.jdbc.client.socket.Writer; | ||
import org.mariadb.jdbc.plugin.Codec; | ||
|
||
public class NonNullParameter<T> extends Parameter { | ||
|
||
public NonNullParameter(Codec<T> codec, T value) { | ||
super(codec, value); | ||
} | ||
|
||
public NonNullParameter(Codec<T> codec, T value, Long length) { | ||
super(codec, value, length); | ||
} | ||
|
||
@Override | ||
public void encodeText(Writer encoder, Context context) throws IOException, SQLException { | ||
codec.encodeText(encoder, context, this.value, null, length); | ||
} | ||
|
||
@Override | ||
public boolean isNull() { | ||
return false; | ||
} | ||
} |