List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:com.ysheng.auth.frontend.configuration.ConfigurationParser.java
/** * Parses the given configuration file and returns a configuration object. * * @param configurationFileName The name of the configuration file. * @return A configuration object./*from ww w. ja v a 2 s . co m*/ * @throws IOException The IO error that contains detail information. * @throws ConfigurationException The configuration error that contains detail information. */ public static ApiConfiguration parse(String configurationFileName) throws IOException, ConfigurationException { if (StringUtils.isBlank(configurationFileName)) { throw new IllegalArgumentException("Configuration file cannot be blank"); } ObjectMapper objectMapper = null; if (configurationFileName.endsWith("yml") || configurationFileName.endsWith("yaml")) { objectMapper = Jackson.newObjectMapper(new YAMLFactory()); } else if (configurationFileName.endsWith("json")) { objectMapper = Jackson.newObjectMapper(new JsonFactory()); } else { throw new IllegalArgumentException("Unrecognized configuration file type"); } ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class).configure() .addValidatedValueHandler(new OptionalValidatedValueUnwrapper()).buildValidatorFactory(); final ConfigurationFactory<ApiConfiguration> configurationFactory = new DefaultConfigurationFactoryFactory<ApiConfiguration>() .create(ApiConfiguration.class, validatorFactory.getValidator(), objectMapper, "dw"); final File file = new File(configurationFileName); if (!file.exists()) { throw new FileNotFoundException("Configuration file " + configurationFileName + " not found"); } return configurationFactory.build(file); }
From source file:com.hp.autonomy.types.idol.content.ScheduleAdapter.java
@Override public Schedule unmarshal(final String scheduleAsString) { if (StringUtils.isBlank(scheduleAsString)) { return null; }//from w w w . java 2s . co m final String correctCalendar = UNMARSHAL_PATTERN.matcher(scheduleAsString).replaceAll("\r\n"); final ICalendar iCalendar = Biweekly.parse(correctCalendar).first(); String productId = null; if (iCalendar.getProductId() != null) { productId = iCalendar.getProductId().getValue(); } final VEvent event = iCalendar.getEvents().get(0); final DateTime startDate = new DateTime(event.getDateStart().getValue().getTime()); final DateTime endDate = new DateTime(event.getDateEnd().getValue().getTime()); DateTime until = null; Recurrence.Frequency frequency = null; if (event.getRecurrenceRule() != null) { frequency = event.getRecurrenceRule().getValue().getFrequency(); if (event.getRecurrenceRule().getValue().getUntil() != null) { until = new DateTime(event.getRecurrenceRule().getValue().getUntil().getRawComponents().toDate()); } } return new Schedule.Builder().setProductId(productId).setStartDate(startDate).setEndDate(endDate) .setUntil(until).setFrequency(frequency).build(); }
From source file:at.tfr.securefs.key.UiShare.java
public void setShare(String share) { if (StringUtils.isBlank(share)) { this.share = null; } this.share = share; }
From source file:br.ufac.sion.converter.VagaConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (StringUtils.isBlank(value)) { return null; }// w ww . j ava 2 s . c o m return this.vagaFacade.findById(new Long(value)); }
From source file:br.ufac.sion.converter.GpConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (StringUtils.isBlank(value)) { return null; }// w w w . java2 s.com return this.grupoFacade.findById(new Long(value)); }
From source file:com.cnten.platform.util.FileUtil.java
public static void saveThumbnail(String filePath, String thumbnailType) { if (StringUtils.isBlank(filePath)) return;//from w ww . j a v a 2 s .c o m String thumbnailFilePath = getThumbnailFilePath(filePath); try { if (CorsAccountConsts.COMPANY_LICENSE_ENTITY_NAME.equals(thumbnailType)) { Thumbnails.of(filePath).size(220, 160).toFile(thumbnailFilePath); } else { Thumbnails.of(filePath).size(130, 92).toFile(thumbnailFilePath); } } catch (Exception e) { e.printStackTrace(); } }
From source file:br.ufac.sion.converter.NivelConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (StringUtils.isBlank(value)) { return null; }//from w w w . j a v a 2s.c o m return this.nivelFacade.findById(new Long(value)); }
From source file:br.ufac.sion.converter.CargoConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (StringUtils.isBlank(value)) { return null; }//w w w . j a v a2s . co m System.out.println("cargo " + value); return this.cargoFacade.findById(new Long(value)); }
From source file:cop.raml.utils.ProblemResolver.java
/** * Method param duplication// w w w .j a v a 2 s .c o m * * @throws RamlProcessingException exception * @see ThreadLocalContext#getClassName() * @see ThreadLocalContext#getMethodName() * @see ThreadLocalContext#getMessager() * @see ThreadLocalContext#getParamName() */ public static void methodParamDuplication() { String paramName = ThreadLocalContext.getParamName(); String className = ThreadLocalContext.getClassName(); String methodName = ThreadLocalContext.getMethodName(); if (StringUtils.isBlank(paramName)) return; String message = String.format("%s.%s() - parameter '%s' duplication", className, methodName, paramName); if (Config.get().ramlStopOnError()) throw new RamlProcessingException(message); ThreadLocalContext.getMessager().printMessage(WARNING, message); }
From source file:br.ufac.sion.converter.SetorConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { if (StringUtils.isBlank(value)) { return null; }/*from ww w . ja v a 2s . c o m*/ return this.setorFacade.findById(new Long(value)); }