Browse Source

Rename LogMessage.lazy(Supplier) to LogMessage.of(Supplier)

See gh-22726
pull/22737/head
Juergen Hoeller 6 years ago
parent
commit
52f90c303e
  1. 24
      spring-core/src/main/java/org/springframework/core/log/LogAccessor.java
  2. 22
      spring-core/src/main/java/org/springframework/core/log/LogMessage.java
  3. 2
      spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java

24
spring-core/src/main/java/org/springframework/core/log/LogAccessor.java

@ -180,7 +180,7 @@ public class LogAccessor { @@ -180,7 +180,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void fatal(Supplier<? extends CharSequence> messageSupplier) {
this.log.fatal(LogMessage.lazy(messageSupplier));
this.log.fatal(LogMessage.of(messageSupplier));
}
/**
@ -189,7 +189,7 @@ public class LogAccessor { @@ -189,7 +189,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void fatal(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.fatal(LogMessage.lazy(messageSupplier), cause);
this.log.fatal(LogMessage.of(messageSupplier), cause);
}
/**
@ -197,7 +197,7 @@ public class LogAccessor { @@ -197,7 +197,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void error(Supplier<? extends CharSequence> messageSupplier) {
this.log.error(LogMessage.lazy(messageSupplier));
this.log.error(LogMessage.of(messageSupplier));
}
/**
@ -206,7 +206,7 @@ public class LogAccessor { @@ -206,7 +206,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void error(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.error(LogMessage.lazy(messageSupplier), cause);
this.log.error(LogMessage.of(messageSupplier), cause);
}
/**
@ -214,7 +214,7 @@ public class LogAccessor { @@ -214,7 +214,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void warn(Supplier<? extends CharSequence> messageSupplier) {
this.log.warn(LogMessage.lazy(messageSupplier));
this.log.warn(LogMessage.of(messageSupplier));
}
/**
@ -223,7 +223,7 @@ public class LogAccessor { @@ -223,7 +223,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void warn(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.warn(LogMessage.lazy(messageSupplier), cause);
this.log.warn(LogMessage.of(messageSupplier), cause);
}
/**
@ -231,7 +231,7 @@ public class LogAccessor { @@ -231,7 +231,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void info(Supplier<? extends CharSequence> messageSupplier) {
this.log.info(LogMessage.lazy(messageSupplier));
this.log.info(LogMessage.of(messageSupplier));
}
/**
@ -240,7 +240,7 @@ public class LogAccessor { @@ -240,7 +240,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void info(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.info(LogMessage.lazy(messageSupplier), cause);
this.log.info(LogMessage.of(messageSupplier), cause);
}
/**
@ -248,7 +248,7 @@ public class LogAccessor { @@ -248,7 +248,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void debug(Supplier<? extends CharSequence> messageSupplier) {
this.log.debug(LogMessage.lazy(messageSupplier));
this.log.debug(LogMessage.of(messageSupplier));
}
/**
@ -257,7 +257,7 @@ public class LogAccessor { @@ -257,7 +257,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void debug(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.debug(LogMessage.lazy(messageSupplier), cause);
this.log.debug(LogMessage.of(messageSupplier), cause);
}
/**
@ -265,7 +265,7 @@ public class LogAccessor { @@ -265,7 +265,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void trace(Supplier<? extends CharSequence> messageSupplier) {
this.log.trace(LogMessage.lazy(messageSupplier));
this.log.trace(LogMessage.of(messageSupplier));
}
/**
@ -274,7 +274,7 @@ public class LogAccessor { @@ -274,7 +274,7 @@ public class LogAccessor {
* @param messageSupplier a lazy supplier for the message to log
*/
public void trace(Throwable cause, Supplier<? extends CharSequence> messageSupplier) {
this.log.trace(LogMessage.lazy(messageSupplier), cause);
this.log.trace(LogMessage.of(messageSupplier), cause);
}
}

22
spring-core/src/main/java/org/springframework/core/log/LogMessage.java

