Class Types

java.lang.Object
org.javagi.gobject.types.Types

@NullMarked public class Types extends Object
The Types class contains GType constants, a series of static methods to check gtype characteristics, and static methods to register a Java class as a new GObject-derived GType.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Type
    The GType for a boxed type holding a GArray reference.
    static final Type
    The GType for a boxed type holding a GBookmarkFile.
    static final Type
    The fundamental type corresponding to gboolean.
    static final Type
    The fundamental type from which all boxed types are derived.
    static final Type
    The GType for a boxed type holding a GByteArray reference.
    static final Type
    The GType for GBytes.
    static final Type
    The fundamental type corresponding to gchar.
    static final Type
    The GType for a boxed type holding a GChecksum.
    static final Type
    The GType for GDate.
    static final Type
    The GType for a boxed type holding a GDateTime.
    static final Type
    The fundamental type corresponding to gdouble.
    static final Type
    The fundamental type from which all enumeration types are derived.
    static final Type
    The GType for a boxed type holding a GError.
    static final Type
    The fundamental type from which all flags types are derived.
    static final Type
    The fundamental type corresponding to gfloat.
    static final Type
    The GType for GString.
    static final Type
    The GType for a boxed type holding a GHashTable reference.
    static final Type
    The fundamental type corresponding to gint.
    static final Type
    The fundamental type corresponding to gint64.
    static final Type
    The fundamental type from which all interfaces are derived.
    static final Type
    An invalid GType used as error return value in some functions which return a GType.
    static final Type
    The GType for GIOChannel.
    static final Type
    The GType for GIOCondition.
    static final Type
    The GType for a boxed type holding a GKeyFile.
    static final Type
    The fundamental type corresponding to glong.
    static final Type
    The GType for a boxed type holding a GMainContext.
    static final Type
    The GType for a boxed type holding a GMainLoop.
    static final Type
    The GType for a boxed type holding a GMappedFile.
    static final Type
    The GType for a boxed type holding a GMarkupParseContext.
    static final Type
    The GType for a boxed type holding a GMatchInfo 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 for GObject.
    static final Type
    The GType for a boxed type holding a GOptionGroup.
    static final Type
    The fundamental type from which all GParamSpec types are derived.
    static final Type
    The GType for GPatternSpec.
    static final Type
    The fundamental type corresponding to gpointer.
    static final Type
    The GType for a boxed type holding a GPollFD.
    static final Type
    The GType for a boxed type holding a GPtrArray reference.
    static final Type
    The GType for a boxed type holding a GRegex 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
    The GType for a boxed type holding a GSource.
    static final Type
    The fundamental type corresponding to nul-terminated C strings.
    static final Type
    The GType for a boxed type holding a null-terminated array of strings.
    static final Type
    The GType for a boxed type holding a GThread.
    static final Type
    The GType for a boxed type holding a GTimeZone.
    static final Type
    The GType for GTree.
    static final Type
    The fundamental type corresponding to guchar.
    static final Type
    The fundamental type corresponding to guint.
    static final Type
    The fundamental type corresponding to guint64.
    static final Type
    The fundamental type corresponding to gulong.
    static final Type
    The GType for a boxed type holding a GUri.
    static final Type
    The fundamental type corresponding to G_TYPE_VARIANT.
    static final Type
    The GType for a boxed type holding a GVariantBuilder.
    static final Type
    The GType for a boxed type holding a GVariantDict.
    static final Type
    The GType for a boxed type holding a GVariantType.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <Z> void
    applyIfNotNull(@Nullable Consumer<? super Z> func, Z cls)
    Apply func to cls if func is not null.
    cacheLayout(Class<?> cls, MemoryLayout layout)
    Cache a generated MemoryLayout.
    Generate a MemoryLayout struct with one member: the memory layout of the parent TypeClass
    Generate a MemoryLayout struct with one member: the memory layout of GTypeInterface
    static <T extends @Nullable Proxy>
    @Nullable Function<@Nullable MemorySegment, T>
    Return the memory address constructor for the provided class.
    static <T extends TypeInstance, TC extends TypeClass>
    @Nullable Consumer<TC>
    Return a lambda that invokes the class initializer, with is a method that is annotated with ClassInit and takes a single parameter of type TypeClass.
    static <T extends TypeInstance>
    Consumer<T>
    Return a lambda that invokes the instance initializer, with is a method that is annotated with InstanceInit and takes a single parameter of type TypeInstance.
    Return the memory layout defined in the provided class, or if not found, a new MemoryLayout.structLayout with 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 with InterfaceInit and takes a single parameter of the type that is specified with iface.
    static @Nullable MemoryLayout
    getLayout(Class<?> cls)
    Return the MemoryLayout that is returned by a method with @MemoryLayout annotation, or if that annotation is not found, by invoking cls.getMemoryLayout() if such method exists, or else, return null.
    static <TC extends TypeClass>
    Class<TC>
    Return the inner TypeClass class, or the inner TypeClass from the superclass.
    static Set<TypeFlags>
    Construct a TypeFlags bitfield that specifies whether the provided class is abstract and/or final.
    static <TI extends TypeInterface>
    Class<TI>
    Return the inner TypeInterface class, or TypeInterface.class if not found.
    static boolean
    Checks if type has a TypeValueTable.
    static boolean
    Checks if type is an abstract type.
    static boolean
    Checks if type is a classed type.
    static boolean
    Checks if type is a deep derivable type.
    static boolean
    Checks if type is deprecated.
    static boolean
    Checks if type is a derivable type.
    static boolean
    Checks if type is derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).
    static boolean
    IS_FINAL(Type type)
    Checks if type is a final type.
    static boolean
    Checks if type is a fundamental type.
    static boolean
    Checks if type can be instantiated.
    static boolean
    Checks if type is an interface type.
    static boolean
    Checks if type is an abstract value type.
    static boolean
    Checks if type is a value type and can be used with g_value_init().
    static boolean
    Check if this class (or in case of an interface, any class that implements it) is a GObject.
    static Type
    register(Class<?> cls)
    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, @Nullable Function<MemorySegment, ? extends Proxy> constructor, @Nullable Function<MemorySegment, ? extends Proxy> typeClassConstructor, Set<TypeFlags> flags)
    Register a new GType.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INVALID

      public static final Type INVALID
      An invalid GType used as error return value in some functions which return a GType.
    • NONE

      public static final Type NONE
      A fundamental type which is used as a replacement for the C void return type.
    • INTERFACE

      public static final Type INTERFACE
      The fundamental type from which all interfaces are derived.
    • CHAR

      public static final Type CHAR
      The fundamental type corresponding to gchar.

      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

      public static final Type UCHAR
      The fundamental type corresponding to guchar.
    • BOOLEAN

      public static final Type BOOLEAN
      The fundamental type corresponding to gboolean.
    • INT

      public static final Type INT
      The fundamental type corresponding to gint.
    • UINT

      public static final Type UINT
      The fundamental type corresponding to guint.
    • LONG

      public static final Type LONG
      The fundamental type corresponding to glong.
    • ULONG

      public static final Type ULONG
      The fundamental type corresponding to gulong.
    • INT64

      public static final Type INT64
      The fundamental type corresponding to gint64.
    • UINT64

      public static final Type UINT64
      The fundamental type corresponding to guint64.
    • ENUM

      public static final Type ENUM
      The fundamental type from which all enumeration types are derived.
    • FLAGS

      public static final Type FLAGS
      The fundamental type from which all flags types are derived.
    • FLOAT

      public static final Type FLOAT
      The fundamental type corresponding to gfloat.
    • DOUBLE

      public static final Type DOUBLE
      The fundamental type corresponding to gdouble.
    • STRING

      public static final Type STRING
      The fundamental type corresponding to nul-terminated C strings.
    • POINTER

      public static final Type POINTER
      The fundamental type corresponding to gpointer.
    • BOXED

      public static final Type BOXED
      The fundamental type from which all boxed types are derived.
    • PARAM

      public static final Type PARAM
      The fundamental type from which all GParamSpec types are derived.
    • OBJECT

      public static final Type OBJECT
      The fundamental type for GObject.
    • VARIANT

      public static final Type VARIANT
      The fundamental type corresponding to G_TYPE_VARIANT.

      All floating G_TYPE_VARIANT instances passed through the GType 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

      public static final Type DATE
      The GType for GDate.
    • STRV

      public static final Type STRV
      The GType for a boxed type holding a null-terminated array of strings.
      Since:
      2.4
    • GSTRING

      public static final Type GSTRING
      The GType for GString.
    • HASH_TABLE

      public static final Type HASH_TABLE
      The GType for a boxed type holding a GHashTable reference.
      Since:
      2.10
    • REGEX

      public static final Type REGEX
      The GType for a boxed type holding a GRegex reference.
      Since:
      2.14
    • MATCH_INFO

      public static final Type MATCH_INFO
      The GType for a boxed type holding a GMatchInfo reference.
      Since:
      2.30
    • ARRAY

      public static final Type ARRAY
      The GType for a boxed type holding a GArray reference.
      Since:
      2.22
    • BYTE_ARRAY

      public static final Type BYTE_ARRAY
      The GType for a boxed type holding a GByteArray reference.
      Since:
      2.22
    • PTR_ARRAY

      public static final Type PTR_ARRAY
      The GType for a boxed type holding a GPtrArray reference.
      Since:
      2.22
    • BYTES

      public static final Type BYTES
      The GType for GBytes.
      Since:
      2.32
    • VARIANT_TYPE

      public static final Type VARIANT_TYPE
      The GType for a boxed type holding a GVariantType.
      Since:
      2.24
    • ERROR

      public static final Type ERROR
      The GType for a boxed type holding a GError.
      Since:
      2.26
    • DATE_TIME

      public static final Type DATE_TIME
      The GType for a boxed type holding a GDateTime.
      Since:
      2.26
    • TIME_ZONE

      public static final Type TIME_ZONE
      The GType for a boxed type holding a GTimeZone.
      Since:
      2.34
    • IO_CHANNEL

      public static final Type IO_CHANNEL
      The GType for GIOChannel.
    • IO_CONDITION

      public static final Type IO_CONDITION
      The GType for GIOCondition.
    • VARIANT_BUILDER

      public static final Type VARIANT_BUILDER
      The GType for a boxed type holding a GVariantBuilder.
      Since:
      2.30
    • VARIANT_DICT

      public static final Type VARIANT_DICT
      The GType for a boxed type holding a GVariantDict.
      Since:
      2.40
    • MAIN_LOOP

      public static final Type MAIN_LOOP
      The GType for a boxed type holding a GMainLoop.
      Since:
      2.30
    • MAIN_CONTEXT

      public static final Type MAIN_CONTEXT
      The GType for a boxed type holding a GMainContext.
      Since:
      2.30
    • SOURCE

      public static final Type SOURCE
      The GType for a boxed type holding a GSource.
      Since:
      2.30
    • POLLFD

      public static final Type POLLFD
      The GType for a boxed type holding a GPollFD.
      Since:
      2.36
    • MARKUP_PARSE_CONTEXT

      public static final Type MARKUP_PARSE_CONTEXT
      The GType for a boxed type holding a GMarkupParseContext.
      Since:
      2.36
    • KEY_FILE

      public static final Type KEY_FILE
      The GType for a boxed type holding a GKeyFile.
      Since:
      2.32
    • MAPPED_FILE

      public static final Type MAPPED_FILE
      The GType for a boxed type holding a GMappedFile.
      Since:
      2.40
    • THREAD

      public static final Type THREAD
      The GType for a boxed type holding a GThread.
      Since:
      2.36
    • CHECKSUM

      public static final Type CHECKSUM
      The GType for a boxed type holding a GChecksum.
      Since:
      2.36
    • OPTION_GROUP

      public static final Type OPTION_GROUP
      The GType for a boxed type holding a GOptionGroup.
      Since:
      2.44
    • URI

      public static final Type URI
      The GType for a boxed type holding a GUri.
      Since:
      2.66
    • TREE

      public static final Type TREE
      The GType for GTree.
      Since:
      2.68
    • PATTERN_SPEC

      public static final Type PATTERN_SPEC
      The GType for GPatternSpec.
      Since:
      2.70
    • BOOKMARK_FILE

      public static final Type BOOKMARK_FILE
      The GType for a boxed type holding a GBookmarkFile.
      Since:
      2.76
    • RESERVED_GLIB_FIRST

      public static final long RESERVED_GLIB_FIRST
      First 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_LAST
      Last fundamental type number reserved for GLib.
      See Also:
    • RESERVED_BSE_FIRST

      public static final long RESERVED_BSE_FIRST
      First 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_LAST
      Last fundamental type number reserved for BSE.
      See Also:
    • RESERVED_USER_FIRST

      public static final long RESERVED_USER_FIRST
      First 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

      public static boolean IS_FUNDAMENTAL(Type type)
      Checks if type is a fundamental type.
      Parameters:
      type - A Type value
      Returns:
      true if type is fundamental
    • IS_DERIVED

      public static boolean IS_DERIVED(Type type)
      Checks if type is derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).
      Parameters:
      type - A Type value
      Returns:
      true if type is derived
    • IS_INTERFACE

      public static boolean IS_INTERFACE(Type type)
      Checks if type 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 - A Type value
      Returns:
      true if type is an interface
    • IS_CLASSED

      public static boolean IS_CLASSED(Type type)
      Checks if type 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. All GObjects 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 to TypeClass, and classes can derive interfaces, TypeInterface doesn’t allow for subclassing.

      Parameters:
      type - A Type value
      Returns:
      true if type is classed
    • IS_INSTANTIATABLE

      public static boolean IS_INSTANTIATABLE(Type type)
      Checks if type can be instantiated. Instantiation is the process of creating an instance (object) of this type.
      Parameters:
      type - A Type value
      Returns:
      true if type is instantiable
    • IS_DERIVABLE

      public static boolean IS_DERIVABLE(Type type)
      Checks if type is a derivable type. A derivable type can be used as the base class of a flat (single-level) class hierarchy.
      Parameters:
      type - A Type value
      Returns:
      true if type is derivable
    • IS_DEEP_DERIVABLE

      public static boolean IS_DEEP_DERIVABLE(Type type)
      Checks if type is a deep derivable type. A deep derivable type can be used as the base class of a deep (multi-level) class hierarchy.
      Parameters:
      type - A Type value
      Returns:
      true if type is deep derivable
    • IS_ABSTRACT

      public static boolean IS_ABSTRACT(Type type)
      Checks if type is an abstract type. An abstract type cannot be instantiated and is normally used as an abstract base class for derived classes.
      Parameters:
      type - A Type value
      Returns:
      true if type is abstract
    • IS_VALUE_ABSTRACT

      public static boolean IS_VALUE_ABSTRACT(Type type)
      Checks if type 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 - A Type value
      Returns:
      true if type is an abstract value type
    • IS_VALUE_TYPE

      public static boolean IS_VALUE_TYPE(Type type)
      Checks if type is a value type and can be used with g_value_init().
      Parameters:
      type - A Type value
      Returns:
      true if type is a value type
    • HAS_VALUE_TABLE

      public static boolean HAS_VALUE_TABLE(Type type)
      Checks if type has a TypeValueTable.
      Parameters:
      type - A Type value
      Returns:
      true if type has a value table
    • IS_FINAL

      public static boolean IS_FINAL(Type type)
      Checks if type is a final type. A final type cannot be derived any further.
      Parameters:
      type - A Type value
      Returns:
      true if type is final
      Since:
      2.70
    • IS_DEPRECATED

      public static boolean IS_DEPRECATED(Type type)
      Checks if type is deprecated. Instantiating a deprecated type will trigger a warning if running with G_ENABLE_DIAGNOSTIC=1.
      Parameters:
      type - A Type value
      Returns:
      true if the type is deprecated
      Since:
      2.76
    • getInstanceLayout

      public static MemoryLayout getInstanceLayout(Class<?> cls)
      Return the memory layout defined in the provided class, or if not found, a new MemoryLayout.structLayout with one field that points to the memory layout defined in the direct superclass.
      Parameters:
      cls - the class to provide a memory layout for
      Returns:
      the declared memory layout, or if not found, a generated memory layout that copies the memory layout declared in the direct superclass.
    • getTypeClass

      public static <TC extends TypeClass> Class<TC> getTypeClass(Class<?> cls)
      Return the inner TypeClass class, or the inner TypeClass from the superclass.
      Parameters:
      cls - the class that contains (or whose superclass contains) an inner TypeClass class
      Returns:
      the TypeClass class
      Throws:
      IllegalArgumentException - when no typeclass is found
    • getTypeInterface

      public static <TI extends TypeInterface> Class<TI> getTypeInterface(Class<?> iface)
      Return the inner TypeInterface class, or TypeInterface.class if not found.
      Type Parameters:
      TI - the returned class extends TypeInterface
      Parameters:
      iface - the interface that contains an inner TypeInterface class
      Returns:
      the TypeInterface class, or TypeInterface.class if not found
    • generateClassLayout

      public static MemoryLayout generateClassLayout(Class<?> cls)
      Generate a MemoryLayout struct with one member: the memory layout of the parent TypeClass
      Parameters:
      cls - the class to generate a memory layout for
      Returns:
      the requested memory layout
    • generateIfaceLayout

      public static MemoryLayout generateIfaceLayout(Class<?> cls)
      Generate a MemoryLayout struct with one member: the memory layout of GTypeInterface
      Parameters:
      cls - the interface to generate a memory layout for
      Returns:
      the requested memory layout
    • cacheLayout

      public static MemoryLayout cacheLayout(Class<?> cls, MemoryLayout layout)
      Cache a generated MemoryLayout.
      Parameters:
      cls - the class for which the layout was generated
      layout - the generated memory layout
      Returns:
      always returns layout
    • getLayout

      public static @Nullable MemoryLayout getLayout(Class<?> cls)
      Return the MemoryLayout that is returned by a method with @MemoryLayout annotation, or if that annotation is not found, by invoking cls.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 the Proxy interface
      Parameters:
      cls - the class that declares a constructor with a single MemorySegment parameter
      Returns:
      the memory address constructor for this class, or null if not found
    • getInstanceInit

      public 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 with InstanceInit and takes a single parameter of type TypeInstance.
      Type Parameters:
      T - the class must extend TypeInstance
      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 with ClassInit and takes a single parameter of type TypeClass.
      Type Parameters:
      T - the class must extend TypeInstance
      TC - the class initializer must accept a TypeClass 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> @Nullable Consumer<TI> getInterfaceInit(Class<T> cls, Class<?> iface)
      Return a lambda that invokes the interface initializer, with is a method that is annotated with InterfaceInit and takes a single parameter of the type that is specified with iface.
      Type Parameters:
      T - the class must extend TypeInstance
      TI - the iface parameter must extend TypeInterface
      Parameters:
      cls - the class that declares the interface init method
      Returns:
      the interface initializer, or null if not found
    • getTypeFlags

      public static Set<TypeFlags> getTypeFlags(Class<?> cls)
      Construct a TypeFlags bitfield that specifies whether the provided class is abstract and/or final.
      Parameters:
      cls - the class for which to generate typeflags
      Returns:
      the generated typeflags
    • isGObjectBased

      public static boolean isGObjectBased(Class<?> cls)
      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

      public static Type register(Class<?> cls)
      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 the RegisteredType 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.
      The name of the new GType will be the simple name of the Java class, but can also be specified with the RegisteredType annotation. (All invalid characters, including '.', are replaced with underscores.)

      Use ClassInit and InstanceInit 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 and TypeFlags.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, @Nullable Function<MemorySegment, ? extends Proxy> constructor, @Nullable Function<MemorySegment, ? extends Proxy> typeClassConstructor, Set<TypeFlags> flags)
      Register a new GType.
      Parameters:
      parentType - parent GType
      typeName - name of the GType
      classLayout - memory layout of the typeclass
      classInit - static class initializer function
      instanceLayout - memory layout of the typeinstance
      instanceInit - static instance initializer function
      flags - type flags
      Returns:
      the GType of the registered Java type
    • applyIfNotNull

      public static <Z> void applyIfNotNull(@Nullable Consumer<? super Z> func, Z cls)
      Apply func to cls if func is not null.
      Type Parameters:
      Z - func must accept the type of cls as its parameter
      Parameters:
      func - a nullable Consumer operation that will be applied to cls
      cls - the Class that will be passed to func