Package io.ebean.config.dbplatform
Class DbPlatformType
- java.lang.Object
-
- io.ebean.config.dbplatform.DbPlatformType
-
- All Implemented Interfaces:
ExtraDbTypes
public class DbPlatformType extends Object implements ExtraDbTypes
Represents a DB type with name, length, precision, and scale.The length is for VARCHAR types and precision/scale for DECIMAL types.
-
-
Field Summary
-
Fields inherited from interface io.ebean.config.dbplatform.ExtraDbTypes
CIDR, HSTORE, INET, JSON, JSONB, JSONBlob, JSONClob, JSONVarchar, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, POINT, POLYGON, UUID
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
DbPlatformType
public DbPlatformType(String name)
Construct with no length or scale.
-
DbPlatformType
public DbPlatformType(String name, int defaultLength)
Construct with a given length.
-
DbPlatformType
public DbPlatformType(String name, int defaultPrecision, int defaultScale)
Construct for Decimal with precision and scale.
-
DbPlatformType
public DbPlatformType(String name, boolean canHaveLength)
Use with canHaveLength=false for types that should never have a length.- Parameters:
name
- the type namecanHaveLength
- set this to false for type that should never have a length
-
-
Method Detail
-
parse
public static DbPlatformType parse(String columnDefinition)
Parse a type definition into a DbPlatformType.e.g. "decimal(18,6)" e.g. "text"
-
getDefaultLength
public int getDefaultLength()
Return the default length/precision.
-
getDefaultScale
public int getDefaultScale()
Return the default scale.
-
renderType
public String renderType(int deployLength, int deployScale)
Return the type for a specific property that incorporates the name, length, precision and scale.The deployLength and deployScale are for the property we are rendering the DB type for.
- Parameters:
deployLength
- the length or precision defined by deployment on a specific property.deployScale
- the scale defined by deployment on a specific property.
-
renderType
public String renderType(int deployLength, int deployScale, boolean strict)
Render the type defining strict mode.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.
-
withLength
public DbPlatformType withLength(int defaultLength)
Create a copy of the type with a new default length.
-
-