In Java is there a static version of 'this' -
i know quite minor, @ top of every class end copying , pasting , changing following line of code.
private static final string tag = myclass.class.getname();
what not have modify myclass bit every time copy.
i.e. write this.
private static final string tag = this.class.getname();
but there no @ point. know minor, learn answers, , indeed learnt stuff searching see if there answer already.
you can define eclipse template, called tag
, example:
private static final string tag = ${enclosing_type}.class.getname();
then, type tag
followed ctrl+space
, insert statement.
i use method declare loggers in classes.
alternatively, query stack trace of current thread:
private static final string tag = thread.currentthread().getstacktrace()[1].getclassname();
Comments
Post a Comment