All Downloads are FREE. Search and download functionalities are using the official Maven repository.

im.aop.loggers.messageinterpolation.ObjectToStringStrategy Maven / Gradle / Ivy

Go to download

A handy and configurable sets of annotation-based loggers for Spring Boot that can log every execution of a method when entering or exiting normally or abnormally, without you writing a single line of code using aspect-oriented programming (AOP)

The newest version!
package im.aop.loggers.messageinterpolation;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * {@link ToStringStrategy} implementation using {@link String#valueOf(boolean)}. Return "null" if a
 * is null.
 *
 * @author Andy Lian
 */
public class ObjectToStringStrategy implements ToStringStrategy {

  @Autowired private ReflectionToStringStrategy reflectionToStringStrategy;

  @Override
  public boolean supports(Object object) {
    return true;
  }

  @Override
  public String toString(Object object) {
    if (object == null || reflectionToStringStrategy.supports(object) == false) {
      return String.valueOf(object);
    } else {
      return reflectionToStringStrategy.toString(object);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy