DATACMNS-1114 - Introduced usage of nullable annotations for API validation.
Marked all packages with Spring Frameworks @NonNullApi. Added Spring's @Nullable to methods, parameters and fields that take or produce null values. Adapted using code to make sure the IDE can evaluate the null flow properly. Fixed Javadoc in places where an invalid null handling policy was advertised. Strengthened null requirements for types that expose null-instances. Removed null handling from converters for JodaTime and ThreeTenBP. Introduced factory methods Page.empty() and Page.empty(Pageable). Introduced default methods getRequiredGetter(), …Setter() and …Field() on PersistentProperty to allow non-nullable lookups of members. The same for TypeInformation.getrequiredActualType(), …SuperTypeInformation(). Tweaked PersistentPropertyCreator.addPropertiesForRemainingDescriptors() to filter unsuitable PropertyDescriptors before actually trying to create a Property instance from them as the new stronger nullability requirements would cause exceptions downstream. Lazy.get() now expects a non-null return value. Clients being able to cope with null need to call ….orElse(…). Original pull request: #232.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.authentication;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -28,8 +29,7 @@ public class UserCredentials {
|
||||
|
||||
public static final UserCredentials NO_CREDENTIALS = new UserCredentials(null, null);
|
||||
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final @Nullable String username, password;
|
||||
|
||||
/**
|
||||
* Creates a new {@link UserCredentials} instance from the given username and password. Empty {@link String}s provided
|
||||
@@ -38,7 +38,7 @@ public class UserCredentials {
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
public UserCredentials(String username, String password) {
|
||||
public UserCredentials(@Nullable String username, @Nullable String password) {
|
||||
this.username = StringUtils.hasText(username) ? username : null;
|
||||
this.password = StringUtils.hasText(password) ? password : null;
|
||||
}
|
||||
@@ -48,6 +48,7 @@ public class UserCredentials {
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
@Nullable
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
@@ -57,6 +58,7 @@ public class UserCredentials {
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
@Nullable
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
@@ -85,9 +87,12 @@ public class UserCredentials {
|
||||
*
|
||||
* @return the obfuscated password
|
||||
*/
|
||||
@Nullable
|
||||
public String getObfuscatedPassword() {
|
||||
|
||||
if (!hasPassword()) {
|
||||
String password = this.password;
|
||||
|
||||
if (password == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -125,7 +130,7 @@ public class UserCredentials {
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
|
||||
if (obj == this) {
|
||||
return true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* Types to abstract authentication concepts.
|
||||
*/
|
||||
package org.springframework.data.authentication;
|
||||
@org.springframework.lang.NonNullApi
|
||||
package org.springframework.data.authentication;
|
||||
|
||||
Reference in New Issue
Block a user