Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/java/org/gephi/graph/impl/GraphAttributesImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,51 @@
*/
package org.gephi.graph.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import org.gephi.graph.api.AttributeUtils;
import org.gephi.graph.api.Interval;
import org.gephi.graph.api.types.TimeMap;
import org.gephi.graph.impl.utils.MapDeepEquals;

public class GraphAttributesImpl {

protected final Map<String, Object> attributes = new HashMap<>();
// A TreeMap is used so the iteration order is canonical (sorted by key).
// This makes serialization a pure function of the content rather than of
// the insertion history, which is required for byte-pinned fixtures.
protected final Map<String, Object> attributes = new TreeMap<>();

public synchronized Set<String> getKeys() {
return attributes.keySet();
}

public synchronized void setValue(String key, Object value) {
Objects.requireNonNull(key, "key");
if (value != null) {
checkSupportedTypes(value.getClass());
}
attributes.put(key, AttributeUtils.standardizeValue(value));
}

public synchronized void removeValue(String key) {
Objects.requireNonNull(key, "key");
attributes.remove(key);
}

public synchronized Object getValue(String key) {
Objects.requireNonNull(key, "key");
return attributes.get(key);
}

public synchronized Object getValue(String key, double timestamp) {
Objects.requireNonNull(key, "key");
return getValueInternal(key, timestamp);
}

public synchronized Object getValue(String key, Interval interval) {
Objects.requireNonNull(key, "key");
return getValueInternal(key, interval);
}

Expand All @@ -63,11 +72,13 @@ private Object getValueInternal(String key, Object timeObj) {
}

public synchronized void removeValue(String key, double timestamp) {
Objects.requireNonNull(key, "key");
removeValueInternal(key, timestamp);

}

public synchronized void removeValue(String key, Interval interval) {
Objects.requireNonNull(key, "key");
removeValueInternal(key, interval);
}

Expand All @@ -83,10 +94,12 @@ private void removeValueInternal(String key, Object timeObj) {
}

public synchronized void setValue(String key, Object value, double timestamp) {
Objects.requireNonNull(key, "key");
setValueInternal(key, value, timestamp);
}

public synchronized void setValue(String key, Object value, Interval interval) {
Objects.requireNonNull(key, "key");
setValueInternal(key, value, interval);
}

Expand Down