All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.cainlara.jalutils.StringUtils Maven / Gradle / Ivy

package io.github.cainlara.jalutils;

/**
 * Provides String class utilities. This class is intended to be
 * used as a Singleton Pattern implementation.
 * 
 * @author jalara
 */
public final class StringUtils {
  private static StringUtils instance;

  private StringUtils() {
    // hide constructor
  }

  /**
   * Retrives the only instance of this class.
   * 
   * @return an instance of this class.
   */
  public static StringUtils getInstance() {
    if (instance == null) {
      instance = new StringUtils();
    }

    return instance;
  }

  /**
   * Validates if a string instance is a blank text.
   * 

* A text is considered blank as long as it fulfills at least one of the next * conditions: *

    *
  • The object is null.
  • *
  • After triming the lenght of the text is 0. *
* * @param text The String instance to be evaluated. * * @return true if and only if the text parameter is * valid. * * @see String#trim() */ public boolean isBlank(final String text) { return text == null || text.trim().isEmpty(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy