Created
March 12, 2012 15:33
-
-
Save zaneli/2022682 to your computer and use it in GitHub Desktop.
「Jython-bugs issue1642 に対するワークアラウンド」ブログ用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.zaneli.script; | |
public interface ScriptService { | |
void echo(String message); | |
String getName(); | |
@Deprecated | |
String getName(String str); | |
int calculate(int num); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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