Class SearchSpec<T extends Component>

java.lang.Object
com.vaadin.browserless.internal.SearchSpec<T>
Type Parameters:
T - the type of the component we are searching for.

public final class SearchSpec<T extends Component> extends Object
A criterion for matching components. The component must match all of non-null fields.

You can add more properties, simply by creating a write-only property which will register a new predicate on write.

For internal use only. May be renamed or removed in a future release.

  • Constructor Details

    • SearchSpec

      public SearchSpec(Class<T> clazz)
      Creates a search specification which matches all components of given class.
      Parameters:
      clazz - the class of the component we are searching for.
    • SearchSpec

      public SearchSpec(Class<T> clazz, String id, String testId, String caption, String placeholder, String text, CountRange count, Object value, String classes, String withoutClasses, List<Predicate<T>> predicates, String themes, String withoutThemes)
      Creates a search specification.
      Parameters:
      clazz - the class of the component we are searching for.
      id - the required Component.getId(); if null, no particular id is matched.
      testId - the required Component.getTestId() (i.e. the data-testid attribute); if null, no particular test id is matched.
      caption - the required caption; if null, no particular caption is matched.
      placeholder - the required placeholder; if null, no particular placeholder is matched.
      text - the Element.getText()
      count - expected count of matching components, defaults to CountRange.ANY
      value - expected HasValue.getValue(); if null, no particular value is matched.
      classes - if not null, the component must match all of these class names. Space-separated.
      withoutClasses - if not null, the component must NOT match any of these class names. Space-separated.
      predicates - the predicates the component needs to match, not null. May be empty - in such case it is ignored.
      themes - if not null, the component must have all theme names defined. Space-separated
      withoutThemes - if not null, the component must NOT have any of the theme names defined. Space-separated
  • Method Details

    • getClazz

      public Class<T> getClazz()
      The class of the component we are searching for.
      Returns:
      the current value
    • getId

      public String getId()
      The required Component.getId(); if null, no particular id is matched.
      Returns:
      the current value
    • setId

      public void setId(String id)
      The required Component.getId(); if null, no particular id is matched.
      Parameters:
      id - the new value
    • getTestId

      public String getTestId()
      The required test id, i.e. the data-testid attribute; if null, no particular test id is matched.
      Returns:
      the current value
    • setTestId

      public void setTestId(String testId)
      The required test id, i.e. the data-testid attribute; if null, no particular test id is matched.
      Parameters:
      testId - the new value
    • getCaption

      public String getCaption()
      The required caption; if null, no particular caption is matched.
      Returns:
      the current value
    • setCaption

      public void setCaption(String caption)
      The required caption; if null, no particular caption is matched.
      Parameters:
      caption - the new value
    • getPlaceholder

      public String getPlaceholder()
      The required placeholder; if null, no particular placeholder is matched.
      Returns:
      the current value
    • setPlaceholder

      public void setPlaceholder(String placeholder)
      The required placeholder; if null, no particular placeholder is matched.
      Parameters:
      placeholder - the new value
    • getText

      public String getText()
      The required Element.getText(); if null, no particular text is matched.
      Returns:
      the current value
    • setText

      public void setText(String text)
      The required Element.getText(); if null, no particular text is matched.
      Parameters:
      text - the new value
    • getCount

      public CountRange getCount()
      The expected number of matching components. Defaults to any number.
      Returns:
      the current value, not null
    • setCount

      public void setCount(CountRange count)
      The expected number of matching components. Defaults to any number.
      Parameters:
      count - the new value, not null
    • getValue

      public Object getValue()
      Expected HasValue.getValue(); if null, no particular value is matched.
      Returns:
      the current value
    • setValue

      public void setValue(Object value)
      Expected HasValue.getValue(); if null, no particular value is matched.
      Parameters:
      value - the new value
    • getClasses

      public String getClasses()
      If not null, the component must match all of these class names. Space-separated.
      Returns:
      the current value
    • setClasses

      public void setClasses(String classes)
      If not null, the component must match all of these class names. Space-separated.
      Parameters:
      classes - the new value
    • getWithoutClasses

      public String getWithoutClasses()
      If not null, the component must NOT match any of these class names. Space-separated.
      Returns:
      the current value
    • setWithoutClasses

      public void setWithoutClasses(String withoutClasses)
      If not null, the component must NOT match any of these class names. Space-separated.
      Parameters:
      withoutClasses - the new value
    • getPredicates

      public List<Predicate<T>> getPredicates()
      Extra predicates the component must satisfy, on top of the other rules.
      Returns:
      the current value
    • setPredicates

      public void setPredicates(List<Predicate<T>> predicates)
      Extra predicates the component must satisfy, on top of the other rules.
      Parameters:
      predicates - the new value
    • getThemes

      public String getThemes()
      If not null, the component must have all theme names defined. Space-separated.
      Returns:
      the current value
    • setThemes

      public void setThemes(String themes)
      If not null, the component must have all theme names defined. Space-separated.
      Parameters:
      themes - the new value
    • getWithoutThemes

      public String getWithoutThemes()
      If not null, the component must NOT have any of the theme names defined. Space-separated.
      Returns:
      the current value
    • setWithoutThemes

      public void setWithoutThemes(String withoutThemes)
      If not null, the component must NOT have any of the theme names defined. Space-separated.
      Parameters:
      withoutThemes - the new value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • captionContains

      public void captionContains(String substring)
      Makes sure that the component's caption contains given substring.
      Parameters:
      substring - the substring the caption must contain.
    • toPredicate

      public Predicate<Component> toPredicate()
      Returns a predicate which matches components based on this spec. All rules are matched except the count rule. The rules are matched against given component only (not against its children).
      Returns:
      the predicate, not null.