Skip to content

Instantly share code, notes, and snippets.

@nazarov-yuriy
Created December 24, 2014 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazarov-yuriy/bdc13ff748ff538a8388 to your computer and use it in GitHub Desktop.
Save nazarov-yuriy/bdc13ff748ff538a8388 to your computer and use it in GitHub Desktop.
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