Class ClassList<E extends Element>

java.lang.Object
org.jboss.elemento.ClassList<E>
All Implemented Interfaces:
Iterable<String>

public class ClassList<E extends Element> extends Object implements Iterable<String>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String... classes)
    Adds one or more classes to the class list of the element.
    static <E extends Element>
    ClassList<E>
    classList(E element)
     
    boolean
    contains(String classname)
    Checks if the specified class name exists in the class list of the element.
     
    int
     
    void
    remove(String... classes)
    Removes one or more classes from the class list of the element.
    void
    replace(String oldClassname, String newClassname)
    Replaces occurrences of a class name with a new class name in the class list of the element.
    void
    toggle(String classname)
    Toggle the class value; i.e., if the class exists, then remove it, if not, then add it.
    void
    toggle(String classname, boolean force)
    Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Iterable

    forEach, spliterator
  • Method Details

    • classList

      public static <E extends Element> ClassList<E> classList(E element)
    • add

      public void add(String... classes)
      Adds one or more classes to the class list of the element. Empty classes are ignored, classes with spaces are split into multiple classes.
    • remove

      public void remove(String... classes)
      Removes one or more classes from the class list of the element. Empty classes are ignored, classes with spaces are split into multiple classes.
    • toggle

      public void toggle(String classname)
      Toggle the class value; i.e., if the class exists, then remove it, if not, then add it.
    • toggle

      public void toggle(String classname, boolean force)
      Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.
    • replace

      public void replace(String oldClassname, String newClassname)
      Replaces occurrences of a class name with a new class name in the class list of the element.
    • contains

      public boolean contains(String classname)
      Checks if the specified class name exists in the class list of the element.
      Parameters:
      classname - the class name to check for; must not be null or empty
      Returns:
      true if the class name exists in the element's class list, false otherwise
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<E extends Element>
    • length

      public int length()