-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from alex268/master
Fixed exception on PgType usage
- Loading branch information
Showing
3 changed files
with
85 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package tech.ydb.table.values; | ||
|
||
import java.util.Objects; | ||
|
||
import tech.ydb.proto.ValueProtos; | ||
import tech.ydb.table.values.proto.ProtoType; | ||
|
||
/** | ||
* | ||
* @author Aleksandr Gorshenin | ||
*/ | ||
public class PgType implements Type { | ||
private final int oid; | ||
private final int typlen; | ||
private final int typmod; | ||
|
||
private PgType(int oid, int typlen, int typmod) { | ||
this.oid = oid; | ||
this.typlen = typlen; | ||
this.typmod = typmod; | ||
} | ||
|
||
public static PgType of(int oid) { | ||
return new PgType(oid, 0, 0); | ||
} | ||
|
||
public static PgType of(int oid, int typlen, int typmod) { | ||
return new PgType(oid, typlen, typmod); | ||
} | ||
|
||
public int getOid() { | ||
return oid; | ||
} | ||
|
||
@Override | ||
public Kind getKind() { | ||
return Kind.PG_TYPE; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
PgType that = (PgType) o; | ||
return oid == that.oid && typlen == that.typlen && typmod == that.typmod; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(oid, typlen, typmod); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PgType[" + oid + "]"; | ||
} | ||
|
||
@Override | ||
public ValueProtos.Type toPb() { | ||
return ProtoType.getPgType(oid, typlen, typmod); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -46,6 +46,7 @@ enum Kind { | |
STRUCT, | ||
DICT, | ||
VARIANT, | ||
VOID; | ||
VOID, | ||
PG_TYPE; | ||
} | ||
} |
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