public class DbPlatformType extends Object implements ExtraDbTypes
The length is for VARCHAR types and precision/scale for DECIMAL types.
CDIR, HSTORE, INET, JSON, JSONB, JSONBlob, JSONClob, JSONVarchar, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, POINT, POLYGON, UUID
Constructor and Description |
---|
DbPlatformType(String name)
Construct with no length or scale.
|
DbPlatformType(String name,
boolean canHaveLength)
Use with canHaveLength=false for types that should never have a length.
|
DbPlatformType(String name,
int defaultLength)
Construct with a given length.
|
DbPlatformType(String name,
int defaultPrecision,
int defaultScale)
Construct for Decimal with precision and scale.
|
Modifier and Type | Method and Description |
---|---|
int |
getDefaultLength()
Return the default length/precision.
|
int |
getDefaultScale()
Return the default scale.
|
String |
getName()
Return the type name.
|
static DbPlatformType |
parse(String columnDefinition)
Parse a type definition into a DbPlatformType.
|
String |
renderType(int deployLength,
int deployScale)
Return the type for a specific property that incorporates the name, length,
precision and scale.
|
String |
renderType(int deployLength,
int deployScale,
boolean strict)
Render the type defining strict mode.
|
DbPlatformType |
withLength(int defaultLength)
Create a copy of the type with a new default length.
|
public DbPlatformType(String name)
public DbPlatformType(String name, int defaultLength)
public DbPlatformType(String name, int defaultPrecision, int defaultScale)
public DbPlatformType(String name, boolean canHaveLength)
name
- the type namecanHaveLength
- set this to false for type that should never have a lengthpublic static DbPlatformType parse(String columnDefinition)
e.g. "decimal(18,6)" e.g. "text"
public int getDefaultLength()
public int getDefaultScale()
public String renderType(int deployLength, int deployScale)
The deployLength and deployScale are for the property we are rendering the DB type for.
deployLength
- the length or precision defined by deployment on a specific
property.deployScale
- the scale defined by deployment on a specific property.public String renderType(int deployLength, int deployScale, boolean strict)
If strict mode if OFF then this will render with a scale value even if that is not strictly supported. The reason for supporting this is to enable use to use types like jsonb(200) as a "logical" type that maps to JSONB for Postgres and VARCHAR(200) for other databases.
public DbPlatformType withLength(int defaultLength)
Copyright © 2019. All rights reserved.