2015-11-26 12:36:15 +01:00
|
|
|
package edu.ycp.cs.dh.acegwt.client.ace;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import com.google.gwt.core.client.JavaScriptObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ace command's argument could be either string or string-to-string map.
|
|
|
|
*/
|
|
|
|
public class AceCommandArgs {
|
|
|
|
private final Object value;
|
|
|
|
|
|
|
|
/**
|
2015-11-26 15:37:51 +01:00
|
|
|
* Create map argument. In case param data is null map will be empty.
|
|
|
|
*
|
|
|
|
* @param data map
|
2015-11-26 12:36:15 +01:00
|
|
|
*/
|
|
|
|
public AceCommandArgs(Map<String, String> data) {
|
|
|
|
value = JavaScriptObject.createObject();
|
|
|
|
if (data != null)
|
|
|
|
for (Map.Entry<String, String> entry : data.entrySet())
|
|
|
|
with(entry.getKey(), entry.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create text argument.
|
2015-11-26 15:37:51 +01:00
|
|
|
*
|
|
|
|
* @param value text argument
|
2015-11-26 12:36:15 +01:00
|
|
|
*/
|
|
|
|
public AceCommandArgs(String value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add key-value pair to map.
|
2015-11-26 15:37:51 +01:00
|
|
|
*
|
|
|
|
* @param argKey key
|
|
|
|
* @param argValue value
|
2016-02-19 11:12:36 +01:00
|
|
|
* @return AceCommandArgs
|
2015-11-26 12:36:15 +01:00
|
|
|
*/
|
|
|
|
public native AceCommandArgs with(String argKey, String argValue) /*-{
|
|
|
|
this.@edu.ycp.cs.dh.acegwt.client.ace.AceCommandArgs::value[argKey] = argValue;
|
|
|
|
return this;
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Give inner value.
|
|
|
|
* @return string or map depending on used constructor
|
|
|
|
*/
|
|
|
|
public Object getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|