Class BasicStatusLine
- All Implemented Interfaces:
StatusLine
- Direct Known Subclasses:
BasicStatusLine.Unmodifiable
StatusLine interface.
Immutability is expressed with the "funnel + nested Unmodifiable snapshot" paradigm: every mutator routes
through the single protected modify(Runnable) choke-point, and unmodifiable() returns a
point-in-time snapshot of type BasicStatusLine.Unmodifiable whose modify(...) override throws.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn unmodifiable point-in-time snapshot of aBasicStatusLine. -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.protectedBasicStatusLine(BasicStatusLine copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a copy of this bean.static BasicStatusLinecreate()Instantiates a new instance of this bean.static BasicStatusLineInstantiates a new instance of this bean.booleanprotected voidfreeze()Deep-freeze hook invoked from theBasicStatusLine.Unmodifiableconstructor after the snapshot copy completes.Returns the locale of this status line.intinthashCode()booleanReturns whether this bean is unmodifiable.protected BasicStatusLineSingle mutation funnel — the only choke-point through which all state changes on this bean flow.Sets the locale used to retrieve reason phrases.Sets the protocol version on the status line.setReasonPhrase(String value) Sets the reason phrase on the status line.Sets the reason phrase catalog used to retrieve reason phrases.setStatusCode(int value) Sets the status code on the status line.toString()Returns an unmodifiable snapshot of this bean.
-
Constructor Details
-
BasicStatusLine
public BasicStatusLine()Constructor. -
BasicStatusLine
Copy constructor.- Parameters:
copyFrom- The status line being copied. Must not benull .
-
-
Method Details
-
create
Instantiates a new instance of this bean.- Returns:
- A new bean.
-
create
Instantiates a new instance of this bean.- Parameters:
statusCode- The initial status code.reasonPhrase- The initial reason phrase. Can benull to look up the reason phrase from the reason phrase catalog.- Returns:
- A new bean.
-
copy
Returns a copy of this bean.- Returns:
- A copy of this bean.
-
getLocale
Returns the locale of this status line.- Returns:
- The locale of this status line.
-
getProtocolVersion
- Specified by:
getProtocolVersionin interfaceStatusLine
-
getReasonPhrase
- Specified by:
getReasonPhrasein interfaceStatusLine
-
getStatusCode
- Specified by:
getStatusCodein interfaceStatusLine
-
setLocale
Sets the locale used to retrieve reason phrases.If not specified, uses
Locale.getDefault().- Parameters:
value- The new value.- Returns:
- This object.
-
setProtocolVersion
Sets the protocol version on the status line.If not specified,
"HTTP/1.1" will be used.- Parameters:
value- The new value.- Returns:
- This object.
-
setReasonPhrase
Sets the reason phrase on the status line.If not specified, the reason phrase will be retrieved from the reason phrase catalog using the locale on this bean.
- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
setReasonPhraseCatalog
Sets the reason phrase catalog used to retrieve reason phrases.If not specified, uses
EnglishReasonPhraseCatalog.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
setStatusCode
Sets the status code on the status line.If not specified,
0 will be used.- Parameters:
value- The new value.- Returns:
- This object.
-
unmodifiable
Returns an unmodifiable snapshot of this bean.The returned instance is a point-in-time copy of type
BasicStatusLine.Unmodifiable; any attempt to set a property on it throws anUnsupportedOperationException. This method is idempotent: if this bean is already unmodifiable it returns itself rather than taking another snapshot. The receiver is left unchanged (and still modifiable unless it was already anBasicStatusLine.Unmodifiable).- Returns:
- An unmodifiable snapshot of this bean, or this bean if it is already unmodifiable.
-
isUnmodifiable
Returns whether this bean is unmodifiable.- Returns:
true if this bean is anBasicStatusLine.Unmodifiablesnapshot.
-
toString
-
equals
-
hashCode
-
modify
Single mutation funnel — the only choke-point through which all state changes on this bean flow.Every mutator routes through this method. The
BasicStatusLine.Unmodifiablesnapshot overrides only this method to throw, which freezes the entire mutation surface with a single override.- Parameters:
mutation- The state change to apply.- Returns:
- This object.
-
freeze
Deep-freeze hook invoked from theBasicStatusLine.Unmodifiableconstructor after the snapshot copy completes.This is a no-op for
BasicStatusLine: all of its fields are immutable value types (protocol version, status code, reason phrase, locale, reason-phrase catalog) with no mutable sub-beans to deep-freeze. It exists as the paradigm's override point for families whose beans hold mutable sub-beans, which must be frozen here by direct field assignment (never via a setter, which would route through the throwingmodify(Runnable)).
-