Merge pull request #46 from ceefour/findbugs

Add `@Nonnull` annotation to aid findbugs / Eclipse IDE.

Pretty innocuous; JSR305 annotations are definitely the norm in many circles.
This commit is contained in:
Matt Bishop 2014-09-26 15:10:39 -07:00
commit 1909792061
3 changed files with 23 additions and 5 deletions

View File

@ -19,7 +19,12 @@
<url>http://www.slf4j.org</url>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>

View File

@ -24,6 +24,8 @@
*/
package org.slf4j;
import javax.annotation.Nonnull;
/**
* <code>ILoggerFactory</code> instances manufacture {@link Logger}
@ -54,5 +56,6 @@ public interface ILoggerFactory {
* @param name the name of the Logger to return
* @return a Logger instance
*/
public Logger getLogger(String name);
@Nonnull
public Logger getLogger(@Nonnull String name);
}

View File

@ -26,7 +26,14 @@ package org.slf4j;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import org.slf4j.helpers.NOPLoggerFactory;
import org.slf4j.helpers.SubstituteLogger;
@ -272,7 +279,8 @@ public final class LoggerFactory {
* @param name The name of the logger.
* @return logger
*/
public static Logger getLogger(String name) {
@Nonnull
public static Logger getLogger(@Nonnull String name) {
ILoggerFactory iLoggerFactory = getILoggerFactory();
return iLoggerFactory.getLogger(name);
}
@ -284,7 +292,8 @@ public final class LoggerFactory {
* @param clazz the returned logger will be named after clazz
* @return logger
*/
public static Logger getLogger(Class clazz) {
@Nonnull
public static Logger getLogger(@Nonnull Class clazz) {
return getLogger(clazz.getName());
}
@ -296,6 +305,7 @@ public final class LoggerFactory {
*
* @return the ILoggerFactory instance in use
*/
@Nonnull
public static ILoggerFactory getILoggerFactory() {
if (INITIALIZATION_STATE == UNINITIALIZED) {
INITIALIZATION_STATE = ONGOING_INITIALIZATION;