-
@Documented @Target({METHOD,TYPE}) @Repeatable(Container.class) @Retention(CLASS) public @interface Cast
Declares a PostgreSQLCAST
.May annotate a Java method (which should also carry a
@Function
annotation, making it a PostgreSQL function), or a class or interface (just to have a place to put it when not directly associated with a method).If not applied to a method, must supply
path=
specifyingBINARY
orINOUT
.The source and target types must be specified with
from
andto
, unless the annotation appears on a method, in which case these default to the first parameter and return types of the function, respectively.The cast will, by default, have to be applied explicitly, unless
application=ASSIGNMENT
orapplication=IMPLICIT
is given.- Author:
- Chapman Flack
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Cast.Application
application
When this cast can be applied: only in explicit form, when used in assignment context, or implicitly whenever needed.String
comment
A comment to be associated with the cast.String
from
The source type to be cast.String
implementor
The<implementor name>
to be used around SQL code generated for this cast.Cast.Path
path
A stock conversion path when a dedicated function is not supplied:BINARY
for two types that are known to have the same internal representation, orINOUT
to invoke the first type's text-output function followed by the second type's text-input function.String[]
provides
One or more arbitrary labels that will be considered 'provided' by the object carrying this annotation.String[]
requires
One or more arbitrary labels that will be considered 'required' by the object carrying this annotation.String
to
The target type to cast to.
-
-
-
Element Detail
-
from
String from
The source type to be cast. Will default to the first parameter type of the associated function, if known.PostgreSQL will allow this type and the function's first parameter type to differ, if there is an existing binary cast between them. That cannot be checked at compile time, so a cast with a different type given here might successfully compile but fail to deploy in PostgreSQL.
- Default:
- ""
-
-
-
to
String to
The target type to cast to. Will default to the return type of the associated function, if known.PostgreSQL will allow this type and the function's return type to differ, if there is an existing binary cast between them. That cannot be checked at compile time, so a cast with a different type given here might successfully compile but fail to deploy in PostgreSQL.
- Default:
- ""
-
-
-
path
Cast.Path path
A stock conversion path when a dedicated function is not supplied:BINARY
for two types that are known to have the same internal representation, orINOUT
to invoke the first type's text-output function followed by the second type's text-input function.To declare an
INOUT
cast,with=INOUT
must appear explicitly; the default value is treated as unspecified.- Default:
- org.postgresql.pljava.annotation.Cast.Path.INOUT
-
-
-
application
Cast.Application application
When this cast can be applied: only in explicit form, when used in assignment context, or implicitly whenever needed.- Default:
- org.postgresql.pljava.annotation.Cast.Application.EXPLICIT
-
-
-
provides
String[] provides
One or more arbitrary labels that will be considered 'provided' by the object carrying this annotation. The deployment descriptor will be generated in such an order that other objects that 'require' labels 'provided' by this come later in the output for install actions, and earlier for remove actions.- Default:
- {}
-
-
-
requires
String[] requires
One or more arbitrary labels that will be considered 'required' by the object carrying this annotation. The deployment descriptor will be generated in such an order that other objects that 'provide' labels 'required' by this come earlier in the output for install actions, and later for remove actions.- Default:
- {}
-
-
-
implementor
String implementor
The<implementor name>
to be used around SQL code generated for this cast. Defaults toPostgreSQL
. Set explicitly to""
to emit code not wrapped in an<implementor block>
.- Default:
- ""
-
-
-
comment
String comment
A comment to be associated with the cast. If left to default, and the annotated Java construct has a doc comment, its first sentence will be used. If an empty string is explicitly given, no comment will be set.- Default:
- ""
-
-