Tabnine Logo
String.isEmpty
Code IndexAdd Tabnine to your IDE (free)

How to use
isEmpty
method
in
java.lang.String

Best Java code snippets using java.lang.String.isEmpty (Showing top 20 results out of 141,219)

origin: spring-projects/spring-framework

public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) {
  this.subPattern = subPattern;
  this.pathMatcher = pathMatcher;
  this.rootPath = (rootPath.isEmpty() || rootPath.endsWith("/") ? rootPath : rootPath + "/");
}
origin: stackoverflow.com

 public static boolean empty( final String s ) {
 // Null-safe, short-circuit evaluation.
 return s == null || s.trim().isEmpty();
}
origin: spring-projects/spring-framework

/**
 * Check that the given {@code String} is neither {@code null} nor of length 0.
 * <p>Note: this method returns {@code true} for a {@code String} that
 * purely consists of whitespace.
 * @param str the {@code String} to check (may be {@code null})
 * @return {@code true} if the {@code String} is not {@code null} and has length
 * @see #hasLength(CharSequence)
 * @see #hasText(String)
 */
public static boolean hasLength(@Nullable String str) {
  return (str != null && !str.isEmpty());
}
origin: stackoverflow.com

 List<String> list = new ArrayList<>();

// This is a clever way to create the iterator and call iterator.hasNext() like
// you would do in a while-loop. It would be the same as doing:
//     Iterator<String> iterator = list.iterator();
//     while (iterator.hasNext()) {
for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
  String string = iterator.next();
  if (string.isEmpty()) {
    // Remove the current element from the iterator and the list.
    iterator.remove();
  }
}
origin: spring-projects/spring-framework

  @Override
  public T convert(String source) {
    if (source.isEmpty()) {
      // It's an empty enum identifier: reset the enum value to null.
      return null;
    }
    return (T) Enum.valueOf(this.enumType, source.trim());
  }
}
origin: spring-projects/spring-framework

protected boolean isNamespaceDeclaration(QName qName) {
  String prefix = qName.getPrefix();
  String localPart = qName.getLocalPart();
  return (XMLConstants.XMLNS_ATTRIBUTE.equals(localPart) && prefix.isEmpty()) ||
      (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix) && !localPart.isEmpty());
}
origin: spring-projects/spring-framework

@Override
public Character convert(String source) {
  if (source.isEmpty()) {
    return null;
  }
  if (source.length() > 1) {
    throw new IllegalArgumentException(
        "Can only convert a [String] with length of 1 to a [Character]; string value '" + source + "'  has length of " + source.length());
  }
  return source.charAt(0);
}
origin: square/okhttp

static void checkName(String name) {
 if (name == null) throw new NullPointerException("name == null");
 if (name.isEmpty()) throw new IllegalArgumentException("name is empty");
 for (int i = 0, length = name.length(); i < length; i++) {
  char c = name.charAt(i);
  if (c <= '\u0020' || c >= '\u007f') {
   throw new IllegalArgumentException(Util.format(
     "Unexpected char %#04x at %d in header name: %s", (int) c, i, name));
  }
 }
}
origin: google/guava

 @Override
 public void parse(CacheBuilderSpec spec, String key, String value) {
  checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
  try {
   parseInteger(spec, Integer.parseInt(value));
  } catch (NumberFormatException e) {
   throw new IllegalArgumentException(
     format("key %s value set to %s, must be integer", key, value), e);
  }
 }
}
origin: google/guava

 @Override
 protected String computeNext() {
  if (lines.hasNext()) {
   String next = lines.next();
   // skip last line if it's empty
   if (lines.hasNext() || !next.isEmpty()) {
    return next;
   }
  }
  return endOfData();
 }
};
origin: google/guava

 @Override
 public void parse(CacheBuilderSpec spec, String key, String value) {
  checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
  try {
   parseLong(spec, Long.parseLong(value));
  } catch (NumberFormatException e) {
   throw new IllegalArgumentException(
     format("key %s value set to %s, must be integer", key, value), e);
  }
 }
}
origin: spring-projects/spring-framework

