diff --git a/api/server/src/main/java/org/softwareheritage/graph/SwhPath.java b/api/server/src/main/java/org/softwareheritage/graph/SwhPath.java index 3cd002a..4b529b9 100644 --- a/api/server/src/main/java/org/softwareheritage/graph/SwhPath.java +++ b/api/server/src/main/java/org/softwareheritage/graph/SwhPath.java @@ -1,69 +1,76 @@ package org.softwareheritage.graph; import java.util.ArrayList; +import com.fasterxml.jackson.annotation.JsonValue; + import org.softwareheritage.graph.SwhId; public class SwhPath { ArrayList path; public SwhPath() { this.path = new ArrayList(); } public SwhPath(String ...swhIds) { this(); for (String swhId : swhIds) { add(new SwhId(swhId)); } } public SwhPath(SwhId ...swhIds) { this(); for (SwhId swhId : swhIds) { add(swhId); } } + @JsonValue + public ArrayList getPath() { + return path; + } + public void add(SwhId swhId) { path.add(swhId); } public SwhId get(int index) { return path.get(index); } public int size() { return path.size(); } @Override public boolean equals(Object otherObj) { if (otherObj == this) return true; if (! (otherObj instanceof SwhPath)) return false; SwhPath other = (SwhPath) otherObj; if (size() != other.size()) { return false; } for (int i = 0; i < size(); i++) { SwhId thisId = get(i); SwhId otherId = other.get(i); if (! thisId.equals(otherId)) { return false; } } return true; } @Override public String toString() { String str = new String(); for (SwhId swhId : path) { str += swhId + "/"; } return str; } }