Class ValueUtil

java.lang.Object
org.javagi.gobject.ValueUtil

@NullMarked public class ValueUtil extends Object
Utility functions to convert a Value to and from a Java Object.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable Value
    copy(@Nullable Value src)
    Allocate and initialize a new GValue, and copy src into it.
    static boolean
    objectToValue(@Nullable Object src, @Nullable Value dest)
    Read the GType of the dest GValue and set the src object (or boxed primitive value) as its value using the corresponding setter in the Value proxy class.
    static @Nullable Object
    valueToObject(@Nullable Value src)
    Read the GType from the GValue, call the corresponding getter (using the methods defined in the Value proxy class), and return the result.

    Methods inherited from class Object

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

    • ValueUtil

      public ValueUtil()
  • Method Details

    • valueToObject

      public static @Nullable Object valueToObject(@Nullable Value src)
      Read the GType from the GValue, call the corresponding getter (using the methods defined in the Value proxy class), and return the result.
      Parameters:
      src - a GValue instance.
      Returns:
      a Java object (or boxed primitive value) that has been marshaled from the GValue, or null if src is null.
    • objectToValue

      public static boolean objectToValue(@Nullable Object src, @Nullable Value dest)
      Read the GType of the dest GValue and set the src object (or boxed primitive value) as its value using the corresponding setter in the Value proxy class.
      Parameters:
      src - the Java Object (or boxed primitive value) to put in the GValue. Should not be null
      dest - the GValue to write to. Should not be null
      Returns:
      true if the value was set, and false otherwise.
    • copy

      public static @Nullable Value copy(@Nullable Value src)
      Allocate and initialize a new GValue, and copy src into it.
      Parameters:
      src - the GValue to copy
      Returns:
      the newly created GValue, or null if src is null