private String resolveExpression(A annotation) {
  for (String attributeName : EXPRESSION_ATTRIBUTES) {
    Object val = AnnotationUtils.getValue(annotation, attributeName);
    if (val instanceof String) {
      String str = (String) val;
      if (!str.isEmpty()) {
        return str;
      }
    }
  }
  throw new IllegalStateException("Failed to resolve expression: " + annotation);
}
origin: spring-projects/spring-framework

  @Override
  public T convert(String source) {
    if (source.isEmpty()) {
      return null;
    }
    return NumberUtils.parseNumber(source, this.targetType);
  }
}
origin: spring-projects/spring-framework

/**
 * Base64-decode the given byte array from an UTF-8 String.
 * @param src the encoded UTF-8 String
 * @return the original byte array
 */
public static byte[] decodeFromString(String src) {
  if (src.isEmpty()) {
    return new byte[0];
  }
  return decode(src.getBytes(DEFAULT_CHARSET));
}
origin: square/okhttp

static int readInt(BufferedSource source) throws IOException {
 try {
  long result = source.readDecimalLong();
  String line = source.readUtf8LineStrict();
  if (result < 0 || result > Integer.MAX_VALUE || !line.isEmpty()) {
   throw new IOException("expected an int but was \"" + result + line + "\"");
  }
  return (int) result;
 } catch (NumberFormatException e) {
  throw new IOException(e.getMessage());
 }
}
origin: google/guava

 private static String firstCharOnlyToUpper(String word) {
  return word.isEmpty()
    ? word
    : Ascii.toUpperCase(word.charAt(0)) + Ascii.toLowerCase(word.substring(1));
 }
}
origin: square/okhttp

/**
 * Sets this request's {@code Cache-Control} header, replacing any cache control headers already
 * present. If {@code cacheControl} doesn't define any directives, this clears this request's
 * cache-control headers.
 */
public Builder cacheControl(CacheControl cacheControl) {
 String value = cacheControl.toString();
 if (value.isEmpty()) return removeHeader("Cache-Control");
 return header("Cache-Control", value);
}
origin: spring-projects/spring-framework

private String getPartName(MethodParameter methodParam, @Nullable RequestPart requestPart) {
  String partName = (requestPart != null ? requestPart.name() : "");
  if (partName.isEmpty()) {
    partName = methodParam.getParameterName();
    if (partName == null) {
      throw new IllegalArgumentException("Request part name for argument type [" +
          methodParam.getNestedParameterType().getName() +
          "] not specified, and parameter name information not found in class file either.");
    }
  }
  return partName;
}
origin: spring-projects/spring-framework

private String getPartName(MethodParameter methodParam, @Nullable RequestPart requestPart) {
  String partName = (requestPart != null ? requestPart.name() : "");
  if (partName.isEmpty()) {
    partName = methodParam.getParameterName();
    if (partName == null) {
      throw new IllegalArgumentException("Request part name for argument type [" +
          methodParam.getNestedParameterType().getName() +
          "] not specified, and parameter name information not found in class file either.");
    }
  }
  return partName;
}
origin: spring-projects/spring-framework

private Expression parseTemplate(String expressionString, ParserContext context) throws ParseException {
  if (expressionString.isEmpty()) {
    return new LiteralExpression("");
  }
  Expression[] expressions = parseExpressions(expressionString, context);
  if (expressions.length == 1) {
    return expressions[0];
  }
  else {
    return new CompositeStringExpression(expressionString, expressions);
  }
}
java.langStringisEmpty

Javadoc

Returns true if, and only if, #length() is 0.

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • split
    Splits this string using the supplied regularExpression. See Pattern#split(CharSequence,int) for an
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • indexOf
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • toLowerCase,
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now