Skip to content

Commit

Permalink
添加jetbrain annotations支持。
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zhou committed Dec 11, 2012
1 parent b4a38ff commit 8b2e7d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions common/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
<groupId>${project.groupId}</groupId>
<artifactId>citrus-common-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
</dependency>
</dependencies>
</project>
14 changes: 10 additions & 4 deletions common/util/src/main/java/com/alibaba/citrus/util/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import static com.alibaba.citrus.util.Assert.ExceptionType.*;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* 断言工具,用来实现<a
* href="http://martinfowler.com/ieeeSoftware/failFast.pdf">Fail-Fast</a>。
Expand Down Expand Up @@ -66,17 +69,20 @@
*/
public final class Assert {
/** 确保对象不为空,否则抛出<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object) {
@NotNull
public static <T> T assertNotNull(@Nullable T object) {
return assertNotNull(object, null, null, (Object[]) null);
}

/** 确保对象不为空,否则抛出<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object, String message, Object... args) {
@NotNull
public static <T> T assertNotNull(@Nullable T object, String message, Object... args) {
return assertNotNull(object, null, message, args);
}

/** 确保对象不为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
@NotNull
public static <T> T assertNotNull(@Nullable T object, ExceptionType exceptionType, String message, Object... args) {
if (object == null) {
if (exceptionType == null) {
exceptionType = ILLEGAL_ARGUMENT;
Expand Down Expand Up @@ -187,7 +193,7 @@ public static <T> T unsupportedOperation(String message, Object... args) {
}

/** 取得带参数的消息。 */
private static String getMessage(String message, Object[] args, String defaultMessage) {
private static String getMessage(@Nullable String message, @Nullable Object[] args, @NotNull String defaultMessage) {
if (message == null) {
message = defaultMessage;
}
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>9.0.4</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
Expand Down

0 comments on commit 8b2e7d2

Please sign in to comment.