Skip to content

Commit 87566df

Browse files
committed
DATACMNS-858 - Polishing.
Some JavaDoc and formatting.
1 parent c51f553 commit 87566df

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/main/java/org/springframework/data/repository/core/support/DefaultCrudMethods.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2014 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
1515
*/
1616
package org.springframework.data.repository.core.support;
1717

18+
import static java.util.Arrays.*;
1819
import static org.springframework.util.ClassUtils.*;
1920
import static org.springframework.util.ReflectionUtils.*;
2021

2122
import java.io.Serializable;
2223
import java.lang.reflect.Method;
23-
import java.util.Arrays;
2424

2525
import org.springframework.data.domain.Pageable;
2626
import org.springframework.data.domain.Sort;
@@ -72,7 +72,7 @@ public DefaultCrudMethods(RepositoryMetadata metadata) {
7272
* The most suitable save method is selected as follows: We prefer
7373
* <ol>
7474
* <li>a {@link RepositoryMetadata#getDomainType()} as first parameter over</li>
75-
* <li>an {@link Object} as first parameter</li>
75+
* <li>an {@link Object} as first parameter.</li>
7676
* </ol>
7777
*
7878
* @param metadata must not be {@literal null}.
@@ -81,8 +81,10 @@ public DefaultCrudMethods(RepositoryMetadata metadata) {
8181
@SuppressWarnings("unchecked")
8282
private Method selectMostSuitableSaveMethod(RepositoryMetadata metadata) {
8383

84-
for (Class<?> type : Arrays.asList(metadata.getDomainType(), Object.class)) {
84+
for (Class<?> type : asList(metadata.getDomainType(), Object.class)) {
85+
8586
Method saveMethodCandidate = findMethod(metadata.getRepositoryInterface(), SAVE, type);
87+
8688
if (saveMethodCandidate != null) {
8789
return getMostSpecificMethod(saveMethodCandidate, metadata.getRepositoryInterface());
8890
}
@@ -106,9 +108,10 @@ private Method selectMostSuitableSaveMethod(RepositoryMetadata metadata) {
106108
@SuppressWarnings("unchecked")
107109
private Method selectMostSuitableDeleteMethod(RepositoryMetadata metadata) {
108110

109-
for (Class<?> type : Arrays.asList(metadata.getDomainType(), metadata.getIdType(), Serializable.class,
110-
Iterable.class)) {
111+
for (Class<?> type : asList(metadata.getDomainType(), metadata.getIdType(), Serializable.class, Iterable.class)) {
112+
111113
Method candidate = findMethod(metadata.getRepositoryInterface(), DELETE, type);
114+
112115
if (candidate != null) {
113116
return getMostSpecificMethod(candidate, metadata.getRepositoryInterface());
114117
}
@@ -122,7 +125,7 @@ private Method selectMostSuitableDeleteMethod(RepositoryMetadata metadata) {
122125
* <ol>
123126
* <li>a {@link Pageable} as first parameter over</li>
124127
* <li>a {@link Sort} as first parameter over</li>
125-
* <li>no parameters</li>
128+
* <li>no parameters.</li>
126129
* </ol>
127130
*
128131
* @param metadata must not be {@literal null}.
@@ -131,9 +134,12 @@ private Method selectMostSuitableDeleteMethod(RepositoryMetadata metadata) {
131134
@SuppressWarnings("unchecked")
132135
private Method selectMostSuitableFindAllMethod(RepositoryMetadata metadata) {
133136

134-
for (Class<?> type : Arrays.asList(Pageable.class, Sort.class)) {
137+
for (Class<?> type : asList(Pageable.class, Sort.class)) {
138+
135139
if (hasMethod(metadata.getRepositoryInterface(), FIND_ALL, type)) {
140+
136141
Method candidate = findMethod(PagingAndSortingRepository.class, FIND_ALL, type);
142+
137143
if (candidate != null) {
138144
return getMostSpecificMethod(candidate, metadata.getRepositoryInterface());
139145
}
@@ -160,8 +166,10 @@ private Method selectMostSuitableFindAllMethod(RepositoryMetadata metadata) {
160166
@SuppressWarnings("unchecked")
161167
private Method selectMostSuitableFindOneMethod(RepositoryMetadata metadata) {
162168

163-
for (Class<?> type : Arrays.asList(metadata.getIdType(), Serializable.class)) {
169+
for (Class<?> type : asList(metadata.getIdType(), Serializable.class)) {
170+
164171
Method candidate = findMethod(metadata.getRepositoryInterface(), FIND_ONE, type);
172+
165173
if (candidate != null) {
166174
return getMostSpecificMethod(candidate, metadata.getRepositoryInterface());
167175
}

0 commit comments

Comments
 (0)