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.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAssessmentTransform.java
public static ServiceLevelAssessment toModel( com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment assessment) { ServiceLevelAssessment model = new ServiceLevelAssessment(); model.setAgreement(new ServiceLevelAgreement()); if (assessment.getServiceLevelAgreementDescription() != null) { if (StringUtils.isNotBlank(assessment.getServiceLevelAgreementDescription().getName())) { model.getAgreement().setName(assessment.getServiceLevelAgreementDescription().getName()); }//from w w w. jav a2s . c o m if (StringUtils.isNotBlank(assessment.getServiceLevelAgreementDescription().getDescription())) { model.getAgreement() .setDescription(assessment.getServiceLevelAgreementDescription().getDescription()); } if (assessment.getServiceLevelAgreementDescription().getSlaId() != null) { model.getAgreement().setId(assessment.getServiceLevelAgreementDescription().getSlaId().toString()); } } if (model.getAgreement().getId() == null) { model.getAgreement() .setId(assessment.getServiceLevelAgreementId() != null ? assessment.getServiceLevelAgreementId().toString() : null); } if (model.getAgreement().getName() == null & assessment.getAgreement() != null) { model.getAgreement().setName(assessment.getAgreement().getName()); } if (assessment.getObligationAssessments() != null) { model.setObligationAssessments(assessment.getObligationAssessments().stream() .map(obligationAssessment -> toModel(obligationAssessment)).collect(Collectors.toList())); } model.setMessage(assessment.getMessage()); model.setResult(ServiceLevelAssessment.Result.valueOf(assessment.getResult().name())); model.setTime(assessment.getTime()); model.setId(assessment.getId().toString()); return model; }
From source file:musiccrawler.common.HtmlToolFix.java
public static String fixLyric(String input) { if (StringUtils.isNotBlank(input)) { String temp = StringUtils.replaceAll(input, Constant.HTML_SPAN_TAG_PATTERN, Constant.EMPTY); return temp.replaceAll(Constant.HTML_TAG_PATTERN, Constant.BREAK_LINE) .replaceAll(Constant.SPACE_START_LINE_PATTERN, Constant.EMPTY).trim(); }//from w w w.j av a2 s. c o m return Constant.EMPTY; }
From source file:com.marand.thinkmed.api.demographics.DemographicsUtils.java
public static String calculateName(final String name1, final String name2, final String nameHyphen) { final StringBuffer sBuf = new StringBuffer(); if (StringUtils.isNotBlank(name1)) { sBuf.append(name1);//w w w .j a v a2 s. com } if (StringUtils.isNotBlank(name2)) { if (sBuf.length() != 0) { sBuf.append(' '); } if (StringUtils.isNotBlank(nameHyphen)) { sBuf.append(nameHyphen); sBuf.append(' '); } sBuf.append(name2); } return sBuf.toString(); }
From source file:com.moviejukebox.model.artwork.ArtworkSize.java
/** * Convert a string into an Enum type//www . j a v a2s . com * * @param artworkSize * @return * @throws IllegalArgumentException If type is not recognised * */ public static ArtworkSize fromString(String artworkSize) { if (StringUtils.isNotBlank(artworkSize)) { try { return ArtworkSize.valueOf(artworkSize.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("ArtworkSize " + artworkSize + " does not exist.", ex); } } throw new IllegalArgumentException("ArtworkSize must not be null"); }
From source file:com.plugin.excel.xsd.node.store.impl.FileHelper.java
public static List<String> getAllXsds(String directoryLocation) { if (StringUtils.isNotBlank(directoryLocation)) { List<File> files = new ArrayList<File>(); findFiles(directoryLocation, files); if (!files.isEmpty()) { List<String> fileStrs = new ArrayList<String>(); for (File file : files) { fileStrs.add(file.getPath()); }/*from w w w. j a va 2s. c o m*/ return fileStrs; } } return null; }
From source file:com.omertron.fanarttvapi.enumeration.FTSourceType.java
/** * Convert a string into an Enum type.//from www. j a va 2s.co m * * @param artworkType * @return * @throws IllegalArgumentException If type is not recognised */ public static FTSourceType fromString(String artworkType) { if (StringUtils.isNotBlank(artworkType)) { try { return FTSourceType.valueOf(artworkType.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("FTSource " + artworkType + " does not exist.", ex); } } throw new IllegalArgumentException("FTSource must not be null"); }
From source file:models.daos.UserDao.java
public static ObjectNode getWatchers(String datasetName) { List<String> watchUsers = new ArrayList<String>(); if (StringUtils.isNotBlank(datasetName)) { Map<String, Object> params = new HashMap<>(); params.put("name", datasetName); List<Map<String, Object>> rows = null; rows = JdbcUtil.wherehowsNamedJdbcTemplate.queryForList(GET_USERS_WATCHED_DATASET, params); for (Map row : rows) { String userName = (String) row.get("username"); watchUsers.add(userName);//www . j a v a 2s . c om } } ObjectNode result = Json.newObject(); result.put("count", watchUsers.size()); result.set("users", Json.toJson(watchUsers)); return result; }
From source file:com.moviejukebox.model.enumerations.TitleSortType.java
/** * Convert a string into an Enum type//from w w w.j av a 2 s . co m * * @param titleSortTypeString * @return TitleSortType */ public static TitleSortType fromString(String titleSortTypeString) { if (StringUtils.isNotBlank(titleSortTypeString)) { for (final TitleSortType titleSortType : EnumSet.allOf(TitleSortType.class)) { if (titleSortTypeString.equalsIgnoreCase(titleSortType.toString().toLowerCase())) { return titleSortType; } } } // We've not found the type, so use the default return TitleSortType.TITLE; }
From source file:com.omertron.bgg.enums.Domain.java
/** * Convert a string into an Enum type//from w ww.j av a 2 s .com * * @param source String representation of the enum to convert * @return The enum that matches the source * @throws IllegalArgumentException If type is not recognised * */ public static Domain fromString(String source) { if (StringUtils.isNotBlank(source)) { try { return Domain.valueOf(source.trim().toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Domain " + source + " does not exist.", ex); } } throw new IllegalArgumentException("Domain must not be null"); }
From source file:ch.cyberduck.core.BookmarkNameProvider.java
public static String toString(final Host bookmark, final boolean username) { if (StringUtils.isEmpty(bookmark.getNickname())) { final String prefix; // Return default bookmark name if (username && !bookmark.getCredentials().isAnonymousLogin() && StringUtils.isNotBlank(bookmark.getCredentials().getUsername())) { prefix = String.format("%s@", bookmark.getCredentials().getUsername()); } else {/*from w w w . ja v a 2s. co m*/ prefix = StringUtils.EMPTY; } if (StringUtils.isNotBlank(bookmark.getHostname())) { return String.format("%s%s \u2013 %s", prefix, StringUtils.strip(bookmark.getHostname()), bookmark.getProtocol().getName()); } if (StringUtils.isNotBlank(bookmark.getProtocol().getDefaultHostname())) { return String.format("%s%s \u2013 %s", prefix, StringUtils.strip(bookmark.getProtocol().getDefaultHostname()), bookmark.getProtocol().getName()); } return String.format("%s%s", prefix, bookmark.getProtocol().getName()); } // Return custom bookmark name set return bookmark.getNickname(); }