Skip to content

Commit

Permalink
Use Objects.requireNonNull()
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 26, 2024
1 parent d265d86 commit 6cc3898
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions core/src/main/java/org/apache/commons/jelly/XMLOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -891,10 +892,7 @@ public ContentHandler getContentHandler() {
* This value cannot be null.
*/
public void setContentHandler(ContentHandler contentHandler) {
if (contentHandler == null) {
throw new NullPointerException("ContentHandler cannot be null!");
}
this.contentHandler = contentHandler;
this.contentHandler = Objects.requireNonNull(contentHandler, "contentHandler");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.MethodUtils;
Expand Down Expand Up @@ -309,11 +310,7 @@ public void setObject(Object object) {
}

public Project getAntProject() {
Project project = AntTagLibrary.getProject(context);
if (project == null) {
throw new NullPointerException("No Ant Project object is available");
}
return project;
return Objects.requireNonNull(AntTagLibrary.getProject(context), "No Ant Project object is available");
}

// Implementation methods
Expand Down

0 comments on commit 6cc3898

Please sign in to comment.