Class Types
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TypeTheGTypefor a boxed type holding aGArrayreference.static final TypeTheGTypefor a boxed type holding aGBookmarkFile.static final TypeThe fundamental type corresponding togboolean.static final TypeThe fundamental type from which all boxed types are derived.static final TypeTheGTypefor a boxed type holding aGByteArrayreference.static final TypeTheGTypeforGBytes.static final TypeThe fundamental type corresponding togchar.static final TypeTheGTypefor a boxed type holding aGChecksum.static final TypeTheGTypeforGDate.static final TypeTheGTypefor a boxed type holding aGDateTime.static final TypeThe fundamental type corresponding togdouble.static final TypeThe fundamental type from which all enumeration types are derived.static final TypeTheGTypefor a boxed type holding aGError.static final TypeThe fundamental type from which all flags types are derived.static final TypeThe fundamental type corresponding togfloat.static final TypeTheGTypeforGString.static final TypeTheGTypefor a boxed type holding aGHashTablereference.static final TypeThe fundamental type corresponding togint.static final TypeThe fundamental type corresponding togint64.static final TypeThe fundamental type from which all interfaces are derived.static final TypeAn invalidGTypeused as error return value in some functions which return aGType.static final TypeTheGTypeforGIOChannel.static final TypeTheGTypeforGIOCondition.static final TypeTheGTypefor a boxed type holding aGKeyFile.static final TypeThe fundamental type corresponding toglong.static final TypeTheGTypefor a boxed type holding aGMainContext.static final TypeTheGTypefor a boxed type holding aGMainLoop.static final TypeTheGTypefor a boxed type holding aGMappedFile.static final TypeTheGTypefor a boxed type holding aGMarkupParseContext.static final TypeTheGTypefor a boxed type holding aGMatchInforeference.static final TypeA fundamental type which is used as a replacement for the C void return type.static final TypeThe fundamental type forGObject.static final TypeTheGTypefor a boxed type holding aGOptionGroup.static final TypeThe fundamental type from which allGParamSpectypes are derived.static final TypeTheGTypeforGPatternSpec.static final TypeThe fundamental type corresponding togpointer.static final TypeTheGTypefor a boxed type holding aGPollFD.static final TypeTheGTypefor a boxed type holding aGPtrArrayreference.static final TypeTheGTypefor a boxed type holding aGRegexreference.static final longFirst fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE.static final longLast fundamental type number reserved for BSE.static final longFirst fundamental type number to create a new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib.static final longLast fundamental type number reserved for GLib.static final longFirst available fundamental type number to create new fundamental type id with G_TYPE_MAKE_FUNDAMENTAL().static final TypeTheGTypefor a boxed type holding aGSource.static final TypeThe fundamental type corresponding to nul-terminated C strings.static final TypeTheGTypefor a boxed type holding anull-terminated array of strings.static final TypeTheGTypefor a boxed type holding aGThread.static final TypeTheGTypefor a boxed type holding aGTimeZone.static final TypeTheGTypeforGTree.static final TypeThe fundamental type corresponding toguchar.static final TypeThe fundamental type corresponding toguint.static final TypeThe fundamental type corresponding toguint64.static final TypeThe fundamental type corresponding togulong.static final TypeTheGTypefor a boxed type holding aGUri.static final TypeThe fundamental type corresponding toG_TYPE_VARIANT.static final TypeTheGTypefor a boxed type holding aGVariantBuilder.static final TypeTheGTypefor a boxed type holding aGVariantDict.static final TypeTheGTypefor a boxed type holding aGVariantType. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <Z> voidapplyIfNotNull(@Nullable Consumer<? super Z> func, Z cls) Applyfunctoclsiffuncis notnull.static MemoryLayoutgenerateClassLayout(Class<?> cls, String typeName) Generate a MemoryLayout struct with one member: the memory layout of the parent TypeClassstatic MemoryLayoutgenerateIfaceLayout(Class<?> cls, String typeName) Generate a MemoryLayout struct with one member: the memory layout of GTypeInterfacestatic <T extends @Nullable Proxy>
@Nullable Function<@Nullable MemorySegment, T> getAddressConstructor(Class<T> cls) Return the memory address constructor for the provided class.static <T extends TypeInstance,TC extends TypeClass>
@Nullable 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 withInstanceInitand 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.structLayoutwith one field that points to the memory layout defined in the direct superclass.static <T extends TypeInstance,TI extends TypeInterface>
@Nullable Consumer<TI> getInterfaceInit(Class<T> cls, Class<?> iface) Return a lambda that invokes the interface initializer, with is a method that is annotated withInterfaceInitand takes a single parameter of the type that is specified withiface.static @Nullable MemoryLayoutReturn the MemoryLayout that is returned by a method with@MemoryLayoutannotation, 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.getTypeFlags(Class<?> cls) Construct aTypeFlagsbitfield 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 booleanHAS_VALUE_TABLE(Type type) Checks iftypehas aTypeValueTable.static booleanIS_ABSTRACT(Type type) Checks iftypeis an abstract type.static booleanIS_CLASSED(Type type) Checks iftypeis a classed type.static booleanIS_DEEP_DERIVABLE(Type type) Checks iftypeis a deep derivable type.static booleanIS_DEPRECATED(Type type) Checks iftypeis deprecated.static booleanIS_DERIVABLE(Type type) Checks iftypeis a derivable type.static booleanIS_DERIVED(Type type) Checks iftypeis derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).static booleanChecks iftypeis a final type.static booleanIS_FUNDAMENTAL(Type type) Checks iftypeis a fundamental type.static booleanIS_INSTANTIATABLE(Type type) Checks iftypecan be instantiated.static booleanIS_INTERFACE(Type type) Checks iftypeis an interface type.static booleanIS_VALUE_ABSTRACT(Type type) Checks iftypeis an abstract value type.static booleanIS_VALUE_TYPE(Type type) Checks iftypeis a value type and can be used with g_value_init().static booleanisGObjectBased(Class<?> cls) Check if this class (or in case of an interface, any class that implements it) is a GObject.static TypeRegister a new GType for a Java class, interface or enum.static Typeregister(Type parentType, Class<?> javaClass, String typeName, MemoryLayout classLayout, Consumer<TypeClass> classInit, MemoryLayout instanceLayout, Consumer<TypeInstance> instanceInit, @Nullable Function<MemorySegment, ? extends Proxy> constructor, @Nullable Function<MemorySegment, ? extends Proxy> typeClassConstructor, Set<TypeFlags> flags) Register a new GType.
-
Field Details
-
INVALID
An invalidGTypeused 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
CHARis 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 allGParamSpectypes are derived. -
OBJECT
The fundamental type forGObject. -
VARIANT
The fundamental type corresponding toG_TYPE_VARIANT.All floating
G_TYPE_VARIANTinstances passed through theGTypesystem 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
TheGTypeforGDate. -
STRV
TheGTypefor a boxed type holding anull-terminated array of strings.- Since:
- 2.4
-
GSTRING
TheGTypeforGString. -
HASH_TABLE
TheGTypefor a boxed type holding aGHashTablereference.- Since:
- 2.10
-
REGEX
-
MATCH_INFO
TheGTypefor a boxed type holding aGMatchInforeference.- Since:
- 2.30
-
ARRAY
-
BYTE_ARRAY
TheGTypefor a boxed type holding aGByteArrayreference.- Since:
- 2.22
-
PTR_ARRAY
TheGTypefor a boxed type holding aGPtrArrayreference.- Since:
- 2.22
-
BYTES
-
VARIANT_TYPE
TheGTypefor a boxed type holding aGVariantType.- Since:
- 2.24
-
ERROR
-
DATE_TIME
-
TIME_ZONE
-
IO_CHANNEL
TheGTypeforGIOChannel. -
IO_CONDITION
TheGTypeforGIOCondition. -
VARIANT_BUILDER
TheGTypefor a boxed type holding aGVariantBuilder.- Since:
- 2.30
-
VARIANT_DICT
TheGTypefor a boxed type holding aGVariantDict.- Since:
- 2.40
-
MAIN_LOOP
-
MAIN_CONTEXT
TheGTypefor a boxed type holding aGMainContext.- Since:
- 2.30
-
SOURCE
-
POLLFD
-
MARKUP_PARSE_CONTEXT
TheGTypefor a boxed type holding aGMarkupParseContext.- Since:
- 2.36
-
KEY_FILE
-
MAPPED_FILE
-
THREAD
-
CHECKSUM
-
OPTION_GROUP
TheGTypefor a boxed type holding aGOptionGroup.- Since:
- 2.44
-
URI
-
TREE
-
PATTERN_SPEC
-
BOOKMARK_FILE
TheGTypefor 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 iftypeis 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- ATypevalue- Returns:
trueiftypeis an interface
-
IS_CLASSED
Checks iftypeis a classed type.A classed type has an associated
TypeClasswhich can be derived to store class-wide virtual function pointers and data for all instances of the type. This allows for subclassing. AllGObjects are classed; none of the scalar fundamental types built into GLib are classed.Interfaces are not classed: while their
TypeInterfacestruct could be considered similar toTypeClass, and classes can derive interfaces,TypeInterfacedoesn’t allow for subclassing.- Parameters:
type- ATypevalue- Returns:
trueiftypeis classed
-
IS_INSTANTIATABLE
-
IS_DERIVABLE
-
IS_DEEP_DERIVABLE
-
IS_ABSTRACT
-
IS_VALUE_ABSTRACT
Checks iftypeis 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- ATypevalue- Returns:
trueiftypeis an abstract value type
-
IS_VALUE_TYPE
-
HAS_VALUE_TABLE
Checks iftypehas aTypeValueTable.- Parameters:
type- ATypevalue- Returns:
trueiftypehas 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.structLayoutwith 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
-
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@MemoryLayoutannotation, 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
public static <T extends @Nullable Proxy> @Nullable Function<@Nullable MemorySegment,T> getAddressConstructor(Class<T> cls) 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 theProxyinterface- Parameters:
cls- the class that declares a constructor with a singleMemorySegmentparameter- 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 withInstanceInitand 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> @Nullable Consumer<TC> getClassInit(Class<T> cls) Return a lambda that invokes the class initializer, with is a method that is annotated withClassInitand takes a single parameter of typeTypeClass.- Type Parameters:
T- the class must extendTypeInstanceTC- the class initializer must accept aTypeClassparameter- 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> @Nullable Consumer<TI> getInterfaceInit(Class<T> cls, Class<?> iface) Return a lambda that invokes the interface initializer, with is a method that is annotated withInterfaceInitand takes a single parameter of the type that is specified withiface.- Type Parameters:
T- the class must extendTypeInstanceTI- 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 theRegisteredTypeannotation. 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
Flagsannotation on the enum.
RegisteredTypeannotation. (All invalid characters, including '.', are replaced with underscores.)Use
ClassInitandInstanceInitannotations on static methods in the Java class to indicate that these are to be called during GObject class- and instance initialization.The
TypeFlags.ABSTRACTandTypeFlags.FINALflags 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, @Nullable Function<MemorySegment, ? extends Proxy> constructor, @Nullable 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
Applyfunctoclsiffuncis notnull.- Type Parameters:
Z-funcmust accept the type ofclsas its parameter- Parameters:
func- a nullable Consumer operation that will be applied toclscls- the Class that will be passed tofunc
-