JSR305 有助于提高代码健壮性
[b]下载(java5+ ,据说java7 内置了)[/b]
[b]使用(eclipse)[/b]
[b]效果(Javadoc和Eclipse提示)[/b]
[color=blue]@Nonnull[/color]
public static String [b]nullToEmpty[/b]([color=blue]@Nullable[/color] String s)
null to empty
[b]Parameters:[/b]
s - @Nullable the string
[b]Returns:[/b]
@Nullable the string
[b]【注】[/b]
eclipse提示中,方法签名中不显示[color=blue]@Nullable[/color]注解,也许以后会支持吧
public static String [b]nullToEmpty[/b]( String s)
[b]下载(java5+ ,据说java7 内置了)[/b]
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
<scope>compile</scope>
</dependency>
[b]使用(eclipse)[/b]
/**
* null to empty
*
* @param s @Nullable the string
* @return @Nullable the string
*/
@Nonnull
public static String nullToEmpty(@Nullable String s) {
return s == null ? EMPTY : s;
}
[b]效果(Javadoc和Eclipse提示)[/b]
[color=blue]@Nonnull[/color]
public static String [b]nullToEmpty[/b]([color=blue]@Nullable[/color] String s)
null to empty
[b]Parameters:[/b]
s - @Nullable the string
[b]Returns:[/b]
@Nullable the string
[b]【注】[/b]
eclipse提示中,方法签名中不显示[color=blue]@Nullable[/color]注解,也许以后会支持吧
public static String [b]nullToEmpty[/b]( String s)