private long countEdges(List<Edge> inEdges) { return inEdges.stream() .filter(e -> e.getContent() instanceof ViewConnector) .count(); } }
private static Function<List<Edge>, Edge> getViewConnector() { return edges -> edges .stream() .filter(e -> e.getContent() instanceof ViewConnector) .findAny() .get(); }
private static List<Edge<? extends ViewConnector<?>, Node>> getConnections(List<? extends Edge> edges) { return edges.stream() .filter(edge -> (edge.getContent() instanceof ViewConnector)) .map(edge -> (Edge<? extends ViewConnector<?>, Node>) edge) .collect(Collectors.toList()); }
@SuppressWarnings("unchecked") public static Element<?> getParent(final Node<?, ? extends Edge> element) { return Optional.ofNullable(element) .map(Node::getInEdges) .orElse(Collections.emptyList()) .stream() .filter(e -> e.getContent() instanceof Child) .findAny() .map(Edge::getSourceNode) .orElse(null); }
@Override public void endEdgeTraversal(final Edge edge) { super.endEdgeTraversal(edge); if (edge.getContent() instanceof Child) { this.currentParents.pop(); } }
private static boolean isRelationshipConnector(Edge e) { return e.getContent() instanceof Parent || e.getContent() instanceof Child || e.getContent() instanceof Dock; } }
private static boolean isRelationshipConnector(Edge e) { return e.getContent() instanceof Parent || e.getContent() instanceof Child || e.getContent() instanceof Dock; } }
public static Optional<Node> getDockParent(final Node<?, ? extends Edge> element) { return Objects.nonNull(element.getInEdges()) ? element.getInEdges() .stream() .filter(edge -> edge.getContent() instanceof Dock) .map(Edge::getSourceNode) .findFirst() : Optional.empty(); }
@Inject public ChildrenTraverseProcessorImpl(final TreeWalkTraverseProcessor treeWalkTraverseProcessor) { super(treeWalkTraverseProcessor); treeWalkTraverseProcessor.useStartNodePredicate(node -> !node.getInEdges().stream() .filter(e -> e.getContent() instanceof Child) .findAny() .isPresent()); }
@Override public void endEdgeTraversal(final Edge edge) { if (edge.getContent() instanceof View) { callback.endViewEdgeTraversal(edge); } else if (edge.getContent() instanceof Child) { callback.endChildEdgeTraversal(edge); } else if (edge.getContent() instanceof Parent) { callback.endParentEdgeTraversal(edge); } else { callback.endEdgeTraversal(edge); } }
@SuppressWarnings("unchecked") public static boolean hasChildren(final Node<?, ? extends Edge> element) { return Objects.nonNull(element.getOutEdges()) ? element.getOutEdges().stream() .anyMatch(edge -> (edge.getContent() instanceof Child)) : false; }
public static boolean isDockedNode(final Node<?, ? extends Edge> element) { return Objects.nonNull(element.getInEdges()) ? element.getInEdges() .stream() .anyMatch(edge -> edge.getContent() instanceof Dock) : false; }
public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) { if (edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof SequenceFlow) { return converterFactory.sequenceFlowConverter().toFlowElement(edge, process); } else if (edge.getContent() instanceof ViewConnector && ((ViewConnector) edge.getContent()).getDefinition() instanceof Association) { return converterFactory.associationFlowConverter().toFlowElement(edge, process); } return Result.failure("Converter is not implemented for edge content type: " + edge.getContent()); } }
private static Optional<ControlPoint> getControlPointyByIndex(final Edge edge, final int index) { ViewConnector viewConnector = (ViewConnector) edge.getContent(); return viewConnector.getControlPoints().stream() .filter(cp -> Objects.nonNull(cp.getIndex())) .filter(cp -> cp.getIndex() == index - 1) .findFirst(); }
@SuppressWarnings("unchecked") private static Node getParent(final Node node) { List<Edge> inEdges = node.getInEdges(); if (null != inEdges && !inEdges.isEmpty()) { for (final Edge edge : inEdges) { if (edge.getContent() instanceof Child) { return edge.getSourceNode(); } } } return null; }
private ViewConnector getInEdgeViewConnector(Node node) { List<Edge> edges = node.getInEdges(); if (edges != null) { for (Edge edge : edges) { if (edge.getContent() instanceof ViewConnector) { return (ViewConnector) edge.getContent(); } } } return null; }
private ViewConnector getInEdgeViewConnector(Node node) { List<Edge> edges = node.getInEdges(); if (edges != null) { for (Edge edge : edges) { if (edge.getContent() instanceof ViewConnector) { return (ViewConnector) edge.getContent(); } } } return null; }
private ViewConnector getOutEdgeViewConnector(Node node) { List<Edge> edges = node.getOutEdges(); if (edges != null) { for (Edge edge : edges) { if (edge.getContent() instanceof ViewConnector) { return (ViewConnector) edge.getContent(); } } } return null; }
@SuppressWarnings("unchecked") private void createEdge(String uuid, Node sourceNode, Node targetNode) { final Edge<View<SequenceFlow>, Node> edge = typedFactoryManager.newEdge(uuid, SequenceFlow.class); edge.setSourceNode(sourceNode); edge.setTargetNode(targetNode); sourceNode.getOutEdges().add(edge); targetNode.getInEdges().add(edge); ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent(); content.setSourceConnection(MagnetConnection.Builder.forElement(sourceNode)); content.setTargetConnection(MagnetConnection.Builder.forElement(targetNode)); }
@Test @SuppressWarnings("unchecked") public void testAccepts() { when(ruleExtension.getTypeArguments()).thenReturn(new Class[]{ParentDefinition.class}); when(containmentContext.getCandidate()).thenReturn(nodeA); when(containmentContext.getParent()).thenReturn(parentNode); nodeA.getInEdges().add(edge); when(edge.getContent()).thenReturn(viewConnector); assertTrue(tested.accepts(ruleExtension, containmentContext)); }