Skip to content

Commit

Permalink
Merge pull request #320 from klu2/318/immutable-map-for-properties
Browse files Browse the repository at this point in the history
#318 return an immutable map in all implementations of PropertyHolder
  • Loading branch information
simonbrowndotje authored Aug 15, 2024
2 parents ca88ead + 9986f30 commit 289f087
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.structurizr.configuration.WorkspaceConfiguration;

import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -237,7 +238,7 @@ public void clearConfiguration() {
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ public void setImpliedRelationshipsStrategy(ImpliedRelationshipsStrategy implied
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void setUrl(String url) {
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.structurizr.PropertyHolder;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -15,7 +16,7 @@ public abstract class AbstractStyle implements PropertyHolder {
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.structurizr.PropertyHolder;
import com.structurizr.util.Url;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Configuration associated with how information in the workspace is rendered.
Expand Down Expand Up @@ -203,7 +200,7 @@ public void setViewSortOrder(ViewSortOrder viewSortOrder) {
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.structurizr.PropertyHolder;

import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -133,7 +134,7 @@ public ViewSet getViewSet() {
* @return a Map (String, String) (empty if there are no properties)
*/
public Map<String, String> getProperties() {
return new HashMap<>(properties);
return Collections.unmodifiableMap(properties);
}

/**
Expand Down

0 comments on commit 289f087

Please sign in to comment.