Class NopStyleSource

java.lang.Object
org.jline.style.NopStyleSource
All Implemented Interfaces:
StyleSource

public class NopStyleSource extends Object implements StyleSource
A no-operation implementation of 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 Details

    • NopStyleSource

      public NopStyleSource()
  • Method Details

    • get

      @Nullable public String get(String group, String name)
      Always returns null 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 interface StyleSource
      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

      public void set(String group, String name, 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 interface StyleSource
      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

      public void remove(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 interface StyleSource
      Parameters:
      group - the style group name to remove (must not be null)
      Throws:
      NullPointerException - if group is null
    • remove

      public void remove(String group, 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 interface StyleSource
      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 interface StyleSource
    • groups

      public Iterable<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 interface StyleSource
      Returns:
      an empty, immutable iterable
    • styles

      public Map<String,String> styles(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 interface StyleSource
      Parameters:
      group - the style group name (not used in this implementation)
      Returns:
      an empty, immutable map