diff options
author | Marvin W <git@larma.de> | 2017-04-16 15:11:00 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-04-18 20:20:41 +0200 |
commit | 765c2605cd0abf2b4431051142f09e2676584222 (patch) | |
tree | f01d7a6822adfc47c47f5a0e1ebd048d9dad00d4 /qlite/src/statement_builder.vala | |
parent | c6ff3387fa7b23678bbfe644c9e1b668ac92a731 (diff) | |
download | dino-765c2605cd0abf2b4431051142f09e2676584222.tar.gz dino-765c2605cd0abf2b4431051142f09e2676584222.zip |
qlite: cleanup, fix nullity issues
Diffstat (limited to 'qlite/src/statement_builder.vala')
-rw-r--r-- | qlite/src/statement_builder.vala | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/qlite/src/statement_builder.vala b/qlite/src/statement_builder.vala index 11efb0de..6097a9cc 100644 --- a/qlite/src/statement_builder.vala +++ b/qlite/src/statement_builder.vala @@ -11,25 +11,32 @@ public abstract class StatementBuilder { internal abstract Statement prepare() throws DatabaseError; - internal class Field<T> { + internal abstract class AbstractField<T> { public T value; public Column<T>? column; - public Field(Column<T>? column, T value) { - this.column = column; + public AbstractField(T value) { this.value = value; } - internal virtual void bind(Statement stmt, int index) { - if (column != null) { - column.bind(stmt, index, value); - } + internal abstract void bind(Statement stmt, int index); + } + + internal class Field<T> : AbstractField<T> { + public Field(Column<T> column, T value) { + base(value); + this.column = column; + } + + internal override void bind(Statement stmt, int index) { + ((!)column).bind(stmt, index, value); } } - internal class NullField<T> : Field<T> { - public NullField(Column<T>? column) { - base(column, null); + internal class NullField<T> : AbstractField<T> { + public NullField(Column<T> column) { + base(null); + this.column = column; } internal override void bind(Statement stmt, int index) { @@ -37,9 +44,9 @@ public abstract class StatementBuilder { } } - internal class StringField : Field<string> { + internal class StringField : AbstractField<string> { public StringField(string value) { - base(null, value); + base(value); } internal override void bind(Statement stmt, int index) { |