-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
347b71a
commit 602619f
Showing
8 changed files
with
118 additions
and
619 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
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
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
34 changes: 34 additions & 0 deletions
34
databend-client/src/main/java/com/databend/client/data/ColumnTypeHandlerBase.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,34 @@ | ||
package com.databend.client.data; | ||
|
||
public abstract class ColumnTypeHandlerBase implements ColumnTypeHandler { | ||
private boolean isNullable; | ||
|
||
public ColumnTypeHandlerBase(boolean isNullable) { | ||
this.isNullable = isNullable; | ||
} | ||
public boolean isNull(String value) { | ||
if (value == null || value.equals("NULL")) { | ||
if (isNullable) { | ||
return true; | ||
} else { | ||
throw new IllegalArgumentException("type is not nullable"); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public Object parseValue(String value) { | ||
if (isNull(value)) { | ||
return null; | ||
} | ||
return parseString(value); | ||
} | ||
|
||
@Override | ||
public void setNullable(boolean isNullable) { | ||
this.isNullable = isNullable; | ||
} | ||
|
||
abstract Object parseString(String value); | ||
} |
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
Oops, something went wrong.