Anchor | ||||
---|---|---|---|---|
|
...
protected void setupParameters()
プラグインは、構成に必要なUI定義とともにAPIを提供するために、こちらのメソッドを実装しなくてはいけません。一般的に、プラグインは「addParameter(Parameter)」を呼び出すことで、パラメーターオブジェクトを作成し、これを追加します。
...
Code Block | ||
---|---|---|
| ||
@Override protected void setupParameters() { Parameter p = new Parameter(); ... addParameter(p); } |
protected final void addParameter(Parameter p)
プラグインは、作成する新規パラメーターのAPIに通知をするために、このメソッドを使用します。新規パラメーターは、「setupParameters」メソッドの外部に追加された場合、保持されないことに注意をしてください。上記の例を参照してください。
public final Object getParameterValue(String key)
こちらのメソッドは、ユニークキー「key」とともに、パラメーターに現在の値を返します。
...
Code Block | ||
---|---|---|
| ||
Object paramVal = getParameterValue("SOME_KEY"); if (paramVal != null && paramVal.equals("INTERESTING_CONFIG")) { // Do something interesting ... } |
public void setParameterValue(String key, Object value)
こちらのメソッドは、パラメーターキーに格納された値を設定します。
...
Code Block | ||
---|---|---|
| ||
Object paramVal = getParameterValue("SOME_KEY"); if (shouldChangeThisValue(paramVal)) { Object newValue = new Object(); setParameterValue("SOME_KEY", newValue); } |
public void clearParameterValue(String key)
「setParameterValue(key, null)」の呼び出しと同等です。しかし、このメソッドは、パラメーター値マップからパラメーターキーの削除も行います。
...
Code Block | ||
---|---|---|
| ||
Object paramVal = getParameterValue("SOME_KEY"); if (shouldRemoveThisValue(paramVal)) { clearParameterValue("SOME_KEY"); } |
public void getParameter(String key)
すでにセットアップしたパラメーターを、与えられたキーとともに取得します。このキーのパラメーターが存在しない場合は、nullを返します。
...