Add GVariant pack and unpack methods #264
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi!264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "variant-pack-unpack"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds three new methods to the
org.gnome.glib.Variantclass:public static Variant pack(Object object)to create a Variant from a Java Objectpublic Object unpack()to unpack a Variant to a Java Objectpublic Object unpackRecursive()to unpack a Variant to a Java Object, recursively unpacking nested Variants too.In most cases, packing and unpacking an object will result in an object that equals the original, but this is not always the case, because during the pack/unpack operations, some information gets lost. For example:
ListandSetare packed into an array-type VariantOptional<?>is packed into a maybe-type Variant, but a maybe-type Variant is unpacked into the Java value or null.