com.datastax.data.dataset.DataCommand Maven / Gradle / Ivy
package com.datastax.data.dataset;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;
import java.util.Map;
public abstract class DataCommand {
private String shortDescription;
private static final Object UNDEFINED = new Object();
private Map params = new HashMap();
private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription == null ? "" : shortDescription;
}
public String getShortDescription() {
return shortDescription;
}
public void setParameter(String name, Object value) {
params.put(name, value);
}
public void clearParameter(String name) {
params.put(name, UNDEFINED);
}
public void clearParameters() {
for (String name : params.keySet()) {
params.put(name, UNDEFINED);
}
}
public Object getParameter(String name) {
return params.get(name);
}
public abstract String[] getParameterNames();
public Object[] getParameterValues() {
return params.values().toArray();
}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
pcs.firePropertyChange(propertyName, oldValue, newValue);
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
pcs.addPropertyChangeListener(propertyName, listener);
}
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
pcs.removePropertyChangeListener(propertyName, listener);
}
}