001package org.slf4j.spi; 002 003import java.util.function.Supplier; 004 005import org.slf4j.Marker; 006import org.slf4j.event.Level; 007 008/** 009 * <p>A no-operation implementation of {@link LoggingEventBuilder}.</p> 010 * 011 * <p>As the name indicates, the method in this class do nothing, except when a return value is expected 012 * in which case a singleton, i.e. the unique instance of this class is returned. 013 * </p 014 * 015 * @author Ceki Gülcü 016 * @since 2.0.0 017 * 018 */ 019public class NOPLoggingEventBuilder implements LoggingEventBuilder { 020 021 static final NOPLoggingEventBuilder SINGLETON = new NOPLoggingEventBuilder(); 022 023 private NOPLoggingEventBuilder() { 024 } 025 026 /** 027 * <p>Returns the singleton instance of this class. 028 * Used by {@link org.slf4j.Logger#makeLoggingEventBuilder(Level) makeLoggingEventBuilder(Level)}.</p> 029 * 030 * @return the singleton instance of this class 031 */ 032 public static LoggingEventBuilder singleton() { 033 return SINGLETON; 034 } 035 036 @Override 037 public LoggingEventBuilder addMarker(Marker marker) { 038 return singleton(); 039 } 040 041 @Override 042 public LoggingEventBuilder addArgument(Object p) { 043 return singleton(); 044 } 045 046 @Override 047 public LoggingEventBuilder addArgument(Supplier<?> objectSupplier) { 048 return singleton(); 049 } 050 051 @Override 052 public LoggingEventBuilder addKeyValue(String key, Object value) { 053 return singleton(); 054 } 055 056 @Override 057 public LoggingEventBuilder addKeyValue(String key, Supplier<Object> value) { 058 return singleton(); 059 } 060 061 @Override 062 public LoggingEventBuilder setCause(Throwable cause) { 063 return singleton(); 064 } 065 066 @Override 067 public void log() { 068 } 069 070 @Override 071 public LoggingEventBuilder setMessage(String message) { 072 return this; 073 } 074 @Override 075 public LoggingEventBuilder setMessage(Supplier<String> messageSupplier) { 076 return this; 077 } 078 079 @Override 080 public void log(String message) { 081 } 082 083 @Override 084 public void log(Supplier<String> messageSupplier) { 085 } 086 087 @Override 088 public void log(String message, Object arg) { 089 } 090 091 @Override 092 public void log(String message, Object arg0, Object arg1) { 093 } 094 095 @Override 096 public void log(String message, Object... args) { 097 098 } 099 100}