@@ -502,6 +502,7 @@ public <S extends T, R> R findBy(Specification<T> spec, Function<FetchableFluent
502502 return doFindBy (spec , getDomainClass (), queryFunction );
503503 }
504504
505+ @ SuppressWarnings ("unchecked" )
505506 private <S extends T , R > R doFindBy (Specification <T > spec , Class <T > domainClass ,
506507 Function <FetchableFluentQuery <S >, R > queryFunction ) {
507508
@@ -593,6 +594,7 @@ public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
593594 }
594595
595596 @ Override
597+ @ SuppressWarnings ("unchecked" )
596598 public <S extends T , R > R findBy (Example <S > example , Function <FetchableFluentQuery <S >, R > queryFunction ) {
597599
598600 Assert .notNull (example , "Example must not be null" );
@@ -615,7 +617,7 @@ public long count() {
615617 }
616618
617619 @ Override
618- public long count (@ Nullable Specification <T > spec ) {
620+ public long count (Specification <T > spec ) {
619621 return executeCountQuery (getCountQuery (spec , getDomainClass ()));
620622 }
621623
@@ -684,7 +686,7 @@ public void flush() {
684686 * @deprecated use {@link #readPage(TypedQuery, Class, Pageable, Specification)} instead
685687 */
686688 @ Deprecated
687- protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , @ Nullable Specification <T > spec ) {
689+ protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , Specification <T > spec ) {
688690 return readPage (query , getDomainClass (), pageable , spec );
689691 }
690692
@@ -694,11 +696,13 @@ protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, @Nullable Spe
694696 *
695697 * @param query must not be {@literal null}.
696698 * @param domainClass must not be {@literal null}.
697- * @param spec can be {@literal null}.
699+ * @param spec must not be {@literal null}.
698700 * @param pageable can be {@literal null}.
699701 */
700702 protected <S extends T > Page <S > readPage (TypedQuery <S > query , final Class <S > domainClass , Pageable pageable ,
701- @ Nullable Specification <S > spec ) {
703+ Specification <S > spec ) {
704+
705+ Assert .notNull (spec , "Specification must not be null" );
702706
703707 if (pageable .isPaged ()) {
704708 query .setFirstResult (PageableUtils .getOffsetAsInteger (pageable ));
@@ -712,22 +716,22 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> dom
712716 /**
713717 * Creates a new {@link TypedQuery} from the given {@link Specification}.
714718 *
715- * @param spec can be {@literal null}.
719+ * @param spec must not be {@literal null}.
716720 * @param pageable must not be {@literal null}.
717721 */
718- protected TypedQuery <T > getQuery (@ Nullable Specification <T > spec , Pageable pageable ) {
722+ protected TypedQuery <T > getQuery (Specification <T > spec , Pageable pageable ) {
719723
720724 return getQuery (spec , getDomainClass (), pageable .getSort ());
721725 }
722726
723727 /**
724728 * Creates a new {@link TypedQuery} from the given {@link Specification}.
725729 *
726- * @param spec can be {@literal null}.
730+ * @param spec must not be {@literal null}.
727731 * @param domainClass must not be {@literal null}.
728732 * @param pageable must not be {@literal null}.
729733 */
730- protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass ,
734+ protected <S extends T > TypedQuery <S > getQuery (Specification <S > spec , Class <S > domainClass ,
731735 Pageable pageable ) {
732736
733737 return getQuery (spec , domainClass , pageable .getSort ());
@@ -806,21 +810,23 @@ protected <S> Query getDelete(DeleteSpecification<S> spec, Class<S> domainClass)
806810 /**
807811 * Creates a new count query for the given {@link Specification}.
808812 *
809- * @param spec can be {@literal null}.
813+ * @param spec must not be {@literal null}.
810814 * @deprecated override {@link #getCountQuery(Specification, Class)} instead
811815 */
812816 @ Deprecated
813- protected TypedQuery <Long > getCountQuery (@ Nullable Specification <T > spec ) {
817+ protected TypedQuery <Long > getCountQuery (Specification <T > spec ) {
814818 return getCountQuery (spec , getDomainClass ());
815819 }
816820
817821 /**
818822 * Creates a new count query for the given {@link Specification}.
819823 *
820- * @param spec can be {@literal null}.
824+ * @param spec must not be {@literal null}.
821825 * @param domainClass must not be {@literal null}.
822826 */
823- protected <S extends T > TypedQuery <Long > getCountQuery (@ Nullable Specification <S > spec , Class <S > domainClass ) {
827+ protected <S extends T > TypedQuery <Long > getCountQuery (Specification <S > spec , Class <S > domainClass ) {
828+
829+ Assert .notNull (spec , "Specification must not be null" );
824830
825831 CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
826832 CriteriaQuery <Long > query = builder .createQuery (Long .class );
@@ -970,7 +976,7 @@ private Map<String, Object> getHints() {
970976 private void applyComment (CrudMethodMetadata metadata , BiConsumer <String , Object > consumer ) {
971977
972978 if (metadata .getComment () != null && provider .getCommentHintKey () != null ) {
973- consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (this . metadata .getComment ()));
979+ consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (metadata .getComment ()));
974980 }
975981 }
976982
0 commit comments