List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank
public static boolean isNotBlank(final CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
From source file:com.netflix.metacat.common.server.properties.PropertyUtils.java
/** * Convert a delimited string into a Set of {@code QualifiedName}. * * @param names The list of names to split * @param delimiter The delimiter to use for splitting * @return The list of qualified names/* w w w .j a va 2s. c o m*/ */ static Set<QualifiedName> delimitedStringsToQualifiedNamesSet(@Nonnull @NonNull final String names, final char delimiter) { if (StringUtils.isNotBlank(names)) { return Splitter.on(delimiter).omitEmptyStrings().splitToList(names).stream() .map(QualifiedName::fromString).collect(Collectors.toSet()); } else { return Sets.newHashSet(); } }
From source file:de.micromata.genome.util.validation.ValStatusException.java
@Override public String getMessage() { StringBuilder sb = new StringBuilder(); String smess = super.getMessage(); if (StringUtils.isNotBlank(smess) == true) { sb.append(smess).append(": "); }/* w ww . j av a 2 s .c o m*/ ValMessage msg = getWorstMessage(); if (msg.getMessage() != null) { sb.append(msg.getMessage()); } else { sb.append(msg.getI18nkey()); } if (msg.getReference() != null) { sb.append(" on ").append(msg.getReference().getClass().getSimpleName()); } if (StringUtils.isNotBlank(msg.getProperty()) == true) { sb.append(".").append(msg.getReference()); } return sb.toString(); }
From source file:jease.site.Discussions.java
/** * Adds a comment with given values to given Discussion. Visible flag * indicates if added comment should be visible or not. * //from w w w .j av a 2 s. c om * Returns null on success, otherwise an error message. */ public static String addComment(Discussion discussion, String author, String subject, String comment, boolean visible) { if (StringUtils.isBlank(subject) || StringUtils.isBlank(author) || StringUtils.isBlank(comment)) { return I18N.get("All_fields_are_required"); } if (subject.length() > MAX_SUBJECT_LENGTH || author.length() > MAX_AUTHOR_LENGTH || comment.length() > MAX_COMMENT_LENGTH) { return I18N.get("Input_is_too_long"); } // Escape all user input subject = StringEscapeUtils.escapeHtml4(subject); author = StringEscapeUtils.escapeHtml4(author); comment = StringEscapeUtils.escapeHtml4(comment); // Save comment to database. discussion.addComment(subject, author, comment, visible); Nodes.save(discussion); // Send email for review to editor in charge. String recipient = discussion.getEditor().getEmail(); if (StringUtils.isNotBlank(recipient)) { Mails.dispatch(recipient, recipient, String.format("%s (%s)", subject, author), comment); } return null; }
From source file:com.netflix.genie.server.repository.jpa.ApplicationSpecs.java
/** * Get a specification using the specified parameters. * * @param name The name of the application * @param userName The name of the user who created the application * @param statuses The status of the application * @param tags The set of tags to search the command for * @return A specification object used for querying *///from w w w. j a va2s . c om public static Specification<Application> find(final String name, final String userName, final Set<ApplicationStatus> statuses, final Set<String> tags) { return new Specification<Application>() { @Override public Predicate toPredicate(final Root<Application> root, final CriteriaQuery<?> cq, final CriteriaBuilder cb) { final List<Predicate> predicates = new ArrayList<>(); if (StringUtils.isNotBlank(name)) { predicates.add(cb.equal(root.get(Application_.name), name)); } if (StringUtils.isNotBlank(userName)) { predicates.add(cb.equal(root.get(Application_.user), userName)); } if (statuses != null && !statuses.isEmpty()) { //Could optimize this as we know size could use native array final List<Predicate> orPredicates = new ArrayList<>(); for (final ApplicationStatus status : statuses) { orPredicates.add(cb.equal(root.get(Application_.status), status)); } predicates.add(cb.or(orPredicates.toArray(new Predicate[orPredicates.size()]))); } if (tags != null) { for (final String tag : tags) { if (StringUtils.isNotBlank(tag)) { predicates.add(cb.isMember(tag, root.get(Application_.tags))); } } } return cb.and(predicates.toArray(new Predicate[predicates.size()])); } }; }
From source file:com.hbc.api.trade.order.validator.OrderValidator.java
/** * ???cityId-stayDay,cityId2-stayDay2,[cityId3-stayDa3,...]FALSETradeException * @param orderBean/*www. j ava 2s .co m*/ */ public final static void validatePassCity(OrderBean orderBean) { if (StringUtils.isNotBlank(orderBean.getServicePassCity())) { for (String passCity : orderBean.getServicePassCity().split(TradeConstant.SPLITER_COMMA)) { if (passCity != null && passCity.split(TradeConstant.SPLITER_LINE).length != 2) { log.error( "?? cityId-stayDay,cityId2-stayDay2,[cityId3-stayDa3,...]" + orderBean.getServicePassCity()); throw new TradeException(TradeReturnCodeEnum.ORDER_PARAM_FAILED, ""); } } } }
From source file:com.boothj5.minions.MinionsRunner.java
void run() throws MinionsException { try {/*from w ww. j a v a 2 s . com*/ LOG.debug("Starting MinionsRunner"); ConnectionConfiguration connectionConfiguration; if (StringUtils.isNotBlank(config.getServer())) { connectionConfiguration = new ConnectionConfiguration(config.getServer(), config.getPort(), config.getService()); } else { connectionConfiguration = new ConnectionConfiguration(config.getService(), config.getPort()); } XMPPConnection conn = new XMPPConnection(connectionConfiguration); conn.connect(); conn.login(config.getUser(), config.getPassword(), config.getResource()); LOG.debug(format("Logged in: %s@%s", config.getUser(), config.getService())); MultiUserChat muc = new MultiUserChat(conn, config.getRoom()); if (StringUtils.isBlank(config.getRoomPassword())) { muc.join(config.getRoomNick()); } else { muc.join(config.getRoomNick(), config.getRoomPassword()); } LOG.debug(format("Joined: %s as %s", config.getRoom(), config.getRoomNick())); MinionStore minions = new MinionStore(config.getPluginsDir(), config.getRefreshSeconds(), muc); MinionsListener listener = new MinionsListener(minions, config.getPrefix(), muc, config.getRoomNick()); muc.addMessageListener(listener); Object lock = new Object(); synchronized (lock) { while (true) { lock.wait(); } } } catch (Throwable t) { throw new MinionsException(t); } }
From source file:com.ufukuzun.myth.dialect.builder.AjaxEventBindingBuilder.java
private static String getEventString(Arguments arguments, Element element) { String event = ElementAndAttrUtils.getProcessedAttributeValue(arguments, element, MythEventAttrProcessor.ATTR_NAME_WITH_PREFIX); return "on" + (StringUtils.isNotBlank(event) ? event : DEFAULT_EVENT_NAME); }
From source file:com.biglakesystems.biglib.quality.ExceptionsTest.java
/** * Test the implementation of {@link Exceptions#uniqueId(Throwable)}. *///www .j a va 2 s . com @Test public void testUniqueId() { /* Verify that repeated calls with the same instance return the same identifier. */ final Exception testException = new Exception(); final String testExceptionId = Exceptions.uniqueId(testException); assertTrue(StringUtils.isNotBlank(testExceptionId)); assertEquals(testExceptionId, Exceptions.uniqueId(testException)); assertFalse(testExceptionId.equals(Exceptions.uniqueId(new Exception()))); /* Verify that two different exception objects, which are equal per equals()/hashCode(), do not yield the same identifier. */ final Throwable equalException1 = new AlwaysEqualException(); final Throwable equalException2 = new AlwaysEqualException(); assertEquals(equalException1, equalException2); assertFalse(Exceptions.uniqueId(equalException1).equals(Exceptions.uniqueId(equalException2))); }
From source file:cop.raml.utils.javadoc.HtmlTag.java
public boolean is(@NotNull String str) { return StringUtils.isNotBlank(str) && pattern.matcher(str).matches(); }
From source file:de.jcup.egradle.sdk.builder.util.DelegationTargetWalker.java
public void visitAllMethodInHierarchy(Type type, DelegationTargetMethodVisitor visitor, SDKBuilderContext context, boolean checkOnlyClosures) { for (Method m : type.getDefinedMethods()) { String targetType = m.getDelegationTargetAsString(); if (StringUtils.isNotBlank(targetType)) { continue; }/* www. j a v a 2 s . c o m*/ targetType = findDelegationTargetTypeForMethod(m, visitor, type, checkOnlyClosures); if (StringUtils.isNotBlank(targetType)) { if (m instanceof ModifiableMethod) { ModifiableMethod method = (ModifiableMethod) m; method.setDelegationTargetAsString(targetType); } else { context.addWarning("cannot set target type:" + targetType + " to method:" + m); } } } }