Class Types
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Type
TheGType
for a boxed type holding aGArray
reference.static final Type
TheGType
for a boxed type holding aGBookmarkFile
.static final Type
The fundamental type corresponding togboolean
.static final Type
The fundamental type from which all boxed types are derived.static final Type
TheGType
for a boxed type holding aGByteArray
reference.static final Type
TheGType
forGBytes
.static final Type
The fundamental type corresponding togchar
.static final Type
TheGType
for a boxed type holding aGChecksum
.static final Type
TheGType
forGDate
.static final Type
TheGType
for a boxed type holding aGDateTime
.static final Type
The fundamental type corresponding togdouble
.static final Type
The fundamental type from which all enumeration types are derived.static final Type
TheGType
for a boxed type holding aGError
.static final Type
The fundamental type from which all flags types are derived.static final Type
The fundamental type corresponding togfloat
.static final Type
TheGType
forGString
.static final Type
TheGType
for a boxed type holding aGHashTable
reference.static final Type
The fundamental type corresponding togint
.static final Type
The fundamental type corresponding togint64
.static final Type
The fundamental type from which all interfaces are derived.static final Type
An invalidGType
used as error return value in some functions which return aGType
.static final Type
TheGType
forGIOChannel
.static final Type
TheGType
forGIOCondition
.static final Type
TheGType
for a boxed type holding aGKeyFile
.static final Type
The fundamental type corresponding toglong
.static final Type
TheGType
for a boxed type holding aGMainContext
.static final Type
TheGType
for a boxed type holding aGMainLoop
.static final Type
TheGType
for a boxed type holding aGMappedFile
.static final Type
TheGType
for a boxed type holding aGMarkupParseContext
.static final Type
TheGType
for a boxed type holding aGMatchInfo
reference.static final Type
A fundamental type which is used as a replacement for the C void return type.static final Type
The fundamental type forGObject
.static final Type
TheGType
for a boxed type holding aGOptionGroup
.static final Type
The fundamental type from which allGParamSpec
types are derived.static final Type
TheGType
forGPatternSpec
.static final Type
The fundamental type corresponding togpointer
.static final Type
TheGType
for a boxed type holding aGPollFD
.static final Type
TheGType
for a boxed type holding aGPtrArray
reference.static final Type
TheGType
for a boxed type holding aGRegex
reference.static final long
First fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE.static final long
Last fundamental type number reserved for BSE.static final long
First fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.static final long
Last fundamental type number reserved for GLib.static final long
First available fundamental type number to create new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL().static final Type
TheGType
for a boxed type holding aGSource
.static final Type
The fundamental type corresponding to nul-terminated C strings.static final Type
TheGType
for a boxed type holding anull
-terminated array of strings.static final Type
TheGType
for a boxed type holding aGThread
.static final Type
TheGType
for a boxed type holding aGTimeZone
.static final Type
TheGType
forGTree
.static final Type
The fundamental type corresponding toguchar
.static final Type
The fundamental type corresponding toguint
.static final Type
The fundamental type corresponding toguint64
.static final Type
The fundamental type corresponding togulong
.static final Type
TheGType
for a boxed type holding aGUri
.static final Type
The fundamental type corresponding toG_TYPE_VARIANT
.static final Type
TheGType
for a boxed type holding aGVariantBuilder
.static final Type
TheGType
for a boxed type holding aGVariantDict
.static final Type
TheGType
for a boxed type holding aGVariantType
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <Z> void
applyIfNotNull
(@Nullable Consumer<? super Z> func, Z cls) Applyfunc
tocls
iffunc
is notnull
.static MemoryLayout
generateClassLayout
(Class<?> cls, String typeName) Generate a MemoryLayout struct with one member: the memory layout of the parent TypeClassstatic MemoryLayout
generateIfaceLayout
(Class<?> cls, String typeName) Generate a MemoryLayout struct with one member: the memory layout of GTypeInterfacestatic <T extends Proxy>
Function<MemorySegment, T> getAddressConstructor
(Class<T> cls) Return the memory address constructor for the provided class.static <T extends TypeInstance,
TC extends TypeClass>
Consumer<TC> getClassInit
(Class<T> cls) static <T extends TypeInstance>
Consumer<T> getInstanceInit
(Class<T> cls) Return a lambda that invokes the instance initializer, with is a method that is annotated withInstanceInit
and takes a single parameter of typeTypeInstance
.static <T extends TypeInstance>
MemoryLayoutgetInstanceLayout
(Class<T> cls, String typeName) Return the memory layout defined in the provided class, or if not found, a newMemoryLayout.structLayout
with one field that points to the memory layout defined in the direct superclass.static <T extends TypeInstance,
TI extends TypeInterface>
Consumer<TI> getInterfaceInit
(Class<T> cls, Class<?> iface) Return a lambda that invokes the interface initializer, with is a method that is annotated withInterfaceInit
and takes a single parameter of the type that is specified withiface
.static MemoryLayout
Return the MemoryLayout that is returned by a method with@MemoryLayout
annotation, or if that annotation is not found, by invokingcls.getMemoryLayout()
if such method exists, or else, return null.getTypeClass
(Class<?> cls) Return the inner TypeClass class, or the inner TypeClass from the superclass, or null if not found.getTypeFlags
(Class<?> cls) Construct aTypeFlags
bitfield that specifies whether the provided class is abstract and/or final.static <TI extends TypeInterface>
Class<TI> getTypeInterface
(Class<?> iface) Return the inner TypeInterface class, or null if not found.static boolean
HAS_VALUE_TABLE
(Type type) Checks iftype
has aTypeValueTable
.static boolean
IS_ABSTRACT
(Type type) Checks iftype
is an abstract type.static boolean
IS_CLASSED
(Type type) Checks iftype
is a classed type.static boolean
IS_DEEP_DERIVABLE
(Type type) Checks iftype
is a deep derivable type.static boolean
IS_DEPRECATED
(Type type) Checks iftype
is deprecated.static boolean
IS_DERIVABLE
(Type type) Checks iftype
is a derivable type.static boolean
IS_DERIVED
(Type type) Checks iftype
is derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).static boolean
Checks iftype
is a final type.static boolean
IS_FUNDAMENTAL
(Type type) Checks iftype
is a fundamental type.static boolean
IS_INSTANTIATABLE
(Type type) Checks iftype
can be instantiated.static boolean
IS_INTERFACE
(Type type) Checks iftype
is an interface type.static boolean
IS_VALUE_ABSTRACT
(Type type) Checks iftype
is an abstract value type.static boolean
IS_VALUE_TYPE
(Type type) Checks iftype
is a value type and can be used with g_value_init().static boolean
isGObjectBased
(Class<?> cls) Check if this class (or in case of an interface, any class that implements it) is a GObject.static Type
Register a new GType for a Java class, interface or enum.static Type
register
(Type parentType, Class<?> javaClass, String typeName, MemoryLayout classLayout, Consumer<TypeClass> classInit, MemoryLayout instanceLayout, Consumer<TypeInstance> instanceInit, Function<MemorySegment, ? extends Proxy> constructor, Function<MemorySegment, ? extends Proxy> typeClassConstructor, Set<TypeFlags> flags) Register a new GType.
-
Field Details
-
INVALID
An invalidGType
used as error return value in some functions which return aGType
. -
NONE
A fundamental type which is used as a replacement for the C void return type. -
INTERFACE
The fundamental type from which all interfaces are derived. -
CHAR
The fundamental type corresponding togchar
.The type designated by
CHAR
is unconditionally an 8-bit signed integer. This may or may not be the same type a the C type "gchar". -
UCHAR
The fundamental type corresponding toguchar
. -
BOOLEAN
The fundamental type corresponding togboolean
. -
INT
The fundamental type corresponding togint
. -
UINT
The fundamental type corresponding toguint
. -
LONG
The fundamental type corresponding toglong
. -
ULONG
The fundamental type corresponding togulong
. -
INT64
The fundamental type corresponding togint64
. -
UINT64
The fundamental type corresponding toguint64
. -
ENUM
The fundamental type from which all enumeration types are derived. -
FLAGS
The fundamental type from which all flags types are derived. -
FLOAT
The fundamental type corresponding togfloat
. -
DOUBLE
The fundamental type corresponding togdouble
. -
STRING
The fundamental type corresponding to nul-terminated C strings. -
POINTER
The fundamental type corresponding togpointer
. -
BOXED
The fundamental type from which all boxed types are derived. -
PARAM
The fundamental type from which allGParamSpec
types are derived. -
OBJECT
The fundamental type forGObject
. -
VARIANT
The fundamental type corresponding toG_TYPE_VARIANT
.All floating
G_TYPE_VARIANT
instances passed through theGType
system are consumed.Note that callbacks in closures, and signal handlers for signals of return type
G_TYPE_VARIANT
, must never return floating variants.Note: GLib 2.24 did include a boxed type with this name. It was replaced with this fundamental type in 2.26.
- Since:
- 2.26
-
DATE
TheGType
forGDate
. -
STRV
TheGType
for a boxed type holding anull
-terminated array of strings.- Since:
- 2.4
-
GSTRING
TheGType
forGString
. -
HASH_TABLE
TheGType
for a boxed type holding aGHashTable
reference.- Since:
- 2.10
-
REGEX
-
MATCH_INFO
TheGType
for a boxed type holding aGMatchInfo
reference.- Since:
- 2.30
-
ARRAY
-
BYTE_ARRAY
TheGType
for a boxed type holding aGByteArray
reference.- Since:
- 2.22
-
PTR_ARRAY
TheGType
for a boxed type holding aGPtrArray
reference.- Since:
- 2.22
-
BYTES
-
VARIANT_TYPE
TheGType
for a boxed type holding aGVariantType
.- Since:
- 2.24
-
ERROR
-
DATE_TIME
-
TIME_ZONE
-
IO_CHANNEL
TheGType
forGIOChannel
. -
IO_CONDITION
TheGType
forGIOCondition
. -
VARIANT_BUILDER
TheGType
for a boxed type holding aGVariantBuilder
.- Since:
- 2.30
-
VARIANT_DICT
TheGType
for a boxed type holding aGVariantDict
.- Since:
- 2.40
-
MAIN_LOOP
-
MAIN_CONTEXT
TheGType
for a boxed type holding aGMainContext
.- Since:
- 2.30
-
SOURCE
-
POLLFD
-
MARKUP_PARSE_CONTEXT
TheGType
for a boxed type holding aGMarkupParseContext
.- Since:
- 2.36
-
KEY_FILE
-
MAPPED_FILE
-
THREAD
-
CHECKSUM
-
OPTION_GROUP
TheGType
for a boxed type holding aGOptionGroup
.- Since:
- 2.44
-
URI
-
TREE
-
PATTERN_SPEC
-
BOOKMARK_FILE
TheGType
for a boxed type holding aGBookmarkFile
.- Since:
- 2.76
-
RESERVED_GLIB_FIRST
public static final long RESERVED_GLIB_FIRSTFirst fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.- See Also:
-
RESERVED_GLIB_LAST
public static final long RESERVED_GLIB_LASTLast fundamental type number reserved for GLib.- See Also:
-
RESERVED_BSE_FIRST
public static final long RESERVED_BSE_FIRSTFirst fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE.- See Also:
-
RESERVED_BSE_LAST
public static final long RESERVED_BSE_LASTLast fundamental type number reserved for BSE.- See Also:
-
RESERVED_USER_FIRST
public static final long RESERVED_USER_FIRSTFirst available fundamental type number to create new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL().- See Also:
-
-
Constructor Details
-
Types
public Types()
-
-
Method Details
-
IS_FUNDAMENTAL
-
IS_DERIVED
-
IS_INTERFACE
Checks iftype
is an interface type.An interface type provides a pure API, the implementation of which is provided by another type (which is then said to conform to the interface). GLib interfaces are somewhat analogous to Java interfaces and C++ classes containing only pure virtual functions, with the difference that GType interfaces are not derivable (but see g_type_interface_add_prerequisite() for an alternative).
- Parameters:
type
- AType
value- Returns:
true
iftype
is an interface
-
IS_CLASSED
Checks iftype
is a classed type.A classed type has an associated
TypeClass
which can be derived to store class-wide virtual function pointers and data for all instances of the type. This allows for subclassing. AllGObject
s are classed; none of the scalar fundamental types built into GLib are classed.Interfaces are not classed: while their
TypeInterface
struct could be considered similar toTypeClass
, and classes can derive interfaces,TypeInterface
doesn’t allow for subclassing.- Parameters:
type
- AType
value- Returns:
true
iftype
is classed
-
IS_INSTANTIATABLE
-
IS_DERIVABLE
-
IS_DEEP_DERIVABLE
-
IS_ABSTRACT
-
IS_VALUE_ABSTRACT
Checks iftype
is an abstract value type. An abstract value type introduces a value table, but can't be used for g_value_init() and is normally used as an abstract base type for derived value types.- Parameters:
type
- AType
value- Returns:
true
iftype
is an abstract value type
-
IS_VALUE_TYPE
-
HAS_VALUE_TABLE
Checks iftype
has aTypeValueTable
.- Parameters:
type
- AType
value- Returns:
true
iftype
has a value table
-
IS_FINAL
-
IS_DEPRECATED
-
getInstanceLayout
public static <T extends TypeInstance> MemoryLayout getInstanceLayout(Class<T> cls, String typeName) Return the memory layout defined in the provided class, or if not found, a newMemoryLayout.structLayout
with one field that points to the memory layout defined in the direct superclass.- Type Parameters:
T
- the class must extendTypeInstance
- Parameters:
cls
- the class to provide a memory layout fortypeName
- the name given tot the generated memory layout- Returns:
- the declared memory layout, or if not found, a generated memory layout that copies the memory layout declared in the direct superclass.
-
getTypeClass
Return the inner TypeClass class, or the inner TypeClass from the superclass, or null if not found.- Parameters:
cls
- the class that contains (or whose superclass contains) an inner TypeClass class- Returns:
- the TypeClass class, or null if not found
-
getTypeInterface
Return the inner TypeInterface class, or null if not found.- Type Parameters:
TI
- the returned class extendsTypeInterface
- Parameters:
iface
- the interface that contains an inner TypeInterface class- Returns:
- the TypeInterface class, or TypeInterface.class if not found
-
generateClassLayout
Generate a MemoryLayout struct with one member: the memory layout of the parent TypeClass- Parameters:
cls
- the class to generate a memory layout fortypeName
- the name of the new memory layout- Returns:
- the requested memory layout
-
generateIfaceLayout
Generate a MemoryLayout struct with one member: the memory layout of GTypeInterface- Parameters:
cls
- the interface to generate a memory layout fortypeName
- the name of the new memory layout- Returns:
- the requested memory layout
-
getLayout
Return the MemoryLayout that is returned by a method with@MemoryLayout
annotation, or if that annotation is not found, by invokingcls.getMemoryLayout()
if such method exists, or else, return null.- Parameters:
cls
- the class for which to return the declared MemoryLayout- Returns:
- the declared MemoryLayout
-
getAddressConstructor
Return the memory address constructor for the provided class. This is a constructor for a new Proxy instance for a native memory address.- Type Parameters:
T
- the class must implement theProxy
interface- Parameters:
cls
- the class that declares a constructor with a singleMemorySegment
parameter- Returns:
- the memory address constructor for this class, or null if not found
-
getInstanceInit
Return a lambda that invokes the instance initializer, with is a method that is annotated withInstanceInit
and takes a single parameter of typeTypeInstance
.- Type Parameters:
T
- the class must extendTypeInstance
- Parameters:
cls
- the class that declares the instance init method- Returns:
- the instance initializer, or a no-op (
$ -> {}
) if not found
-
getClassInit
public static <T extends TypeInstance,TC extends TypeClass> Consumer<TC> getClassInit(Class<T> cls) Return a lambda that invokes the class initializer, with is a method that is annotated withClassInit
and takes a single parameter of typeTypeClass
.- Type Parameters:
T
- the class must extendTypeInstance
TC
- the class initializer must accept aTypeClass
parameter- Parameters:
cls
- the class that declares the class init method- Returns:
- the class initializer, or null if not found
-
getInterfaceInit
public static <T extends TypeInstance,TI extends TypeInterface> Consumer<TI> getInterfaceInit(Class<T> cls, Class<?> iface) Return a lambda that invokes the interface initializer, with is a method that is annotated withInterfaceInit
and takes a single parameter of the type that is specified withiface
.- Type Parameters:
T
- the class must extendTypeInstance
TI
- the iface parameter must extendTypeInterface
- Parameters:
cls
- the class that declares the interface init method- Returns:
- the interface initializer, or null if not found
-
getTypeFlags
-
isGObjectBased
Check if this class (or in case of an interface, any class that implements it) is a GObject.- Parameters:
cls
- the class or interface to check- Returns:
- whether this is a class that extends GObject or an interface that has GObject as a prerequisite
-
register
Register a new GType for a Java class, interface or enum.- For classes, the GType will inherit from the GType of the Java superclass, and will implement all interfaces that are implemented by the Java class.
- Interfaces will be registered as a GType that inherits from
TypeInterface
. It is possible to specify prerequisite types using theRegisteredType
annotation. When no prerequisites are set, GObject is by default set as a prerequisite. - Enums will be registered as a GObject enum type. When a flags
type is preferred, add the
Flags
annotation on the enum.
RegisteredType
annotation. (All invalid characters, including '.', are replaced with underscores.)Use
ClassInit
andInstanceInit
annotations on static methods in the Java class to indicate that these are to be called during GObject class- and instance initialization.The
TypeFlags.ABSTRACT
andTypeFlags.FINAL
flags are set for abstract and final Java classes.- Parameters:
cls
- the class, interface or enumeration to register- Returns:
- the GType of the registered Java type
-
register
public static Type register(Type parentType, Class<?> javaClass, String typeName, MemoryLayout classLayout, Consumer<TypeClass> classInit, MemoryLayout instanceLayout, Consumer<TypeInstance> instanceInit, Function<MemorySegment, ? extends Proxy> constructor, Function<MemorySegment, ? extends Proxy> typeClassConstructor, Set<TypeFlags> flags) Register a new GType.- Parameters:
parentType
- parent GTypetypeName
- name of the GTypeclassLayout
- memory layout of the typeclassclassInit
- static class initializer functioninstanceLayout
- memory layout of the typeinstanceinstanceInit
- static instance initializer functionflags
- type flags- Returns:
- the GType of the registered Java type
-
applyIfNotNull
Applyfunc
tocls
iffunc
is notnull
.- Type Parameters:
Z
-func
must accept the type ofcls
as its parameter- Parameters:
func
- a nullable Consumer operation that will be applied tocls
cls
- the Class that will be passed tofunc
-