com.structurizr.view.AbstractStyle Maven / Gradle / Ivy
package com.structurizr.view;
import com.structurizr.PropertyHolder;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractStyle implements PropertyHolder {
private Map properties = new HashMap<>();
/**
* Gets the collection of name-value property pairs associated with this workspace, as a Map.
*
* @return a Map (String, String) (empty if there are no properties)
*/
public Map getProperties() {
return Collections.unmodifiableMap(properties);
}
/**
* Adds a name-value pair property to this workspace.
*
* @param name the name of the property
* @param value the value of the property
*/
public void addProperty(String name, String value) {
if (name == null || name.trim().length() == 0) {
throw new IllegalArgumentException("A property name must be specified.");
}
if (value == null || value.trim().length() == 0) {
throw new IllegalArgumentException("A property value must be specified.");
}
properties.put(name, value);
}
void setProperties(Map properties) {
if (properties != null) {
this.properties = new HashMap<>(properties);
}
}
}