Are there macro facility for Java or C#?

前端 未结 4 491
情话喂你
情话喂你 2021-01-13 13:33

Macros are useful.

Therefore, I occasionally bemoan the absence of macros in Java and C#. Macros allow me to force in-line but allow me the code-manageability of non

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 14:18

    Take a look at project Lombok - http://projectlombok.org/features/Log.html

    It is an annotation library that allows the following code snip-it - which (I believe) is exactly what you are speaking of.

     import lombok.extern.slf4j.Log;
    
     @Log
     public class LogExample {
    
       public static void main(String... args) {
         log.error("Something's wrong here");
       }
     }
    
     @Log(java.util.List.class)
     public class LogExampleOther {
    
       public static void main(String... args) {
         log.warn("Something might be wrong here");
       }
     }
    

提交回复
热议问题