Logging util with static lambda function So again, I am a bit confused about some notes that i'am getting from my reviewer. I have some kind of utils, to print/prepare log messages. Yea, maybe I am a bit fanatic java 8 lambda guy but I think it is still under control. :)

So its looks like that [I hide 'sensitive' data]

public class ExceptionUtils {

  private static final BiFunction&lt;String, String, String&gt; CUSTOM_EXCEPTION_MESSAGE_FORMAT =
    (typeOfError, typeOfEndpoint) -&gt; "[XXX] " + typeOfError + " Error during process bulk " + typeOfEndpoint + " events. "
        + "Event "
        + "occurrences time: %d "
        + "event retry count: %d, "
        + "session: %s";

  public static String validationMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
    return String.format(CUSTOM_EXCEPTION_MESSAGE_FORMAT.apply("Validation", endpoint), timestamp, retryCount, sessionToken);
  }

  public static String unknownMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
    return String.format(CUSTOM_EXCEPTION_MESSAGE_FORMAT.apply("Unknown", endpoint), timestamp, retryCount, sessionToken);
  }
}
What is the point of adding some parameters as part of format string when others are simply passed to String.format? You might as well just do the latter:

public class ExceptionUtils {

    private static final String CUSTOM_EXCEPTION_MESSAGE_FORMAT
            = "[XXX] %s Error during process bulk %s events. Event occurrences time: %d event retry count: %d, session: %s";

    private static String formatMessage(String type, String endpoint, long timestamp, int retryCount, String sessionToken) {
        return String.format(CUSTOM_EXCEPTION_MESSAGE_FORMAT, 
                type, endpoint, timestamp, retryCount, sessionToken);
    }

    public static String validationMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
        return formatMessage("Validation", endpoint, timestamp, retryCount, sessionToken);
    }

    public static String unknownMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
        return formatMessage("Unknown", endpoint, timestamp, retryCount, sessionToken);
    }
}


or even just:

public class ExceptionUtils {

    private static final String CUSTOM_EXCEPTION_MESSAGE_FORMAT
            = "[XXX] %s Error during process bulk %s events. Event occurrences time: %d event retry count: %d, session: %s";

    public static String validationMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
        return String.format(CUSTOM_EXCEPTION_MESSAGE_FORMAT, 
                "Validation", endpoint, timestamp, retryCount, sessionToken);
    }

    public static String unknownMessageException(String endpoint, long timestamp, int retryCount, String sessionToken) {
        return String.format(CUSTOM_EXCEPTION_MESSAGE_FORMAT, 
                "Unknown", endpoint, timestamp, retryCount, sessionToken);
    }
}