Class RedisPassword
java.lang.Object
org.springframework.data.redis.connection.RedisPassword
Value object which may or may not contain a Redis password.
If a password is present, isPresent() will return true and get() will return the value.
The password is stored as character array.
- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptionbooleanchar[]get()Return the password value if present.inthashCode()booleanReturntrueif there is a password present, otherwisefalse.<R> Optional<R>static RedisPasswordnone()Create an absentRedisPassword.static RedisPasswordof(char[] passwordAsChars) Create aRedisPasswordfrom achararray.static RedisPasswordCreate aRedisPasswordfrom aString.Optional<char[]>Adopt the password toOptionalcontaining the password value.toString()
-
Method Details
-
of
Create aRedisPasswordfrom aString.- Parameters:
passwordAsString- the password as string.- Returns:
- the
RedisPasswordforpasswordAsString.
-
of
Create aRedisPasswordfrom achararray.- Parameters:
passwordAsChars- the password as char array.- Returns:
- the
RedisPasswordforpasswordAsChars.
-
none
Create an absentRedisPassword.- Returns:
- the absent
RedisPassword.
-
isPresent
public boolean isPresent()Returntrueif there is a password present, otherwisefalse.- Returns:
trueif there is a password present, otherwisefalse
-
get
Return the password value if present. ThrowsNoSuchElementExceptionif the password is absent.- Returns:
- the password.
- Throws:
NoSuchElementException- if the password is absent.
-
map
Map the password using aFunctionand return aOptionalcontaining the mapped value.Absent passwords return a
Optional.empty().- Parameters:
mapper- must not be null.- Returns:
- the mapped result.
-
toOptional
Adopt the password toOptionalcontaining the password value.Absent passwords return a
Optional.empty().- Returns:
- the
Optionalcontaining the password value.
-
toString
-
equals
-
hashCode
public int hashCode()
-