Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WICKET-7145: added @Nonnull to parameters #1093

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions wicket-auth-roles/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<osgi.import.package>!java*,!kotlin*,!sun.nio.ch,org.slf4j*;version="[1.7,3)",*</osgi.import.package>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
Expand Down
1 change: 1 addition & 0 deletions wicket-auth-roles/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
requires org.apache.wicket.util;
requires org.apache.wicket.request;
requires org.apache.wicket.core;
requires jakarta.annotation;

exports org.apache.wicket.authroles.authentication;
exports org.apache.wicket.authroles.authentication.pages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.wicket.authroles.authorization.strategies.role;

import jakarta.annotation.Nonnull;

import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.util.lang.Args;

Expand All @@ -36,7 +38,7 @@ public abstract class AbstractRoleAuthorizationStrategy extends IAuthorizationSt
* @param roleCheckingStrategy
* the authorizer delegate
*/
public AbstractRoleAuthorizationStrategy(IRoleCheckingStrategy roleCheckingStrategy)
public AbstractRoleAuthorizationStrategy(@Nonnull IRoleCheckingStrategy roleCheckingStrategy)
{
Args.notNull(roleCheckingStrategy, "roleCheckingStrategy");
this.roleCheckingStrategy = roleCheckingStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Collection;
import java.util.HashSet;

import jakarta.annotation.Nonnull;

import org.apache.wicket.util.io.IClusterable;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.StringList;
Expand Down Expand Up @@ -53,7 +55,7 @@ public Roles()
* @param roles
* Roles as a comma separated list, like "ADMIN, USER"
*/
public Roles(final String roles)
public Roles(@Nonnull final String roles)
{
Args.notNull(roles, "roles");
for (final String role : roles.split("\\s*,\\s*"))
Expand All @@ -68,7 +70,7 @@ public Roles(final String roles)
* @param roles
* Roles
*/
public Roles(final String[] roles)
public Roles(@Nonnull final String[] roles)
{
Args.notNull(roles, "roles");
for (final String role : roles)
Expand All @@ -77,7 +79,7 @@ public Roles(final String[] roles)
}
}

public Roles(final Collection<String> roles) {
public Roles(@Nonnull final Collection<String> roles) {
Args.notNull(roles, "roles");
addAll(roles);
}
Expand Down
4 changes: 4 additions & 0 deletions wicket-bean-validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
Expand Down
1 change: 1 addition & 0 deletions wicket-bean-validation/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
requires org.apache.wicket.util;
requires org.apache.wicket.core;
requires jakarta.validation;
requires jakarta.annotation;

exports org.apache.wicket.bean.validation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Supplier;

import jakarta.annotation.Nonnull;
import jakarta.validation.Validator;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -99,8 +100,8 @@ public BeanValidationConfiguration()
* tag modifier to use
* @return {@code this}
*/
public <T extends Annotation> BeanValidationConfiguration register(Class<T> annotationType,
ITagModifier<T> modifier)
public <T extends Annotation> BeanValidationConfiguration register(@Nonnull Class<T> annotationType,
@Nonnull ITagModifier<T> modifier)
{
Args.notNull(annotationType, "annotationType");
Args.notNull(modifier, "modifier");
Expand All @@ -117,7 +118,7 @@ public <T extends Annotation> BeanValidationConfiguration register(Class<T> anno
*/
@Override
@SuppressWarnings("unchecked")
public <T extends Annotation> ITagModifier<T> getTagModifier(Class<T> annotationType)
public <T extends Annotation> ITagModifier<T> getTagModifier(@Nonnull Class<T> annotationType)
{
Args.notNull(annotationType, "annotationType");

Expand All @@ -131,7 +132,7 @@ public <T extends Annotation> ITagModifier<T> getTagModifier(Class<T> annotation
* @param resolver
* @return {@code this}
*/
public BeanValidationConfiguration add(IPropertyResolver resolver)
public BeanValidationConfiguration add(@Nonnull IPropertyResolver resolver)
{
Args.notNull(resolver, "resolver");

Expand All @@ -156,7 +157,7 @@ public Validator getValidator()
*
* @param validatorProvider
*/
public void setValidatorProvider(Supplier<Validator> validatorProvider)
public void setValidatorProvider(@Nonnull Supplier<Validator> validatorProvider)
{
Args.notNull(validatorProvider, "validatorProvider");

Expand Down Expand Up @@ -187,7 +188,7 @@ public IViolationTranslator getViolationTranslator()
* A violation translator that will convert {@link jakarta.validation.ConstraintViolation}s into Wicket's
* {@link org.apache.wicket.validation.ValidationError}s
*/
public void setViolationTranslator(IViolationTranslator violationTranslator)
public void setViolationTranslator(@Nonnull IViolationTranslator violationTranslator)
{
Args.notNull(violationTranslator, "violationTranslator");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.lang.annotation.Annotation;

import jakarta.annotation.Nonnull;
import jakarta.validation.Validator;
import jakarta.validation.metadata.ConstraintDescriptor;

Expand All @@ -41,7 +42,7 @@ public interface BeanValidationContext extends IPropertyResolver
* @param annotationType
* @return tag modifier or {@code null} if none
*/
<T extends Annotation> ITagModifier<T> getTagModifier(Class<T> annotationType);
<T extends Annotation> ITagModifier<T> getTagModifier(@Nonnull Class<T> annotationType);

/**
* @return the validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.io.Serializable;

import jakarta.annotation.Nonnull;

import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.reference.ClassReference;

Expand All @@ -31,7 +33,7 @@ public final class Property implements Serializable
private final ClassReference<?> owner;
private final String name;

public Property(ClassReference<?> owner, String name)
public Property(@Nonnull ClassReference<?> owner, @Nonnull String name)
{
Args.notNull(owner, "owner");
Args.notEmpty(name, "name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Iterator;
import java.util.Set;

import jakarta.annotation.Nonnull;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;
import jakarta.validation.groups.Default;
Expand Down Expand Up @@ -150,7 +151,7 @@ private Class<?>[] getGroups()

@SuppressWarnings("unchecked")
@Override
public void bind(Component component)
public void bind(@Nonnull Component component)
{
if (this.component != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.Locale;

import jakarta.annotation.Nonnull;
import jakarta.validation.MessageInterpolator;

import org.apache.wicket.Session;
Expand All @@ -38,7 +39,7 @@ public class SessionLocaleInterpolator implements MessageInterpolator
* @param delegate
* the MessageInterpolator to delegate to
*/
public SessionLocaleInterpolator(MessageInterpolator delegate)
public SessionLocaleInterpolator(@Nonnull MessageInterpolator delegate)
{
Args.notNull(delegate, "delegate");
this.delegate = delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.wicket.cdi;

import jakarta.annotation.Nonnull;
import jakarta.enterprise.context.ContextNotActiveException;
import jakarta.enterprise.context.Conversation;
import jakarta.enterprise.context.ConversationScoped;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class ConversationPropagator implements IRequestCycleListener
* @param application
* @param propagation
*/
public ConversationPropagator(Application application, IConversationPropagation propagation)
public ConversationPropagator(@Nonnull Application application, @Nonnull IConversationPropagation propagation)
{
Args.notNull(application, "application");
Args.notNull(propagation, "propagation");
Expand Down
5 changes: 5 additions & 0 deletions wicket-core-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<japicmp.skip>true</japicmp.skip> <!-- this module is not released -->
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
*/
package org.apache.wicket.core.request.mapper;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.io.Serializable;
import java.util.Locale;
import java.util.function.Supplier;
import java.util.regex.Pattern;

import jakarta.annotation.Nonnull;

import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
Expand All @@ -47,6 +45,10 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static imports usually come before non-static?


/**
* @author Matej Knopp
*/
Expand Down Expand Up @@ -584,7 +586,7 @@ private static class AlphaDigitResourceVersion implements IResourceVersion
* @param version
* static version string to deliver for all queries resources
*/
AlphaDigitResourceVersion(String version)
AlphaDigitResourceVersion(@Nonnull String version)
{
this.version = Args.notNull(version, "version");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ void executeAjaxEvent_ajaxFormSubmitLink()
// executeAjaxEvent weren't submitting the form the name would have been
// reset to null, because the form would have been updated but there
// wouldn't be any data to update it with.
assertNotNull("executeAjaxEvent() did not properly submit the form", pojo.getName());
assertNotNull(pojo.getName(), "executeAjaxEvent() did not properly submit the form");
assertEquals("Mock name", pojo.getName());
}

Expand Down
4 changes: 4 additions & 0 deletions wicket-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ org.apache.wicket.validation.validator;-noimport:=true
<osgi.import.package>!java*,!kotlin*,!sun.nio.ch,!com.sun.crypto.provider,org.slf4j*;version="[1.7,3)",jakarta.servlet,jakarta.servlet.http,*</osgi.import.package>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>com.github.openjson</groupId>
<artifactId>openjson</artifactId>
Expand Down
1 change: 1 addition & 0 deletions wicket-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
requires org.danekja.jdk.serializable.functional;
requires com.github.openjson;
requires static org.bouncycastle.provider;
requires jakarta.annotation;

provides org.apache.wicket.IInitializer with org.apache.wicket.Initializer;
provides org.apache.wicket.resource.FileSystemPathService with org.apache.wicket.resource.FileSystemJarPathService;
Expand Down
13 changes: 8 additions & 5 deletions wicket-core/src/main/java/org/apache/wicket/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

import jakarta.annotation.Nonnull;

import org.apache.wicket.application.ComponentInitializationListenerCollection;
import org.apache.wicket.application.ComponentInstantiationListenerCollection;
import org.apache.wicket.application.ComponentOnAfterRenderListenerCollection;
Expand Down Expand Up @@ -673,7 +676,7 @@ public Supplier<IExceptionMapper> getExceptionMapperProvider()
return exceptionMapperProvider;
}

public void setExceptionMapperProvider(Supplier<IExceptionMapper> exceptionMapperProvider) {
public void setExceptionMapperProvider(@Nonnull Supplier<IExceptionMapper> exceptionMapperProvider) {
this.exceptionMapperProvider = Args.notNull(exceptionMapperProvider, "exceptionMapperProvider");
}

Expand All @@ -690,7 +693,7 @@ public final Supplier<ISessionStore> getSessionStoreProvider()
*
* @param sessionStoreProvider
*/
public final Application setSessionStoreProvider(final Supplier<ISessionStore> sessionStoreProvider)
public final Application setSessionStoreProvider(@Nonnull final Supplier<ISessionStore> sessionStoreProvider)
{
this.sessionStoreProvider = Args.notNull(sessionStoreProvider, "sessionStoreProvider");
this.sessionStore = null;
Expand Down Expand Up @@ -800,7 +803,7 @@ protected void validateInit()
* @param name
* unique application name
*/
public final void setName(final String name)
public final void setName(@Nonnull final String name)
{
Args.notEmpty(name, "name");

Expand Down Expand Up @@ -1392,7 +1395,7 @@ public final IPageRendererProvider getPageRendererProvider()
*
* @param pageRendererProvider
*/
public final Application setPageRendererProvider(final IPageRendererProvider pageRendererProvider)
public final Application setPageRendererProvider(@Nonnull final IPageRendererProvider pageRendererProvider)
{
Args.notNull(pageRendererProvider, "pageRendererProvider");
this.pageRendererProvider = pageRendererProvider;
Expand Down Expand Up @@ -1519,7 +1522,7 @@ protected IMapperContext newMapperContext()
* @param requestCycle
* @return Session
*/
public Session fetchCreateAndSetSession(final RequestCycle requestCycle)
public Session fetchCreateAndSetSession(@Nonnull final RequestCycle requestCycle)
{
Args.notNull(requestCycle, "requestCycle");

Expand Down
Loading