Skip to content

Instantly share code, notes, and snippets.

@zaneli
Created March 12, 2012 15:33
Show Gist options
  • Save zaneli/2022682 to your computer and use it in GitHub Desktop.
Save zaneli/2022682 to your computer and use it in GitHub Desktop.
「Jython-bugs issue1642 に対するワークアラウンド」ブログ用
package com.zaneli.script;
public interface ScriptService {
void echo(String message);
String getName();
@Deprecated
String getName(String str);
int calculate(int num);
}
package com.zaneli.script;
public class ScriptServiceWrapper implements ScriptService {
private final ScriptService delegeted;
public ScriptServiceWrapper(ScriptService delegeted) {
this.delegeted = delegeted;
}
@Override
public void echo(String message) {
delegeted.echo(message);
}
@Override
@SuppressWarnings("deprecation")
public String getName() {
try {
return delegeted.getName();
} catch (NullPointerException e) {
return delegeted.getName("");
}
}
@Override
public String getName(String str) {
// 回避用メソッドなので直接呼べないようにする。
throw new UnsupportedOperationException();
}
@Override
public int calculate(int num) {
return delegeted.calculate(num);
}
}
def echo(message):
print(message)
def getName(value):
# value は使用しない
return "Python Service"
def calculate(num):
return num - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment