List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:org.cloudfoundry.identity.uaa.login.TileInfo.java
public List<Map<String, String>> getLoginTiles() { List<Map<String, String>> loginTiles = new ArrayList<>(); for (Map<String, String> tile : tiles) { if (!StringUtils.isEmpty(tile.get("login-link"))) { loginTiles.add(tile);// ww w . j a v a 2s .co m } } return loginTiles; }
From source file:lydichris.smashbracket.services.EntrantService.java
public Entrant createEntrant(String tag, String username, String password, String tournamentUuid) { Entrant entrant = new Entrant(); entrant.setTag(tag);/*from w w w .j a v a2 s .co m*/ entrant.setTournamentUuid(tournamentUuid); if (!tournamentService.checkTournamentExists(tournamentUuid)) { throw new EntrantCreationException(EntrantCreationExceptionEnum.TOURNAMENT_LOOKUP_FAILED); } if (StringUtils.isEmpty(tag)) { throw new EntrantCreationException(EntrantCreationExceptionEnum.TAG_IS_EMPTY); } if (!StringUtils.isEmpty(username)) { if (userService.checkUsernamePasswordHashExists(username, password)) { entrant.setUserUuid(userService.getUserByUserName(username).getId()); } else { throw new EntrantCreationException(EntrantCreationExceptionEnum.LOOKUP_FAILED); } } //Throw exception if creating entrant exceeds limit return entrantPersistence.createEntrant(entrant); }
From source file:com.ocs.dynamo.utils.PasteUtils.java
/** * Converts a string to an integer, conveniently removing all grouping separators * /*from w w w. j a v a 2s .c o m*/ * @param input * @return */ public static Integer toInt(String input) { if (input == null) { return null; } input = input.replaceAll(",", "").replaceAll("\\.", ""); return StringUtils.isEmpty(input) ? null : Integer.parseInt(input); }
From source file:com.ocs.dynamo.importer.impl.BaseTextImporter.java
@Override protected Boolean getBooleanValueWithDefault(String unit, XlsField field) { Boolean result = getBooleanValue(unit); if (result == null && !StringUtils.isEmpty(field.defaultValue())) { return Boolean.valueOf(field.defaultValue()); }/*w ww. j ava 2 s .co m*/ return result; }
From source file:cn.guoyukun.spring.jpa.exception.BaseException.java
@Override public String getMessage() { String message = null;//from w ww. j ava 2s . c om if (!StringUtils.isEmpty(code)) { message = MessageUtils.message(code, args); } if (message == null) { message = defaultMessage; } return message; }
From source file:org.paxml.bean.AppendTag.java
@Override protected Object doInvoke(Context context) throws Exception { IFile ifile;//w ww . j a v a2 s. c o m if (StringUtils.isEmpty(to)) { ifile = context.getOnlyFile(); if (ifile == null) { throw new PaxmlRuntimeException("Please specify a destination to append to!"); } } else { File f = PaxmlUtils.getFile(to); ifile = context.getFile(f); if (ifile == null) { ifile = FileHelper.load(PaxmlUtils.getResource(f)); } } if (ifile.isReadonly()) { throw new PaxmlRuntimeException("Cannot append to: " + to + ", because it is readonly!"); } Object row = getValue(); if (ifile instanceof ITable) { ITable table = ((ITable) ifile); IRow r = table.createNextRow(); if (row == null) { throw new PaxmlRuntimeException("Please specify a row to append!"); } else if (row instanceof Map) { r.setCellValues((Map) row); } else { List list = new ArrayList(); ReflectUtils.collect(row, list, true); r.setCellValues(0, -1, list.iterator()); } } else { throw new PaxmlRuntimeException( "Unsupported resource type to append to: " + ifile.getClass().getName()); } ifile.flush(); return ifile; }
From source file:com.ge.apm.service.converter.DateConverter.java
protected Object convertToDate(Class type, Object value, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); if (value instanceof String) { try {//from w ww. ja v a 2 s. c o m if (StringUtils.isEmpty(value.toString())) { return null; } Date date = sdf.parse((String) value); if (type.equals(Timestamp.class)) { return new Timestamp(date.getTime()); } return date; } catch (Exception pe) { return null; } } else if (value instanceof Date) { return value; } throw new ConversionException("?? " + value.getClass().getName() + " " + type.getName()); }
From source file:cognition.pipeline.commandline.CommandCreateModeFromFile.java
@Override public void process(CommandLine cmd) { String filePath = cmd.getOptionValue("file"); if (StringUtils.isEmpty(filePath)) { throw new IllegalArgumentException("File argument must be specified."); }/* w ww .j a v a 2 s . c om*/ if (cmd.hasOption("noPseudonym")) { dncPipelineService.getCommandLineArgHolder().setNoPseudonym(true); } dncPipelineService.startCreateModeWithFile(filePath); }
From source file:cn.guoyukun.spring.cache.BaseCacheAspect.java
public void evict(String key) { log.debug("cacheName:{}, evict key:{}", cacheName, key); if (StringUtils.isEmpty(key)) { return;//from ww w.j av a2s. co m } this.cache.evict(key); }
From source file:com.btmatthews.springboot.memcached.MemcachedAutoConfiguration.java
@Bean public MemcachedClient memcachedClient() throws IOException { final List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); final String servers = environment.getProperty("memcached.servers"); if (StringUtils.isEmpty(servers)) { addresses.add(new InetSocketAddress(LOCALHOST, DEFAULT_PORT)); } else {/* w ww. j a v a2s.c om*/ for (final String server : servers.split(",")) { final int colon = server.indexOf(":"); if (colon == -1) { addresses.add(new InetSocketAddress(server, DEFAULT_PORT)); } else { final int port = Integer.parseInt(server.substring(colon + 1)); addresses.add(new InetSocketAddress(server.substring(0, colon), port)); } } } return new MemcachedClient(addresses); }