-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
public class Bar implements IBar { | ||
public String widen() { return "foo"; } | ||
public Object narrow() { return "foo"; } | ||
public String adapter() { return "http://example.com/"; } | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
public interface IBar { | ||
String widen(); | ||
Object narrow(); | ||
String adapter(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods; | ||
import java.io.UncheckedIOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
public class Bar implements IBar { | ||
@WithBridgeMethods(value = String.class, castRequired = true) | ||
public Object widen() { return "bar"; } | ||
|
||
@WithBridgeMethods(Object.class) | ||
public String narrow() { return "bar"; } | ||
|
||
@WithBridgeMethods(value = String.class, adapterMethod = "convert") | ||
public URL adapter() { | ||
try { | ||
return new URL("http://example.com/"); | ||
} catch (MalformedURLException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
} | ||
|
||
private Object convert(URL url, Class<?> type) { | ||
return url.toString(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods; | ||
import java.net.URL; | ||
|
||
public interface IBar { | ||
@WithBridgeMethods(value=String.class,castRequired=true) | ||
Object widen(); | ||
@WithBridgeMethods(Object.class) | ||
String narrow(); | ||
@WithBridgeMethods(String.class) | ||
URL adapter(); | ||
} |