Skip to content

Commit

Permalink
Merge pull request #195 from DecwLK/generic_visitor
Browse files Browse the repository at this point in the history
make PositionableViewModelElementVisitor generic
  • Loading branch information
crissNb authored Mar 10, 2024
2 parents da97ae5 + 2e24d7a commit 9bed177
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@Getter
@Setter
public class CopyPositionableViewModelElementVisitor implements PositionableViewModelElementVisitor {
public class CopyPositionableViewModelElementVisitor implements PositionableViewModelElementVisitor<Void> {
@Getter(AccessLevel.NONE)
private GeckoViewModel geckoViewModel;
private boolean isAutomatonCopy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* necessary delete-{@link Action}s for deleting all "lower level"-dependencies of a given parent-@link
* SystemViewModel}.
*/
public class DeleteActionsCreatorVisitor implements PositionableViewModelElementVisitor {
public class DeleteActionsCreatorVisitor
implements PositionableViewModelElementVisitor<Set<AbstractPositionableViewModelElementAction>> {

private final GeckoViewModel geckoViewModel;
private final SystemViewModel parentSystemViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* type of {@link org.gecko.viewmodel.PositionableViewModelElement PositionableViewModelElement} in order to create
* inspectors for concrete {@link org.gecko.viewmodel.PositionableViewModelElement PositionableViewModelElement}s.
*/
public class InspectorFactoryVisitor implements PositionableViewModelElementVisitor {
public class InspectorFactoryVisitor implements PositionableViewModelElementVisitor<Void> {

private final InspectorFactory inspectorFactory;
@Getter
Expand All @@ -26,36 +26,36 @@ public class InspectorFactoryVisitor implements PositionableViewModelElementVisi
}

@Override
public Object visit(SystemViewModel systemViewModel) {
public Void visit(SystemViewModel systemViewModel) {
inspector = inspectorFactory.createSystemInspector(systemViewModel);
return null;
}

@Override
public Object visit(RegionViewModel regionViewModel) {
public Void visit(RegionViewModel regionViewModel) {
inspector = inspectorFactory.createRegionInspector(regionViewModel);
return null;
}

@Override
public Object visit(SystemConnectionViewModel systemConnectionViewModel) {
public Void visit(SystemConnectionViewModel systemConnectionViewModel) {
return null;
}

@Override
public Object visit(EdgeViewModel edgeViewModel) {
public Void visit(EdgeViewModel edgeViewModel) {
inspector = inspectorFactory.createEdgeInspector(edgeViewModel);
return null;
}

@Override
public Object visit(StateViewModel stateViewModel) {
public Void visit(StateViewModel stateViewModel) {
inspector = inspectorFactory.createStateInspector(stateViewModel);
return null;
}

@Override
public Object visit(PortViewModel portViewModel) {
public Void visit(PortViewModel portViewModel) {
inspector = inspectorFactory.createVariableBlockInspector(portViewModel);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* type of {@link ViewElement} through the {@link ViewFactory} by visiting a type of
* {@link org.gecko.viewmodel.PositionableViewModelElement PositionableViewModelElement}.
*/
public class ViewElementCreatorVisitor implements PositionableViewModelElementVisitor {
public class ViewElementCreatorVisitor implements PositionableViewModelElementVisitor<ViewElement<?>> {

private final ViewFactory viewFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.gecko.view.views;

import java.util.Locale;
import org.gecko.viewmodel.AbstractViewModelElement;
import org.gecko.viewmodel.ContractViewModel;
import org.gecko.viewmodel.EdgeViewModel;
import org.gecko.viewmodel.PortViewModel;
Expand All @@ -15,7 +16,7 @@
* absolute or partial matches between a given {@link String} and the names of
* {@link org.gecko.viewmodel.PositionableViewModelElement PositionableViewModelElement}s, if present.
*/
public class ViewElementSearchVisitor implements PositionableViewModelElementVisitor {
public class ViewElementSearchVisitor implements PositionableViewModelElementVisitor<AbstractViewModelElement<?>> {
private final String search;

public ViewElementSearchVisitor(String search) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* Represents a visitor pattern for performing operations on {@link PositionableViewModelElement}s. Concrete visitors
* must implement this interface to define specific behavior for each {@link PositionableViewModelElement}.
*/
public interface PositionableViewModelElementVisitor {
Object visit(SystemViewModel systemViewModel);
public interface PositionableViewModelElementVisitor<T> {
T visit(SystemViewModel systemViewModel);

Object visit(RegionViewModel regionViewModel);
T visit(RegionViewModel regionViewModel);

Object visit(SystemConnectionViewModel systemConnectionViewModel);
T visit(SystemConnectionViewModel systemConnectionViewModel);

Object visit(EdgeViewModel edgeViewModel);
T visit(EdgeViewModel edgeViewModel);

Object visit(StateViewModel stateViewModel);
T visit(StateViewModel stateViewModel);

Object visit(PortViewModel portViewModel);
T visit(PortViewModel portViewModel);
}

0 comments on commit 9bed177

Please sign in to comment.