Class NopStyleSource
- All Implemented Interfaces:
StyleSource
StyleSource
that always returns null
.
This class provides an implementation of StyleSource that does not store or retrieve any styles. All methods that modify styles are no-ops, and all methods that retrieve styles return empty results.
This class is useful as a default or fallback StyleSource when no styles are
needed or available. It is used by default in Styler
until a different
StyleSource is set.
Example usage:
// Create a StyleResolver with a NopStyleSource StyleResolver resolver = new StyleResolver(new NopStyleSource(), "group"); // Named style references will always resolve to null AttributedStyle style = resolver.resolve(".error"); // Uses default style if provided
- Since:
- 3.4
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
No-operation implementation of clear that does nothing.Always returnsnull
for any style lookup.groups()
Always returns an empty list of style groups.void
No-operation implementation of remove that does nothing.void
No-operation implementation of remove that does nothing.void
No-operation implementation of set that does nothing.Always returns an empty map of styles.
-
Constructor Details
-
NopStyleSource
public NopStyleSource()
-
-
Method Details
-
get
Always returnsnull
for any style lookup.This implementation validates that the parameters are not null but otherwise always returns null, indicating that no style is defined.
- Specified by:
get
in interfaceStyleSource
- Parameters:
group
- the style group name (must not be null)name
- the style name within the group (must not be null)- Returns:
- always
null
- Throws:
NullPointerException
- if group or name is null
-
set
No-operation implementation of set that does nothing.This implementation validates that the parameters are not null but otherwise does nothing. The style is not stored anywhere.
- Specified by:
set
in interfaceStyleSource
- Parameters:
group
- the style group name (must not be null)name
- the style name within the group (must not be null)style
- the style definition string (must not be null)- Throws:
NullPointerException
- if any parameter is null
-
remove
No-operation implementation of remove that does nothing.This implementation validates that the parameter is not null but otherwise does nothing.
- Specified by:
remove
in interfaceStyleSource
- Parameters:
group
- the style group name to remove (must not be null)- Throws:
NullPointerException
- if group is null
-
remove
No-operation implementation of remove that does nothing.This implementation validates that the parameters are not null but otherwise does nothing.
- Specified by:
remove
in interfaceStyleSource
- Parameters:
group
- the style group name (must not be null)name
- the style name to remove (must not be null)- Throws:
NullPointerException
- if group or name is null
-
clear
public void clear()No-operation implementation of clear that does nothing.Since this implementation doesn't store any styles, this method has no effect.
- Specified by:
clear
in interfaceStyleSource
-
groups
Always returns an empty list of style groups.Since this implementation doesn't store any styles, this method always returns an empty, immutable list.
- Specified by:
groups
in interfaceStyleSource
- Returns:
- an empty, immutable iterable
-
styles
Always returns an empty map of styles.Since this implementation doesn't store any styles, this method always returns an empty, immutable map regardless of the group specified.
- Specified by:
styles
in interfaceStyleSource
- Parameters:
group
- the style group name (not used in this implementation)- Returns:
- an empty, immutable map
-