List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:com.yahoo.bullet.parsing.Error.java
/** * Creates an Error object with the root cause message from the given cause if available. * * @param cause A cause if available.//from w w w .j a va 2 s . c o m * * @return An Error representing this cause. */ public static Error makeError(Throwable cause) { String message = ExceptionUtils.getRootCauseMessage(cause); message = message.isEmpty() ? GENERIC_JSON_ERROR : message; return Error.of(message, singletonList(GENERIC_JSON_RESOLUTION)); }
From source file:net.lyonlancer5.mcmp.kawo.modes.BookProcessor.java
public static List<Pair<String, String>> readBook(ItemStack book) { if (book.getTagCompound() == null) { return ImmutableList.of(); }//from w ww . j a v a 2s. com NBTTagList pages = book.getTagCompound().getTagList("pages", 8); if (pages == null || pages.tagCount() == 0) { return ImmutableList.of(); } final List<Pair<String, String>> lines = Lists.newArrayList(); for (int i = 0; i < pages.tagCount(); i++) { String[] crlf = pages.getStringTagAt(i).split("[\\r\\n]"); for (String ln : crlf) { ln = ln.trim(); if (!ln.isEmpty()) { if (ln.contains("=")) { String[] var0 = ln.split("=", 2); lines.add(Pair.of(var0[0].trim(), var0[1].trim())); } } } } return ImmutableList.copyOf(lines); }
From source file:com.github.ferstl.depgraph.dependency.style.StyleKey.java
private static boolean match(String value1, String value2) { return value1.isEmpty() || value1.equals(value2); }
From source file:com.yahoo.bullet.parsing.Error.java
/** * Creates an Error object with the original rule string and the root cause message from the given cause. * * @param cause A cause.//from w ww .j a v a2 s . c om * @param ruleString The original rule. * * @return An Error representing this cause. */ public static Error makeError(RuntimeException cause, String ruleString) { String message = ExceptionUtils.getRootCauseMessage(cause); message = message.isEmpty() ? "" : message; return Error.of(GENERIC_JSON_ERROR + ":\n" + ruleString + "\n" + message, singletonList(GENERIC_JSON_RESOLUTION)); }
From source file:Main.java
public static String removeLastPath(String path) { String result = path; if (result == null) { return result; }/*from w w w. j a v a2 s. com*/ if (!result.isEmpty() && result.charAt(result.length() - 1) == '/') { result = result.substring(0, result.length() - 2); } if (!result.contains("/")) { return result; } else { return result.substring(0, result.lastIndexOf("/")); } }
From source file:StringUtilities.java
/** * Capicalizes the first letter of a string * @param str the string to be capitalized * @return a capitalized version of {@code str} *///from ww w .j a v a 2s .c o m public static String capitalize(final String str) { if (str == null) { throw new IllegalArgumentException("str is null"); } if (str.isEmpty()) { return str; } final String firstLetterUppercase = str.substring(0, 1).toUpperCase(); final String theRest = str.substring(1); return firstLetterUppercase + theRest; }
From source file:de.lbe.sandbox.springboot.jersey2.JerseyAutoConfiguration.java
private static String findPath(ApplicationPath annotation) { // Jersey doesn't like to be the default servlet, so map to /* as a fallback if (annotation == null) { return "/*"; }/*from w ww . j a v a 2s .c o m*/ String path = annotation.value(); return ((path.isEmpty() || path.equals("/")) ? "/*" : path + "/*"); }
From source file:io.klerch.alexa.state.utils.ConversionUtils.java
/** * A json-string of key-value pairs is read out as a map * @param json json-string of key-value pairs * @return a map with corresponding key-value paris *///from ww w . j av a 2 s . c o m public static Map<String, Object> mapJson(final String json) { final ObjectMapper mapper = new ObjectMapper(); if (json == null || json.isEmpty()) { return new HashMap<>(); } final TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { }; try { // read jsonString into map return mapper.readValue(json, typeRef); } catch (IOException e) { log.error(e); return new HashMap<>(); } }
From source file:Main.java
/** * Checks if is element exists by tag name. * @param element the element//from w w w. j a v a 2 s . c om * @param tagName the tag name * @return true, if is element exists by tag name */ public static boolean isElementExistsByTagName(final Element element, final String tagName) { if (element == null || tagName == null || tagName.isEmpty()) { return false; } // Extract all children on element final NodeList res = element.getChildNodes(); for (int i = 0; i < res.getLength(); i++) { final Node node = res.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { final Element elem = (Element) node; // Check matching with tagname expected if (elem.getTagName().equals(tagName)) { return true; } } } return false; }
From source file:com.github.stagirs.lingvo.morph.MorphStateMachine.java
private static void add(State state, String suf, RuleMapping mapping) { if (suf.isEmpty()) { state.mapping = mapping;/* w w w . java2s .c o m*/ return; } int charCode = char2byte(suf.charAt(suf.length() - 1)); if (state.states[charCode] == null) { state.states[charCode] = new State(); } add(state.states[charCode], suf.substring(0, suf.length() - 1), mapping); }