Created
December 24, 2014 22:12
-
-
Save nazarov-yuriy/bdc13ff748ff538a8388 to your computer and use it in GitHub Desktop.
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
import java.lang.*; | |
public class NameOfDemo { | |
public MyString getName() { | |
return (new MyString(this.name){}); | |
} | |
public void setName(MyString name) { | |
this.name = name; | |
} | |
public MyString name; | |
public NameOfDemo() { | |
name = new MyString(""); | |
} | |
public static String nameof(MyString val){ | |
return val.getClass().getEnclosingMethod().getName().replace("get", "").toLowerCase(); | |
} | |
public static void main(String[] args) { | |
System.out.println( nameof((new NameOfDemo()).getName()) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment