From 0669632a613994cfdeffecafc81078df851a211d Mon Sep 17 00:00:00 2001 From: Christoph Strobl Date: Tue, 22 Aug 2017 13:31:16 +0200 Subject: [PATCH] DATACMNS-1141 - Add missing NonNullApi and Nullable annotations. --- .../data/domain/Persistable.java | 10 +++++--- ...bstractRepositoryPopulatorFactoryBean.java | 24 +++++++++++++------ ...ackson2RepositoryPopulatorFactoryBean.java | 12 ++++++---- .../init/Jackson2ResourceReader.java | 19 +++++++++------ .../repository/init/RepositoryPopulator.java | 6 ++--- .../data/repository/init/ResourceReader.java | 17 ++++++++++--- .../ResourceReaderRepositoryPopulator.java | 19 +++++++++------ ...shallerRepositoryPopulatorFactoryBean.java | 9 ++++--- .../init/UnmarshallingResourceReader.java | 10 ++++++-- .../data/repository/init/package-info.java | 1 + .../repository/query/RepositoryQuery.java | 14 +++++++---- .../query/parser/AbstractQueryCreator.java | 24 +++++++++++-------- .../query/parser/OrderBySource.java | 8 +++---- .../repository/query/parser/PartTree.java | 10 ++++---- .../repository/query/parser/package-info.java | 2 +- .../repository/query/spi/package-info.java | 2 +- .../repository/reactive/package-info.java | 5 ++++ .../data/transaction/package-info.java | 1 + .../QuerydslPredicateArgumentResolver.java | 5 ++-- .../data/web/querydsl/package-info.java | 1 + 20 files changed, 132 insertions(+), 67 deletions(-) create mode 100644 src/main/java/org/springframework/data/repository/reactive/package-info.java diff --git a/src/main/java/org/springframework/data/domain/Persistable.java b/src/main/java/org/springframework/data/domain/Persistable.java index ca4d42172..c39dd91e6 100644 --- a/src/main/java/org/springframework/data/domain/Persistable.java +++ b/src/main/java/org/springframework/data/domain/Persistable.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2011 the original author or authors. + * Copyright 2008-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,25 +15,29 @@ */ package org.springframework.data.domain; +import org.springframework.lang.Nullable; + /** * Simple interface for entities. * * @param the type of the identifier * @author Oliver Gierke + * @author Christoph Strobl */ public interface Persistable { /** * Returns the id of the entity. * - * @return the id + * @return the id. Can be {@literal null}. */ + @Nullable ID getId(); /** * Returns if the {@code Persistable} is new or was persisted already. * - * @return if the object is new + * @return if {@literal true} the object is new. */ boolean isNew(); } diff --git a/src/main/java/org/springframework/data/repository/init/AbstractRepositoryPopulatorFactoryBean.java b/src/main/java/org/springframework/data/repository/init/AbstractRepositoryPopulatorFactoryBean.java index 9a83a1c0f..3e1c85832 100644 --- a/src/main/java/org/springframework/data/repository/init/AbstractRepositoryPopulatorFactoryBean.java +++ b/src/main/java/org/springframework/data/repository/init/AbstractRepositoryPopulatorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.core.io.Resource; import org.springframework.data.repository.support.Repositories; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -30,14 +31,15 @@ import org.springframework.util.Assert; * a {@link ResourceReader} to hand into the {@link RepositoryPopulator} instance created. * * @author Oliver Gierke + * @author Christoph Strobl */ -public abstract class AbstractRepositoryPopulatorFactoryBean extends - AbstractFactoryBean implements ApplicationListener, - ApplicationContextAware { +public abstract class AbstractRepositoryPopulatorFactoryBean + extends AbstractFactoryBean + implements ApplicationListener, ApplicationContextAware { - private Resource[] resources; - private RepositoryPopulator populator; - private ApplicationContext context; + private @Nullable Resource[] resources; + private @Nullable RepositoryPopulator populator; + private @Nullable ApplicationContext context; /** * Configures the {@link Resource}s to be used to load objects from and initialize the repositories eventually. @@ -45,6 +47,7 @@ public abstract class AbstractRepositoryPopulatorFactoryBean extends * @param resources must not be {@literal null}. */ public void setResources(Resource[] resources) { + Assert.notNull(resources, "Resources must not be null!"); this.resources = resources.clone(); } @@ -95,4 +98,11 @@ public abstract class AbstractRepositoryPopulatorFactoryBean extends } protected abstract ResourceReader getResourceReader(); + + @Override + public void afterPropertiesSet() throws Exception { + + Assert.state(resources != null, "Resources must not be null!"); + super.afterPropertiesSet(); + } } diff --git a/src/main/java/org/springframework/data/repository/init/Jackson2RepositoryPopulatorFactoryBean.java b/src/main/java/org/springframework/data/repository/init/Jackson2RepositoryPopulatorFactoryBean.java index 96eb8c112..4ae86d4e2 100644 --- a/src/main/java/org/springframework/data/repository/init/Jackson2RepositoryPopulatorFactoryBean.java +++ b/src/main/java/org/springframework/data/repository/init/Jackson2RepositoryPopulatorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.data.repository.init; import org.springframework.beans.factory.FactoryBean; +import org.springframework.lang.Nullable; import com.fasterxml.jackson.databind.ObjectMapper; @@ -23,18 +24,19 @@ import com.fasterxml.jackson.databind.ObjectMapper; * {@link FactoryBean} to set up a {@link ResourceReaderRepositoryPopulator} with a {@link Jackson2ResourceReader}. * * @author Oliver Gierke + * @author Christoph Strobl * @since 1.6 */ public class Jackson2RepositoryPopulatorFactoryBean extends AbstractRepositoryPopulatorFactoryBean { - private ObjectMapper mapper; + private @Nullable ObjectMapper mapper; /** * Configures the {@link ObjectMapper} to be used. - * - * @param mapper + * + * @param mapper can be {@literal null}. */ - public void setMapper(ObjectMapper mapper) { + public void setMapper(@Nullable ObjectMapper mapper) { this.mapper = mapper; } diff --git a/src/main/java/org/springframework/data/repository/init/Jackson2ResourceReader.java b/src/main/java/org/springframework/data/repository/init/Jackson2ResourceReader.java index 35966606e..fb59cb4b3 100644 --- a/src/main/java/org/springframework/data/repository/init/Jackson2ResourceReader.java +++ b/src/main/java/org/springframework/data/repository/init/Jackson2ResourceReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ import java.util.Iterator; import java.util.List; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import com.fasterxml.jackson.databind.JsonNode; @@ -33,6 +35,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; * A {@link ResourceReader} using Jackson to read JSON into objects. * * @author Oliver Gierke + * @author Christoph Strobl * @since 1.6 */ public class Jackson2ResourceReader implements ResourceReader { @@ -59,7 +62,7 @@ public class Jackson2ResourceReader implements ResourceReader { * * @param mapper */ - public Jackson2ResourceReader(ObjectMapper mapper) { + public Jackson2ResourceReader(@Nullable ObjectMapper mapper) { this.mapper = mapper == null ? DEFAULT_MAPPER : mapper; } @@ -69,15 +72,17 @@ public class Jackson2ResourceReader implements ResourceReader { * * @param typeKey */ - public void setTypeKey(String typeKey) { - this.typeKey = typeKey; + public void setTypeKey(@Nullable String typeKey) { + this.typeKey = typeKey == null ? DEFAULT_TYPE_KEY : typeKey; } /* * (non-Javadoc) * @see org.springframework.data.repository.init.ResourceReader#readFrom(org.springframework.core.io.Resource, java.lang.ClassLoader) */ - public Object readFrom(Resource resource, ClassLoader classLoader) throws Exception { + public Object readFrom(Resource resource, @Nullable ClassLoader classLoader) throws Exception { + + Assert.notNull(resource, "Resource must not be null!"); InputStream stream = resource.getInputStream(); JsonNode node = mapper.readerFor(JsonNode.class).readTree(stream); @@ -102,10 +107,10 @@ public class Jackson2ResourceReader implements ResourceReader { * Reads the given {@link JsonNode} into an instance of the type encoded in it using the configured type key. * * @param node must not be {@literal null}. - * @param classLoader + * @param classLoader can be {@literal null}. * @return */ - private Object readSingle(JsonNode node, ClassLoader classLoader) throws IOException { + private Object readSingle(JsonNode node, @Nullable ClassLoader classLoader) throws IOException { JsonNode typeNode = node.findValue(typeKey); diff --git a/src/main/java/org/springframework/data/repository/init/RepositoryPopulator.java b/src/main/java/org/springframework/data/repository/init/RepositoryPopulator.java index 252e15534..b654dd362 100644 --- a/src/main/java/org/springframework/data/repository/init/RepositoryPopulator.java +++ b/src/main/java/org/springframework/data/repository/init/RepositoryPopulator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ public interface RepositoryPopulator { /** * Populates the given {@link Repositories}. - * - * @param repositories + * + * @param repositories must not be {@literal null}. */ void populate(Repositories repositories); } diff --git a/src/main/java/org/springframework/data/repository/init/ResourceReader.java b/src/main/java/org/springframework/data/repository/init/ResourceReader.java index acb892d7b..05bf29bcf 100644 --- a/src/main/java/org/springframework/data/repository/init/ResourceReader.java +++ b/src/main/java/org/springframework/data/repository/init/ResourceReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,26 @@ package org.springframework.data.repository.init; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; /** * @author Oliver Gierke + * @author Christoph Strobl */ public interface ResourceReader { - public static enum Type { + enum Type { XML, JSON; } - Object readFrom(Resource resource, ClassLoader classLoader) throws Exception; + /** + * Reads a single or {@link java.util.Collection} of target objects from the given {@link Resource}. + * + * @param resource must not be {@literal null}. + * @param classLoader can be {@literal null}. + * @return {@link java.util.Collection} of target objects if resource contains multiple ones of single on. Never + * {@literal null}. + * @throws Exception + */ + Object readFrom(Resource resource, @Nullable ClassLoader classLoader) throws Exception; } diff --git a/src/main/java/org/springframework/data/repository/init/ResourceReaderRepositoryPopulator.java b/src/main/java/org/springframework/data/repository/init/ResourceReaderRepositoryPopulator.java index 7ee3ec4ff..7c42ed950 100644 --- a/src/main/java/org/springframework/data/repository/init/ResourceReaderRepositoryPopulator.java +++ b/src/main/java/org/springframework/data/repository/init/ResourceReaderRepositoryPopulator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.data.repository.init; import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,12 +31,14 @@ import org.springframework.data.repository.support.DefaultRepositoryInvokerFacto import org.springframework.data.repository.support.Repositories; import org.springframework.data.repository.support.RepositoryInvoker; import org.springframework.data.repository.support.RepositoryInvokerFactory; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** * A {@link RepositoryPopulator} using a {@link ResourceReader} to read objects from the configured {@link Resource}s. * * @author Oliver Gierke + * @author Christoph Strobl * @since 1.4 */ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, ApplicationEventPublisherAware { @@ -46,8 +49,8 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A private final ResourceReader reader; private final ClassLoader classLoader; - private ApplicationEventPublisher publisher; - private Collection resources; + private @Nullable ApplicationEventPublisher publisher; + private Collection resources = Collections.emptySet(); /** * Creates a new {@link ResourceReaderRepositoryPopulator} using the given {@link ResourceReader}. @@ -63,9 +66,9 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A * {@link ClassLoader}. * * @param reader must not be {@literal null}. - * @param classLoader + * @param classLoader can be {@literal null}. */ - public ResourceReaderRepositoryPopulator(ResourceReader reader, ClassLoader classLoader) { + public ResourceReaderRepositoryPopulator(ResourceReader reader, @Nullable ClassLoader classLoader) { Assert.notNull(reader, "Reader must not be null!"); @@ -99,7 +102,7 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A * (non-Javadoc) * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) */ - public void setApplicationEventPublisher(ApplicationEventPublisher publisher) { + public void setApplicationEventPublisher(@Nullable ApplicationEventPublisher publisher) { this.publisher = publisher; } @@ -109,6 +112,8 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A */ public void populate(Repositories repositories) { + Assert.notNull(repositories, "Repositories must not be null!"); + RepositoryInvokerFactory invokerFactory = new DefaultRepositoryInvokerFactory(repositories); for (Resource resource : resources) { @@ -153,7 +158,7 @@ public class ResourceReaderRepositoryPopulator implements RepositoryPopulator, A * Persists the given {@link Object} using a suitable repository. * * @param object must not be {@literal null}. - * @param repositories must not be {@literal null}. + * @param invokerFactory must not be {@literal null}. */ private void persist(Object object, RepositoryInvokerFactory invokerFactory) { diff --git a/src/main/java/org/springframework/data/repository/init/UnmarshallerRepositoryPopulatorFactoryBean.java b/src/main/java/org/springframework/data/repository/init/UnmarshallerRepositoryPopulatorFactoryBean.java index 0307c66d3..afb50223d 100644 --- a/src/main/java/org/springframework/data/repository/init/UnmarshallerRepositoryPopulatorFactoryBean.java +++ b/src/main/java/org/springframework/data/repository/init/UnmarshallerRepositoryPopulatorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.data.repository.init; import org.springframework.beans.factory.FactoryBean; +import org.springframework.lang.Nullable; import org.springframework.oxm.Unmarshaller; import org.springframework.util.Assert; @@ -23,10 +24,11 @@ import org.springframework.util.Assert; * {@link FactoryBean} to create a {@link ResourceReaderRepositoryPopulator} using an {@link Unmarshaller}. * * @author Oliver Gierke + * @author Christoph Strobl */ public class UnmarshallerRepositoryPopulatorFactoryBean extends AbstractRepositoryPopulatorFactoryBean { - private Unmarshaller unmarshaller; + private @Nullable Unmarshaller unmarshaller; /** * Configures the {@link Unmarshaller} to be used. @@ -51,7 +53,8 @@ public class UnmarshallerRepositoryPopulatorFactoryBean extends AbstractReposito */ @Override public void afterPropertiesSet() throws Exception { - Assert.notNull(unmarshaller, "No Unmarshaller configured!"); + + Assert.state(unmarshaller != null, "No Unmarshaller configured!"); super.afterPropertiesSet(); } } diff --git a/src/main/java/org/springframework/data/repository/init/UnmarshallingResourceReader.java b/src/main/java/org/springframework/data/repository/init/UnmarshallingResourceReader.java index b6d8d3d2f..f0ad13eb5 100644 --- a/src/main/java/org/springframework/data/repository/init/UnmarshallingResourceReader.java +++ b/src/main/java/org/springframework/data/repository/init/UnmarshallingResourceReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,13 @@ import java.io.IOException; import javax.xml.transform.stream.StreamSource; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.oxm.Unmarshaller; +import org.springframework.util.Assert; /** * @author Oliver Gierke + * @author Christoph Strobl */ public class UnmarshallingResourceReader implements ResourceReader { @@ -40,7 +43,10 @@ public class UnmarshallingResourceReader implements ResourceReader { * (non-Javadoc) * @see org.springframework.data.repository.init.ResourceReader#readFrom(org.springframework.core.io.Resource, java.lang.ClassLoader) */ - public Object readFrom(Resource resource, ClassLoader classLoader) throws IOException { + public Object readFrom(Resource resource, @Nullable ClassLoader classLoader) throws IOException { + + Assert.notNull(resource, "Resource must not be null!"); + StreamSource source = new StreamSource(resource.getInputStream()); return unmarshaller.unmarshal(source); } diff --git a/src/main/java/org/springframework/data/repository/init/package-info.java b/src/main/java/org/springframework/data/repository/init/package-info.java index 98011b158..d0122ce0a 100644 --- a/src/main/java/org/springframework/data/repository/init/package-info.java +++ b/src/main/java/org/springframework/data/repository/init/package-info.java @@ -1,4 +1,5 @@ /** * Support for repository initialization using XML and JSON. */ +@org.springframework.lang.NonNullApi package org.springframework.data.repository.init; \ No newline at end of file diff --git a/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java b/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java index 649acfda1..46a300c54 100644 --- a/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java +++ b/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,25 +15,29 @@ */ package org.springframework.data.repository.query; +import org.springframework.lang.Nullable; + /** * Interface for a query abstraction. * * @author Oliver Gierke + * @author Christoph Strobl */ public interface RepositoryQuery { /** * Executes the {@link RepositoryQuery} with the given parameters. * - * @param parameters - * @return + * @param parameters must not be {@literal null}. + * @return execution result. Can be {@literal null}. */ + @Nullable Object execute(Object[] parameters); /** - * Returns the + * Returns the related {@link QueryMethod}. * - * @return + * @return never {@literal null}. */ QueryMethod getQueryMethod(); } diff --git a/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java b/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java index 03407c4dc..a10a3a029 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java +++ b/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java @@ -15,6 +15,7 @@ */ package org.springframework.data.repository.query.parser; +import java.util.Collections; import java.util.Iterator; import java.util.Optional; @@ -31,6 +32,7 @@ import org.springframework.util.Assert; * @param the intermediate criteria type * @author Oliver Gierke * @author Mark Paluch + * @author Christoph Strobl */ public abstract class AbstractQueryCreator { @@ -83,10 +85,12 @@ public abstract class AbstractQueryCreator { * Creates the actual query object applying the given {@link Sort} parameter. Use this method in case you haven't * provided a {@link ParameterAccessor} in the first place but want to apply dynamic sorting nevertheless. * - * @param dynamicSort + * @param dynamicSort must not be {@literal null}. * @return */ public T createQuery(Sort dynamicSort) { + + Assert.notNull(dynamicSort, "DynamicSort must not be null!"); return complete(createCriteria(tree), tree.getSort().and(dynamicSort)); } @@ -94,13 +98,13 @@ public abstract class AbstractQueryCreator { * Actual query building logic. Traverses the {@link PartTree} and invokes callback methods to delegate actual * criteria creation and concatenation. * - * @param tree + * @param tree must not be {@literal null}. * @return */ private S createCriteria(PartTree tree) { S base = null; - Iterator iterator = parameters.map(ParameterAccessor::iterator).orElse(null); + Iterator iterator = parameters.map(ParameterAccessor::iterator).orElse(Collections.emptyIterator()); for (OrPart node : tree) { @@ -120,8 +124,8 @@ public abstract class AbstractQueryCreator { /** * Creates a new atomic instance of the criteria object. * - * @param part - * @param iterator + * @param part must not be {@literal null}. + * @param iterator must not be {@literal null}. * @return */ protected abstract S create(Part part, Iterator iterator); @@ -129,9 +133,9 @@ public abstract class AbstractQueryCreator { /** * Creates a new criteria object from the given part and and-concatenates it to the given base criteria. * - * @param part + * @param part must not be {@literal null}. * @param base will never be {@literal null}. - * @param iterator + * @param iterator must not be {@literal null}. * @return */ protected abstract S and(Part part, S base, Iterator iterator); @@ -139,8 +143,8 @@ public abstract class AbstractQueryCreator { /** * Or-concatenates the given base criteria to the given new criteria. * - * @param base - * @param criteria + * @param base must not be {@literal null}. + * @param criteria must not be {@literal null}. * @return */ protected abstract S or(S base, S criteria); @@ -149,7 +153,7 @@ public abstract class AbstractQueryCreator { * Actually creates the query object applying the given criteria object and {@link Sort} definition. * * @param criteria will never be {@literal null}. - * @param sort might be {@literal null}. + * @param sort must not be {@literal null}. * @return */ protected abstract T complete(S criteria, Sort sort); diff --git a/src/main/java/org/springframework/data/repository/query/parser/OrderBySource.java b/src/main/java/org/springframework/data/repository/query/parser/OrderBySource.java index 38b7d8458..cbc129f04 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/OrderBySource.java +++ b/src/main/java/org/springframework/data/repository/query/parser/OrderBySource.java @@ -56,7 +56,7 @@ class OrderBySource { * * @param clause must not be {@literal null}. */ - public OrderBySource(String clause) { + OrderBySource(String clause) { this(clause, Optional.empty()); } @@ -67,7 +67,7 @@ class OrderBySource { * @param clause must not be {@literal null}. * @param domainClass must not be {@literal null}. */ - public OrderBySource(String clause, Optional> domainClass) { + OrderBySource(String clause, Optional> domainClass) { this.orders = new ArrayList<>(); @@ -100,8 +100,8 @@ class OrderBySource { * is given, we will use it for nested property traversal checks. * * @param propertySource - * @param direction - * @param domainClass can be {@literal null}. + * @param direction must not be {@literal null}. + * @param domainClass must not be {@literal null}. * @return * @see PropertyPath#from(String, Class) */ diff --git a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java index 65587ad4d..7eb927a41 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/PartTree.java +++ b/src/main/java/org/springframework/data/repository/query/parser/PartTree.java @@ -29,6 +29,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.repository.query.parser.Part.Type; import org.springframework.data.repository.query.parser.PartTree.OrPart; import org.springframework.data.util.Streamable; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -105,9 +106,9 @@ public class PartTree implements Streamable { } /** - * Returns the {@link Sort} specification parsed from the source or null. - * - * @return the sort + * Returns the {@link Sort} specification parsed from the source. + * + * @return never {@literal null}. */ public Sort getSort() { return predicate.getOrderBySource().toSort(); @@ -164,9 +165,10 @@ public class PartTree implements Streamable { /** * Return the number of maximal results to return or {@literal null} if not restricted. * - * @return + * @return {@literal null} if not restricted. * @since 1.9 */ + @Nullable public Integer getMaxResults() { return subject.getMaxResults().orElse(null); } diff --git a/src/main/java/org/springframework/data/repository/query/parser/package-info.java b/src/main/java/org/springframework/data/repository/query/parser/package-info.java index 1449ffd7c..a2db23ab7 100644 --- a/src/main/java/org/springframework/data/repository/query/parser/package-info.java +++ b/src/main/java/org/springframework/data/repository/query/parser/package-info.java @@ -1,5 +1,5 @@ /** * Support classes for parsing queries from method names. */ +@org.springframework.lang.NonNullApi package org.springframework.data.repository.query.parser; - diff --git a/src/main/java/org/springframework/data/repository/query/spi/package-info.java b/src/main/java/org/springframework/data/repository/query/spi/package-info.java index 78d4d841d..0550c1c2f 100644 --- a/src/main/java/org/springframework/data/repository/query/spi/package-info.java +++ b/src/main/java/org/springframework/data/repository/query/spi/package-info.java @@ -1,5 +1,5 @@ /** * Service provider interfaces to extend the query execution mechanism. */ +@org.springframework.lang.NonNullApi package org.springframework.data.repository.query.spi; - diff --git a/src/main/java/org/springframework/data/repository/reactive/package-info.java b/src/main/java/org/springframework/data/repository/reactive/package-info.java new file mode 100644 index 000000000..8b110b5dc --- /dev/null +++ b/src/main/java/org/springframework/data/repository/reactive/package-info.java @@ -0,0 +1,5 @@ +/** + * Support for reactive repository. + */ +@org.springframework.lang.NonNullApi +package org.springframework.data.repository.reactive; diff --git a/src/main/java/org/springframework/data/transaction/package-info.java b/src/main/java/org/springframework/data/transaction/package-info.java index be8e155a3..ccda5af06 100644 --- a/src/main/java/org/springframework/data/transaction/package-info.java +++ b/src/main/java/org/springframework/data/transaction/package-info.java @@ -3,4 +3,5 @@ * * @see org.springframework.data.transaction.ChainedTransactionManager */ +@org.springframework.lang.NonNullApi package org.springframework.data.transaction; \ No newline at end of file diff --git a/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java b/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java index 778804da9..fe97d48d1 100644 --- a/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolver.java @@ -30,6 +30,7 @@ import org.springframework.data.querydsl.binding.QuerydslPredicateBuilder; import org.springframework.data.util.CastUtils; import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.TypeInformation; +import org.springframework.lang.Nullable; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.support.WebDataBinderFactory; @@ -90,8 +91,8 @@ public class QuerydslPredicateArgumentResolver implements HandlerMethodArgumentR * @see org.springframework.web.method.support.HandlerMethodArgumentResolver#resolveArgument(org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.bind.support.WebDataBinderFactory) */ @Override - public Predicate resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { + public Predicate resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception { MultiValueMap parameters = new LinkedMultiValueMap<>(); diff --git a/src/main/java/org/springframework/data/web/querydsl/package-info.java b/src/main/java/org/springframework/data/web/querydsl/package-info.java index 71c09b26b..2d7e9c9d9 100644 --- a/src/main/java/org/springframework/data/web/querydsl/package-info.java +++ b/src/main/java/org/springframework/data/web/querydsl/package-info.java @@ -1,4 +1,5 @@ /** * Querydsl-specific web support. */ +@org.springframework.lang.NonNullApi package org.springframework.data.web.querydsl;