@ -29,7 +29,7 @@ import org.springframework.util.Assert; @@ -29,7 +29,7 @@ import org.springframework.util.Assert;
*
* @author Juergen Hoeller
* @since 5.2
* @see #lazy(Supplier)
* @see #of(Supplier)
* @see #format(String, Object)
* @see #format(String, Object...)
* @see org.apache.commons.logging.Log#fatal(Object)
@ -76,16 +76,16 @@ public abstract class LogMessage implements CharSequence { @@ -76,16 +76,16 @@ public abstract class LogMessage implements CharSequence {
/**
* Build a lazy resolution message from the given supplier.
* Build a lazily resolving message from the given supplier.
* @param supplier the supplier (typically bound to a Java 8 lambda expression)
* @see #toString()
*/
public static LogMessage lazy(Supplier<? extends CharSequence> supplier) {
return new LazyMessage(supplier);
public static LogMessage of(Supplier<? extends CharSequence> supplier) {
return new SupplierMessage(supplier);
}
/**
* Build a formatted message from the given format string and argument.
* Build a lazily formatted message from the given format string and argument.
* @param format the format string (following {@link String#format} rules)
* @param arg1 the argument
* @see String#format(String, Object...)
@ -95,7 +95,7 @@ public abstract class LogMessage implements CharSequence { @@ -95,7 +95,7 @@ public abstract class LogMessage implements CharSequence {
}
/**
* Build a formatted message from the given format string and arguments.
* Build a lazily formatted message from the given format string and arguments.
* @param format the format string (following {@link String#format} rules)
* @param arg1 the first argument
* @param arg2 the second argument
@ -106,7 +106,7 @@ public abstract class LogMessage implements CharSequence { @@ -106,7 +106,7 @@ public abstract class LogMessage implements CharSequence {
}
/**
* Build a formatted message from the given format string and arguments.
* Build a lazily formatted message from the given format string and arguments.
* @param format the format string (following {@link String#format} rules)
* @param arg1 the first argument
* @param arg2 the second argument
@ -118,7 +118,7 @@ public abstract class LogMessage implements CharSequence { @@ -118,7 +118,7 @@ public abstract class LogMessage implements CharSequence {
}
/**
* Build a formatted message from the given format string and arguments.
* Build a lazily formatted message from the given format string and arguments.
* @param format the format string (following {@link String#format} rules)
* @param arg1 the first argument
* @param arg2 the second argument
@ -131,7 +131,7 @@ public abstract class LogMessage implements CharSequence { @@ -131,7 +131,7 @@ public abstract class LogMessage implements CharSequence {
}
/**
* Build a formatted message from the given format string and varargs.
* Build a lazily formatted message from the given format string and varargs.
* @param format the format string (following {@link String#format} rules)
* @param args the varargs array (costly, prefer individual arguments)
* @see String#format(String, Object...)
@ -141,11 +141,11 @@ public abstract class LogMessage implements CharSequence { @@ -141,11 +141,11 @@ public abstract class LogMessage implements CharSequence {
}
private static final class LazyMessage extends LogMessage {
private static final class SupplierMessage extends LogMessage {
private Supplier<? extends CharSequence> supplier;
LazyMessage(Supplier<? extends CharSequence> supplier) {
SupplierMessage(Supplier<? extends CharSequence> supplier) {
Assert.notNull(supplier, "Supplier must not be null");
this.supplier = supplier;
}

2
spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java

@ -28,7 +28,7 @@ public class LogSupportTests { @@ -28,7 +28,7 @@ public class LogSupportTests {
@Test
public void testLogMessageWithSupplier() {
LogMessage msg = LogMessage.lazy(() -> new StringBuilder("a").append(" b"));
LogMessage msg = LogMessage.of(() -> new StringBuilder("a").append(" b"));
assertEquals("a b", msg.toString());
assertSame(msg.toString(), msg.toString());
}

Loading…
Cancel
Save