Class SearchHelper

java.lang.Object
com.smell.application.search.SearchHelper

public class SearchHelper extends Object
SearchHelper provides utilities for extracting a character ID from a URL and initializing search-related components within a Vaadin application. This class encapsulates the functionality needed to handle the input of URLs, initiate searches, and log outcomes of such operations. The helper is designed to be reusable across different parts of the application that require similar functionality. Usage:
 SearchHelper helper = new SearchHelper();
 TextField urlField = helper.getUrlField();
 Button searchButton = helper.getSearchButton();
 searchButton.addClickListener(e -> {
     Long characterId = SearchHelper.extractCharacterIdFromUrl(urlField.getValue());
     if(characterId != null) {
         // proceed with characterId
     }
 });
 
Since:
24/04/24
Version:
${version}
Author:
FlynnDynamics
  • Constructor Details

    • SearchHelper

      public SearchHelper()
      Constructs a SearchHelper instance and initializes its components.
  • Method Details

    • getUrlField

      public com.vaadin.flow.component.textfield.TextField getUrlField()
      Returns the text field used for URL input.
      Returns:
      the text field for URL input
    • getSearchButton

      public com.vaadin.flow.component.button.Button getSearchButton()
      Returns the search button.
      Returns:
      the search button
    • extractCharacterIdFromUrl

      public static Long extractCharacterIdFromUrl(String url)
      Extracts and returns the character ID from the given URL. Logs the outcome of the operation, including successful extraction and errors.
      Parameters:
      url - the URL from which to extract the character ID
      Returns:
      the extracted character ID, or null if extraction fails