View Javadoc
1   /*
2    * SPDX-License-Identifier: Apache-2.0
3    * See LICENSE file for details.
4    *
5    * Copyright 2012-2026 hazendaz
6    *
7    * Portions of initial baseline code (getter/setter test) by Rob Dawson (CodeBox)
8    */
9   package com.codebox.util;
10  
11  import java.lang.reflect.Method;
12  import java.lang.reflect.Modifier;
13  
14  /**
15   * The Class LombokBuilderUtil.
16   */
17  public final class LombokBuilderUtil {
18  
19      /**
20       * Instantiates a new lombok builder util.
21       */
22      private LombokBuilderUtil() {
23          // prevent instantiation
24      }
25  
26      /**
27       * Get the Lombok builder() method if present, else null.
28       *
29       * @param clazz
30       *            the clazz
31       * @return the lombok builder method
32       */
33      public static Method getLombokBuilderMethod(final Class<?> clazz) {
34          try {
35              final Method builderMethod = clazz.getMethod("builder");
36              if (Modifier.isStatic(builderMethod.getModifiers()) && builderMethod.getParameterCount() == 0) {
37                  return builderMethod;
38              }
39          } catch (final NoSuchMethodException e) {
40              // ignore
41          }
42          return null;
43      }
44  
45  }