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 TypeMethodDescriptionboolean
char[]
get()
Return the password value if present.int
hashCode()
boolean
Returntrue
if there is a password present, otherwisefalse
.<R> Optional<R>
static RedisPassword
none()
Create an absentRedisPassword
.static RedisPassword
of
(char[] passwordAsChars) Create aRedisPassword
from achar
array.static RedisPassword
Create aRedisPassword
from aString
.Optional<char[]>
Adopt the password toOptional
containing the password value.toString()
-
Method Details
-
of
Create aRedisPassword
from aString
.- Parameters:
passwordAsString
- the password as string.- Returns:
- the
RedisPassword
forpasswordAsString
.
-
of
Create aRedisPassword
from achar
array.- Parameters:
passwordAsChars
- the password as char array.- Returns:
- the
RedisPassword
forpasswordAsChars
.
-
none
Create an absentRedisPassword
.- Returns:
- the absent
RedisPassword
.
-
isPresent
public boolean isPresent()Returntrue
if there is a password present, otherwisefalse
.- Returns:
true
if there is a password present, otherwisefalse
-
get
Return the password value if present. ThrowsNoSuchElementException
if the password is absent.- Returns:
- the password.
- Throws:
NoSuchElementException
- if the password is absent.
-
map
Map the password using aFunction
and return aOptional
containing the mapped value.Absent passwords return a
Optional.empty()
.- Parameters:
mapper
- must not be null.- Returns:
- the mapped result.
-
toOptional
Adopt the password toOptional
containing the password value.Absent passwords return a
Optional.empty()
.- Returns:
- the
Optional
containing the password value.
-
toString
-
equals
-
hashCode
public int hashCode()
-