class PropertyWriterUtils {

    public static BPMNEdge createBPMNEdge(BasePropertyWriter source,
                                          BasePropertyWriter target,
                                          Connection sourceConnection,
                                          ControlPoint[] mid,
                                          Connection targetConnection) {
        BPMNEdge bpmnEdge = di.createBPMNEdge();
        bpmnEdge.setId(Ids.bpmnEdge(source.getShape().getId(),
                                    target.getShape().getId()));

        Point2D sourcePt = getSourceLocation(source,
                                             sourceConnection);
        Point2D targetPt = getTargetLocation(target,
                                             targetConnection);

        Point sourcePoint = pointOf(
                source.getShape().getBounds().getX() + sourcePt.getX(),
                source.getShape().getBounds().getY() + sourcePt.getY());

        Point targetPoint = pointOf(
                target.getShape().getBounds().getX() + targetPt.getX(),
                target.getShape().getBounds().getY() + targetPt.getY());

        List<Point> waypoints = bpmnEdge.getWaypoint();
        waypoints.add(sourcePoint);

        if (null != mid) {
            for (ControlPoint controlPoint : mid) {
                waypoints.add(pointOf(controlPoint.getLocation().getX(),
                                      controlPoint.getLocation().getY()));
            }
        }

        waypoints.add(targetPoint);

        return bpmnEdge;
    }

}