Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#233 Add operation arguments to CreateNodeOperationHandler #108

Merged
merged 3 commits into from
May 10, 2021

Conversation

tortmayr
Copy link
Contributor

@tortmayr tortmayr commented May 6, 2021

@tortmayr tortmayr force-pushed the tortmayr/issues/233 branch from b3f46f3 to 12e289f Compare May 6, 2021 10:03
@@ -40,13 +41,13 @@ public void executeOperation(final CreateNodeOperation operation, final GModelSt
container = Optional.of(modelState.getRoot());
}

GModelElement element = createNode(getLocation(operation), modelState);
GModelElement element = createNode(getLocation(operation), operation.getArgs(), modelState);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see the map may be null here. I am not too much of a fan of null collection parameters, especially when point is wrapped in a nice Optional. But it could be that this is consistent with other operation handlers as well, just wanted to mention that in case it is different anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I updated the CreateNodeOperation so that the args map is initalized with an empty map. This way we can avoid the overhead of wrapping the Map into an Optional and the map should always be defined. Unless somebody explicitly uses the setter to set the map to null, which should hopefully never be the case 😉)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having an empty map before having an optional map much more! However, it seems that CreateEdgeOperation and CreateNodeOperation both initialize the args with null due to re-using the full constructor. So either we do a putAll in the CreateNodeOperation constructor for non-null maps OR the subclasses also need to use an empty map as their default constructor argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I checked other occurrences where we use an arbitrary args Map (e.g. EditorContext, RequestModelAction etc.) and we always more or less operate on the assumption that this map is not null. So I updated the constructors of all classes that use an args Map to ensure that they are initialized with an empty map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thank you!

@tortmayr tortmayr force-pushed the tortmayr/issues/233 branch from 12e289f to eea52b4 Compare May 6, 2021 10:36
@tortmayr tortmayr requested a review from martin-fleck-at May 10, 2021 13:53
…p/example/workflow/handler/CreateActivityNodeHandler.java
@martin-fleck-at martin-fleck-at merged commit ffdada5 into master May 10, 2021
@martin-fleck-at martin-fleck-at deleted the tortmayr/issues/233 branch May 10, 2021 21:28
MatthiasHofstaetter pushed a commit to MatthiasHofstaetter/glsp-server that referenced this pull request Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CreateNodeOperationHandler should also provide args
2 participants