public class Value extends Object implements Supplier<String>
Supplier
of String
s and hence an abstraction of a
(definitionally) String
-typed setting
value, additionally encompassing the setting
name for which it is applicable and the Source
whence
it originated.Settings
,
Source
,
Source.getValue(String, Set)
Constructor and Description |
---|
Value(Source source,
String name,
Set<Annotation> qualifiers,
boolean authoritative,
String value)
Creates a new
Value . |
Value(Source source,
String name,
Set<Annotation> qualifiers,
boolean authoritative,
Supplier<? extends String> valueSupplier)
Creates a new
Value . |
Value(Source source,
String name,
Set<Annotation> qualifiers,
String value)
Creates a new
Value . |
Value(Source source,
String name,
Set<Annotation> qualifiers,
Supplier<? extends String> valueSupplier)
Creates a new
Value . |
Value(Value other)
Creates a new
Value . |
Value(Value other,
String value)
Creates a new
Value . |
Value(Value other,
Supplier<? extends String> valueSupplier)
Creates a new
Value . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
|
String |
get()
|
String |
getName()
Returns the name of the
setting for which this is a
Value . |
Set<Annotation> |
getQualifiers()
|
Source |
getSource()
|
int |
hashCode()
|
boolean |
isAuthoritative()
Returns
true if this Value is to be treated as
coming from an authoritative source. |
String |
toString()
|
public Value(Value other)
Value
.other
- the Value
to copy; must not be null
NullPointerException
- if other
is null
public Value(Value other, String value)
Value
.other
- the Value
to copy; must not be null
value
- the String
to be returned by the get()
method; may be null
NullPointerException
- if other
is null
public Value(Value other, Supplier<? extends String> valueSupplier)
Value
.other
- the Value
to copy; must not be null
valueSupplier
- a Supplier
of String
s whose
Supplier.get()
method will be called by this Value
's get()
method; may be null
; if
non-null
, must be safe for concurrent access by multiple
threadsNullPointerException
- if other
is null
public Value(Source source, String name, Set<Annotation> qualifiers, String value)
Value
.source
- the Source
that created this Value
;
may be null
to indicate that the Value
was
synthesizedname
- the name of the
setting for which this is a Value
; must not be null
qualifiers
- a Set
of Annotation
s qualifying
this Value
; may be null
; will be iterated over by
this constructor without any extra synchronization; will be
copied shallowly by this constructor if it is non-null
value
- the String
to be returned by the get()
method; may be null
NullPointerException
- if name
is null
public Value(Source source, String name, Set<Annotation> qualifiers, Supplier<? extends String> valueSupplier)
Value
.source
- the Source
that created this Value
;
may be null
to indicate that the Value
was
synthesizedname
- the name of the
setting for which this is a Value
; must not be null
qualifiers
- a Set
of Annotation
s qualifying
this Value
; may be null
; will be iterated over by
this constructor without any extra synchronization; will be
copied shallowly by this constructor if it is non-null
valueSupplier
- a Supplier
of String
s whose
Supplier.get()
method will be called by this Value
's get()
method; may be null
; if
non-null
, must be safe for concurrent access by multiple
threadsNullPointerException
- if name
is null
public Value(Source source, String name, Set<Annotation> qualifiers, boolean authoritative, String value)
Value
.source
- the Source
that created this Value
;
may be null
to indicate that the Value
was
synthesizedname
- the name of the
setting for which this is a Value
; must not be null
qualifiers
- a Set
of Annotation
s qualifying
this Value
; may be null
; will be iterated over by
this constructor without any extra synchronization; will be
copied shallowly by this constructor if it is non-null
authoritative
- whether this Value
is to be treated
as coming from an authoritative sourcevalue
- the String
to be returned by the get()
method; may be null
NullPointerException
- if name
is null
public Value(Source source, String name, Set<Annotation> qualifiers, boolean authoritative, Supplier<? extends String> valueSupplier)
Value
.source
- the Source
that created this Value
;
may be null
to indicate that the Value
was
synthesizedname
- the name of the
setting for which this is a Value
; must not be null
qualifiers
- a Set
of Annotation
s qualifying
this Value
; may be null
; will be iterated over by
this constructor without any extra synchronization; will be
copied shallowly by this constructor if it is non-null
authoritative
- whether this Value
is to be treated
as coming from an authoritative sourcevalueSupplier
- a Supplier
of String
s whose
Supplier.get()
method will be called by this Value
's get()
method; may be null
; if
non-null
, must be safe for concurrent access by multiple
threadsNullPointerException
- if name
is null
public final String get()
get
in interface Supplier<String>
String
representation of this Value
,
which may be null
null
.public final boolean isAuthoritative()
true
if this Value
is to be treated as
coming from an authoritative source.true
if this Value
is to be treated as
coming from an authoritative source; false
otherwisepublic final String getName()
Value
.Value
; never null
null
.public final Set<Annotation> getQualifiers()
null
, unmodifiable Set
of Annotation
s qualifying
this Value
null
.public int hashCode()
Value
based off the return
value of the get()
method and nothing else.
Note that because the return value of invocations of a Value
's get()
method can change over time, in general
Value
hashcodes should be treated with great care.
hashCode
in class Object
Value
equals(Object)
public boolean equals(Object other)
true
if the supplied Object
is a Value
and has a get()
method implementation that
returns a value equal to the return value of an invocation of
this Value
's get()
method.
Note that because the return value of invocations of a Value
's get()
method can change over time, in general
Value
equality comparisons should be treated with great
care.
equals
in class Object
other
- the Object
to compare; may be null
true
if the supplied Object
is a Value
and has a get()
method implementation that
returns a value equal to the return value of an invocation of
this Value
's get()
method; false
otherwisehashCode()
public String toString()
String
representation of this Value
as
of the current moment by returning the result of invoking the
get()
method.
This method may return null
.
toString
in class Object
String
representation of this Value
as
of the current moment, or null
get()
null
.Copyright © 2019–2020, microBean™. All rights reserved.