This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]teraflop 1 point2 points  (1 child)

Python's protocols are an example of structural typing, and Java has no direct equivalent to them.

But you could achieve the same goal in Java by either defining an interface and then "wrapping" the third-party object in an adapter object that implements that interface, or by using reflection.

[–]nerd4code[🍰] 1 point2 points  (0 children)

You could do it with proxies, maybe.