Skip to content

Get value of MapElement #45

Closed
Closed
@liranyogev

Description

@liranyogev

Not really sure if this is the right place for a question, but I saw you answer here, so I'll give it a try.
First off, amazing library!!

I am trying to figure something and I can't find any example in your code on how to do it.

I created a custom visitor.
Using the accept function I am able to traverse all changes.

I am trying to get the actual element behind a node (element is in a collection).
Once I reach such an element I wrote the following code that works:

Map:
Integer key = (Integer) ((MapElement) node.getPathElement()).getKey();

List/Set:
SomeObject object = (SomeObject) ((CollectionElement) node.getPathElement()).getItem();

These seem to work, but I wonder...

  1. Is there an easier way to perform this task?
  2. How can I get the value in a mapElement?

Thanks for this great library!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions