Class NopStyleSource
- java.lang.Object
-
- org.jline.style.NopStyleSource
-
- All Implemented Interfaces:
StyleSource
public class NopStyleSource extends java.lang.Object implements StyleSource
A no-operation implementation ofStyleSource
that always returnsnull
.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:
StyleSource
,MemoryStyleSource
,Styler.getSource()
-
-
Constructor Summary
Constructors Constructor Description NopStyleSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
No-operation implementation of clear that does nothing.java.lang.String
get(java.lang.String group, java.lang.String name)
Always returnsnull
for any style lookup.java.lang.Iterable<java.lang.String>
groups()
Always returns an empty list of style groups.void
remove(java.lang.String group)
No-operation implementation of remove that does nothing.void
remove(java.lang.String group, java.lang.String name)
No-operation implementation of remove that does nothing.void
set(java.lang.String group, java.lang.String name, java.lang.String style)
No-operation implementation of set that does nothing.java.util.Map<java.lang.String,java.lang.String>
styles(java.lang.String group)
Always returns an empty map of styles.
-
-
-
Method Detail
-
get
@Nullable public java.lang.String get(java.lang.String group, java.lang.String name)
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:
java.lang.NullPointerException
- if group or name is null
-
set
public void set(java.lang.String group, java.lang.String name, java.lang.String style)
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:
java.lang.NullPointerException
- if any parameter is null
-
remove
public void remove(java.lang.String group)
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:
java.lang.NullPointerException
- if group is null
-
remove
public void remove(java.lang.String group, java.lang.String name)
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:
java.lang.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
public java.lang.Iterable<java.lang.String> 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
public java.util.Map<java.lang.String,java.lang.String> styles(java.lang.String group)
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
-
-