Created
May 9, 2015 02:49
-
-
Save lgiudice/cd5981b38f04c979f5ee to your computer and use it in GitHub Desktop.
proving that, given an object, we can know if some of the methods it understands are from a trait
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
public interface InterfaceA { | |
public default String m1() { | |
return " This is InterfaceA.m1"; | |
} | |
} | |
public class SomeClass implements InterfaceA { | |
public static void main(String[] args) { | |
List<Method> declaredMethods = Arrays.asList(new SomeClass().getClass().getMethods()); | |
declaredMethods.forEach(m -> System.out.println(m.getName() + (m.isDefault() ? " is default" : " is not default"))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment