Skip to content

Commit

Permalink
structurizr-core: Fixes problem with ordering of relationship view ve…
Browse files Browse the repository at this point in the history
…rtices.
  • Loading branch information
simonbrowndotje committed Mar 3, 2024
1 parent f9be616 commit b3fd678
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subprojects { proj ->

description = 'Structurizr'
group = 'com.structurizr'
version = '2.1.0'
version = '2.1.1'

repositories {
mavenCentral()
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.1 (3rd March 2024)

- structurizr-core: Fixes problem with ordering of relationship view vertices.

## 2.1.0 (2nd March 2024)

- structurizr-core: `ViewSet.isEmpty()` was missing a check for image views.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import com.structurizr.util.StringUtils;
import com.structurizr.util.Url;

import java.util.Collection;
import java.util.LinkedList;
import java.util.Set;
import java.util.TreeSet;
import java.util.*;

/**
* This class represents an instance of a Relationship on a View.
Expand All @@ -25,7 +22,7 @@ public final class RelationshipView implements Comparable<RelationshipView> {
private String url;
private String order;
private Boolean response;
private Set<Vertex> vertices = new TreeSet<>();
private List<Vertex> vertices = new ArrayList<>();

@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Routing routing;
Expand Down Expand Up @@ -158,7 +155,7 @@ void setResponse(Boolean response) {
* @return a collection of Vertex objects
*/
public Collection<Vertex> getVertices() {
return new LinkedList<>(vertices);
return new ArrayList<>(vertices);
}

/**
Expand All @@ -168,7 +165,7 @@ public Collection<Vertex> getVertices() {
*/
public void setVertices(Collection<Vertex> vertices) {
if (vertices != null) {
this.vertices = new TreeSet<>(vertices);
this.vertices = new ArrayList<>(vertices);
}
}

Expand Down
12 changes: 1 addition & 11 deletions structurizr-core/src/main/java/com/structurizr/view/Vertex.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* The X, Y coordinate of a bend in a line.
*/
public final class Vertex implements Comparable<Vertex> {
public final class Vertex {

private int x;
private int y;
Expand Down Expand Up @@ -63,14 +63,4 @@ public int hashCode() {
return Objects.hash(x, y);
}

@Override
public int compareTo(Vertex vertex) {
int result = getX() - vertex.getX();
if (result == 0) {
result = getY() - vertex.getY();
}

return result;
}

}

0 comments on commit b3fd678

Please sign in to comment.