Exposer
will look for when during the definition of a
PyType
.
Modifier and Type | Class and Description |
---|---|
public static @interface | Exposed.Default
Provide default value for the annotated parameter. |
public static @interface | Exposed.Deleter
Identify a method as that to be called during a Python call to
|
public static @interface | Exposed.DocString
Specify the documentation string ( |
public static @interface | Exposed.FrozenArray
Documentation-only annotation reminding us that the defining class guarantees not to change the contents. |
public static @interface | Exposed.Getter
Identify a method as that to be called during a Python call to
|
public static @interface | Exposed.KeywordCollector
Declare that the annotated parameter is the collector for excess keyword arguments. |
public static @interface | Exposed.KeywordOnly
Declare that the annotated parameter is the first keyword only parameter. |
public static @interface | Exposed.Member
Identify a field of a Python object as an exposed attribute. |
public static @interface | Exposed.Name
Override the name of an parameter to a method defined in Java, as it will appear to Python (in generated signatures and error messages). |
public static @interface | Exposed.PositionalCollector
Declare that the annotated parameter is the collector for excess positional arguments. |
public static @interface | Exposed.PositionalOnly
Declare that the annotated parameter is the last positional only parameter. |
public static @interface | Exposed.PythonMethod
Identify a Python instance method of a type or module defined in Java and exposed to Python. |
public static @interface | Exposed.PythonStaticMethod
Identify a Python static method of a type or module defined in Java and exposed to Python. |
public static @interface | Exposed.Setter
Identify a method as that to be called during a Python call to
|
String
: "None", an integer, or a
single-quoted string. For example PyList split( @Default("None") Object sep, @Default("-1") int maxsplit )
Modifier and Type | Method and Description |
---|---|
public String |
value | back to summary |
---|---|
public String value() |
__delattr__
naming an exposed attribute.
The signature must be ()V
.
Modifier and Type | Method and Description |
---|---|
public String | Returns: name of the attributeExposed name of the attribute, if different from the Java method name. |
__doc__
) for a method,
field, etc. defined in Java and exposed to Python.
Modifier and Type | Method and Description |
---|---|
public String |
value | back to summary |
---|---|
public String value() |
__getattribute__
naming an exposed attribute.
The signature must be ()T
where T
can be
Object
if the implementor has no reason to do otherwise.
(One reason might be type safety when calling the same method
from Java.) The annotated method is responsible for converting to
T
from however the attribute is represented internally to
the type.
Modifier and Type | Method and Description |
---|---|
public String | Returns: name of the attributeExposed name of the attribute, if different from the Java method name. |
PyDict
.
final
it will be
read-only.
Some primitive types and String
receive special support
for conversion from Python objects. A field of type
Object
may easily be made a member and will then receive
any Python object.
The annotated field may have any Java reference type. In that
case, an attempt to assign a Python object of the wrong Java type
will raise a TypeError
. This makes it possible to declare
an attribute of a specific Python type. For example one enforce
tuple
values by declaring the field as a PyTuple
.
The field would also accept Python sub-classes of the attribute
type, since they must be sub-classes in Java too.
This approach creates a limitation where the corresponding Python
type has multiple Java implementations not related by Java
inheritance and is not specially provided for (like
String
). The set operation of the Member
attribute will reject instances that have the intended Python
type but non-matching Java type (with a confusing
TypeError
to boot). A writable attribute of that type
should be implemented as Object
or using explicit
Getter
, Setter
and Deleter
methods.
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true if access following delete will raise an errorA member may be |
public boolean | |
public String |
optional | back to summary |
---|---|
public boolean optional() A member may be
|
readonly | back to summary |
---|---|
public boolean readonly()
|
value | back to summary |
---|---|
public String value() Exposed name of the member if different from the field.
|
Modifier and Type | Method and Description |
---|---|
public String |
value | back to summary |
---|---|
public String value() |
PyTuple
.
When found in the classes that define a built-in type, this annotation results in a method definition, then a descriptor in the dictionary of the type. When found in the class that defines a built-in module, this annotation results in a method definition in the module specification, and a bound method in the dictionary of each module instance created from it.
Annotations may appear on the parameters of a method annotated
with PythonMethod
. These further describe the method,
defining the parameters as positional-only parameters, or
providing default values. A method may also be annotated with a
documentation string (in the Python sense), by means of the
@DocString
annotation.
In types that accept multiple implementations, more than one
method of the same name may be annotated PythonMethod
.
Only one may be the primary definition (see
PythonMethod#primary()
, and only in that one are the
documentation string and parameter annotations effective. (It
need not be the first definition.) These annotations on the
primary definition define the signature that Python sees.
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true (the default) if and only if this is the
primary definition of the methodThe element |
public boolean | Returns: true (the default) if and only if this is the
primary definition of the methodThe element |
public String |
positionalOnly | back to summary |
---|---|
public boolean positionalOnly() The element def g(a, b, c): print(a, b, c)may be called as >>> g(b=2, c=3, a=1) 1 2 3 >>> g(**dict(b=2, c=3, a=1)) 1 2 3It is as if we had annotated an imaginary parameter before the first declared parameter (or self ) with
@PositionalOnly .
The default
|
primary | back to summary |
---|---|
public boolean primary() The element
|
value | back to summary |
---|---|
public String value() Exposed name of the method if different from the declaration.
|
When found in the classes that define a built-in type, this
annotation results in a method definition, then a
staticmethod
object in the dictionary of the type. When
found in the class that defines a built-in module, this
annotation results in a method definition in the module
specification, and an unbound method in the dictionary of each
module instance created from it.
Annotations may appear on the parameters of a method annotated
with PythonStaticMethod
. These further describe the
method, defining the parameters as positional-only parameters, or
providing default values. A method may also be annotated with a
documentation string (in the Python sense), by means of the
@DocString
annotation.
Only one method of the given name, in a given class class, may be
annotated as a PythonStaticMethod
.
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true (the default) if and only if this is the
primary definition of the methodThe element |
public String |
positionalOnly | back to summary |
---|---|
public boolean positionalOnly() The element def g(a, b, c): print(a, b, c)may be called as >>> g(b=2, c=3, a=1) 1 2 3 >>> g(**dict(b=2, c=3, a=1)) 1 2 3It is as if we had annotated an imaginary parameter before the first declared parameter (or self ) with
@PositionalOnly .
The default
|
value | back to summary |
---|---|
public String value() Exposed name of the function if different from the declaration.
|
__setattr__
naming an exposed attribute.
The signature must be (T)V
where T
is often
Object
. The annotated method is responsible for
converting this to the form in which the attribute is represented
internally to the type. If T
is something more specific
than Object
, a cast occurs to this Java type during the
descriptor call, which if it fails will raise a Python
TypeError
.
Modifier and Type | Method and Description |
---|---|
public String | Returns: name of the attributeExposed name of the attribute, if different from the Java method name. |