Java – make lambdas succinct with the help of lists?

In general, we want to create a logging framework that is suitable for both user-readable output and various structured data formats. One goal is to minimize code duplication when packaging the formatting functions. We have created a library of functions that can be used to format log entries.

The client can then loop through a list of these elements as each log record is processed to create the output string based on any recipe.

for (LogFormatSteps logFormatStep: logFormatList {

sb = logFormatStep.getRecipeStep (). f (sb, record, altContent);
}

In discussions about lambdas, they seem to be declared in their own class by expanding their functional interface. This is a lot of effort despite the many Javadocs. Is it a problem if the lambdas are collected instead in an enumeration to reduce the number of classes that ultimately need to be defined?

import java.util.Date;
import java.util.logging.LogRecord;

@Funktionsschnittstelle
/ ** Append stringbuilder with log information. * /
Interface LogFormatLambda {

/ **
* Adds information to the log entry text.
*
* @param logFragmentParam startup log fragment
* @param logRecordParam, which can be queried by Lambda
* @param altContentParam, which can be converted to lambda through toString ().
* /
Use public abstract StringBuilder (
StringBuilder logFragmentParam, LogRecord logRecordParam, Object altContentParam);
}

/ ** Lambda notation formatting functions used by this formatter * /
Enum LogFormatFunctions {

/ ** Append the current date and time. * /
DATE ((s, r, a) -> s.append (new date (r.getMillis ())) Append ("")),

/ ** Attach log level. * /
LEVEL ((s, r, a) -> s.append (r.getLevel (). GetLocalizedName ())),

/ ** Attach empty line. * /
LINE ((s, r, a) -> s.append (System.getProperty ("line.separator"))),

/ ** Append class name or, if not available, protocol name. * /
CLASS(
(s, r, a) ->
(r.getSourceClassName ()! = null)
? s.append ("") .append (r.getSourceClassName ())
: (r.getLoggerName ()! = null)? s.append ("") .append (r.getLoggerName ()): s),

/ ** Append the name of the method that generates the log entry. * /
METHOD(
(s, r, a) ->
(r.getSourceMethodName ()! = null)
? s.append ("") .append (r.getSourceMethodName ())
: s),

/ **
* Attach message text for the log entry and add a indent.
* /
EMBASSY(
(s, r, a) ->
(a! = zero)? s.append ("") .append (a.toString (). replace (" n", " n")): s);


/ ** lambda field. * /
LogFormatLambda f;

/ **
* Constructor - loads lambdas.
*
* @param functionParam lambda for this process step
* /
LogFormatFunctions (LogFormatLambda FunctionParam) {
this.f = functionParam;
}

/ **
* Adds log information.
*
* @param stringBuilderParam current log entry fragment
* @param logRecordParam log record (model)
* @param The AltContentParam object provides toString () information for processing steps
* /
StringBuilder f (
StringBuilder stringBuilderParam, LogRecord logRecordParam, Object altContentParam) {

return f.apply (stringBuilderParam, logRecordParam, altContentParam);
}
}

Are there any other ways to organize lambdas, eg. By naming conventions, package organization, etc., to avoid verbosity?

I've heard about using lambdas to process enumerations and enumerations to control the dynamic linking of lambdas as strategy objects. So far, however, I have not seen anyone who dealt with the possibility of using an enumeration to reduce the confusion.