All Manuals > LispWorks User Guide and Reference Manual > 41 The LW-JI Package

NextPrevUpTopContentsIndex

setup-field-accessor

Function
Summary

Defines a Java field accessor.

Package

lw-ji

Signature

setup-field-accessor name class-name field-name static-p &optional is-final => result, error

Arguments

name

A symbol.

class-name

A string.

field-name

A string.

static-p

A boolean.

is-final

A boolean.

Values

result

name or nil.

error

A condition or nil.

Description

The function setup-field-accessor defines a field accessor for a field in a Java class.

class-name must name a Java class.

field-name must be a field name.

static-p specifies whether the field is static or not.

is-final specifies whether the field is final (read-only) or not.

setup-field-accessor sets the symbol function of name to a function that reads the value of the field. If is-final is nil, it also defines (setf name) as the setter.

The arguments for the getter and setter are determined by the value of static-p. If static-p is non-nil, the getter takes no arguments and the setter takes the new value. If static-p is nil, the getter takes that object from which to get the value, and the setter gets the value and the object.

setup-field-accessor looks up the field definition in Java, and if the definition is incorrect returns nil and the condition as the second value.

Notes

In general, accessing fields should be avoided, because they are typically a less well-defined and implemented interface than methods, but sometimes it is necessary.

See also

define-field-accessor


LispWorks User Guide and Reference Manual - 20 Sep 2017

NextPrevUpTopContentsIndex