Java annotation utility for multiline text

给你一囗甜甜゛ 提交于 2019-12-23 10:47:12

问题


WRT Any Future Plans for Multiline Java String.

How difficult is it to write a utility that does the following?

@AllYouCanEatText(return="query")
private String getQuery(String empid, String[] columns) {
  String query;
  /*
  SELECT ${columns}
  FROM Employees
  WHERE empid = ${empid}
  ;
  */
  return query;
};

Of course, before I jump in front of the barrel, I should have asked - Is such a utility already available? If so, where?

The issue at hand is actually - how do I read the comments section in reflection during compile time. As an indication of my (dismal) level of familiarity with Reflection and annotation processing - the last time I used reflection was run-time to read methods. Is compile-time reflection possible?

Is anyone interested in sharing a google code project with me to do this? May be there is already an apache project afoot?


回答1:


I came across this a while ago, never used it myself, but I think its what you are looking for http://www.adrianwalker.org/2011/12/java-multiline-string.html



来源:https://stackoverflow.com/questions/12115115/java-annotation-utility-for-multiline-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!