Java Code Examples for org.apache.commons.lang3.StringUtils.isNotEmpty()

The following are Jave code examples for showing how to use isNotEmpty() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: xm-commons   File: PrivilegeScanner.java   View Source Code Vote up 6 votes
private Privilege parse(String expression) {
    Privilege privilege = new Privilege();
    privilege.setMsName(appName);
    String[] inputParams = StringUtils.split(expression, ",");

    for (int i = 0; i < inputParams.length; i++) {
        if (i == inputParams.length - 1) {
            if (StringUtils.contains(inputParams[i], "'")) {
                privilege.setKey(StringUtils.substringBetween(inputParams[i], "'")
                    .replace("@msName", appName.toUpperCase()));
            } else {
                privilege.setKey(inputParams[i].replace("@msName", appName.toUpperCase()));
            }
        } else {
            String resource = StringUtils.substringBetween(inputParams[i], "'");
            if (StringUtils.isNotEmpty(resource)) {
                privilege.getResources().add(resource);
            }
        }
    }
    return privilege;
}
 
Example 2
Project: dooo   File: AbstractConditionValidator.java   View Source Code Vote up 6 votes
@Override
public boolean accept(Object object) {
    // 如果不允许为空的情况下
    if (notNull) {
        if (object instanceof String) {
            if (!isCard((String) object)) {
                return false;
            }
        } else {
            return false;
        }
    } else {
        // 值不为空的时候才进行正则判断
        if (StringUtils.isNotEmpty((String) object)) {
            if (!isCard((String) object)) {
                return false;
            }
        }
    }

    return true;
}
 
Example 3
Project: Yidu   File: Utils.java   View Source Code Vote up 6 votes
/**
 * 判断对象是不是定义了 <br>
 * List的话,不为NULL和空<br>
 * 字符串的的话,不为NULL或空<br>
 * Integer的话,不为NULL或0<br>
 * 
 * @param obj
 *            要判断的对象
 * @return 是否定义了
 */
public static boolean isDefined(Object obj) {
    if (obj instanceof Collection) {
        return CollectionUtils.isNotEmpty((Collection<?>) obj);
    }

    if (obj instanceof Map) {
        return MapUtils.isNotEmpty((Map<?, ?>) obj);
    }

    if (obj instanceof String) {
        return StringUtils.isNotEmpty((String) obj);
    }

    if (obj instanceof Integer) {
        return obj != null && (Integer) obj != 0;
    }

    return obj != null;
}
 
Example 4
Project: saluki   File: GenericInvokeUtils.java   View Source Code Vote up 6 votes
private static Object generateMapType(ServiceDefinition def, TypeDefinition td, MetadataType metadataType,
                                      Set<String> resolvedTypes) {
    String keyType = StringUtils.substringAfter(td.getType(), "<");
    keyType = StringUtils.substringBefore(keyType, ",");
    keyType = StringUtils.strip(keyType);
    keyType = StringUtils.isNotEmpty(keyType) ? keyType : "java.lang.Object";
    Object key = generateType(def, keyType, metadataType, resolvedTypes);

    String valueType = StringUtils.substringAfter(td.getType(), ",");
    valueType = StringUtils.substringBefore(valueType, ">");
    valueType = StringUtils.strip(valueType);
    valueType = StringUtils.isNotEmpty(valueType) ? valueType : "java.lang.Object";
    Object value = generateType(def, valueType, metadataType, resolvedTypes);

    Map<Object, Object> map = new HashMap<>();
    map.put(key, value);
    return map;
}
 
Example 5
Project: redis-client   File: RedisClientImpl.java   View Source Code Vote up 6 votes
@Override
public <T> T hgetObject(final String bizkey, final String nameSpace, final String field, TypeReference<T> type,
        final GetDataCallBack<T> gbs) {
    final String key = CacheUtils.getKeyByNamespace(bizkey, nameSpace);
    String res = hget(bizkey, nameSpace, field, null);
    T rtn = null;
    if (StringUtils.isNotEmpty(res)) {
        rtn = CacheUtils.parseObject(key, res, type);
    } else {
        if (gbs != null) {
            rtn = gbs.invoke();
        }
        if (null != rtn) {
            hsetObject(bizkey, nameSpace, field, rtn);
        }
    }
    return rtn;
}
 
Example 6
Project: Supreweb   File: CastUtil.java   View Source Code Vote up 5 votes
public static int cast2Int(Object obj, int defaultValue) {
    int intValue = defaultValue;
    if (null != obj) {
        String str = cast2String(obj);
        if (StringUtils.isNotEmpty(str)) {
            try {
                intValue = Integer.parseInt(str);
            } catch (NumberFormatException e) {
                intValue = defaultValue;
            }
        }
    }
    return intValue;
}
 
Example 7
Project: jwala   File: ParamValidator.java   View Source Code Vote up 5 votes
public ParamValidator isNotEmpty(final String val) {
    if (isValid()) {
        valid = StringUtils.isNotEmpty(val);
        return this;
    }
    return this;
}
 
Example 8
Project: hybris-integration-intellij-idea-plugin   File: ImportImpexAction.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(final AnActionEvent e) {
    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
    if (editor != null) {
        final SelectionModel selectionModel = editor.getSelectionModel();
        final ImportImpexHttpClient client = new ImportImpexHttpClient();
        final String selectedText = selectionModel.getSelectedText();
        if (StringUtils.isNotEmpty(selectedText)) {
            final HybrisHttpResult hybrisHttpResult = client.importImpex(selectedText);

            ExecuteHybrisConsole.getInstance().show(hybrisHttpResult, e.getProject());
        }
    }
}
 
Example 9
Project: aaden-pay   File: PaymentCommon.java   View Source Code Vote up 5 votes
protected String getInternetIp() {
	if (StringUtils.isNotEmpty(this.webip))
		return this.webip;

	this.webip = IpAddressUtil.getInternetIp();

	return this.webip;
}
 
Example 10
Project: JuniperBotJ   File: RankingServiceImpl.java   View Source Code Vote up 5 votes
@Transactional
@Override
public void syncMee6(Guild guild) throws IOException {
    List<RankingInfo> mee6Infos = mee6Provider.export(guild.getIdLong());
    if (CollectionUtils.isNotEmpty(mee6Infos)) {
        List<LocalMember> members = memberService.syncMembers(guild);
        Map<String, LocalMember> membersMap = members.stream()
                .collect(Collectors.toMap(u -> u.getUser().getUserId(), e -> e));
        for (RankingInfo info : mee6Infos) {
            LocalMember member = membersMap.get(info.getId());
            if (member == null) {
                member = new LocalMember();
                member.setGuildId(guild.getId());
                member.setEffectiveName(info.getNick());

                LocalUser user = userRepository.findByUserId(info.getId());
                if (user == null) {
                    user = new LocalUser();
                    user.setUserId(info.getId());
                }
                if (StringUtils.isNotEmpty(info.getAvatarUrl())) {
                    user.setAvatarUrl(info.getAvatarUrl());
                }
                user.setName(info.getName());
                user.setDiscriminator(info.getDiscriminator());
                member.setUser(user);
                userRepository.save(user);
                memberRepository.save(member);
            }
            Ranking ranking = getRanking(member);
            ranking.setExp(info.getTotalExp());
            rankingRepository.save(ranking);
        }
        sync(guild);
    }
}
 
Example 11
Project: PTEAssistant   File: SkinManager.java   View Source Code Vote up 5 votes
public void initialize() throws Exception {
    String skin = ObjectUtils.toString(config.get("UISkin")).trim();
    String theme = ObjectUtils.toString(config.get("UITheme")).trim();
    
    if(skin.equalsIgnoreCase("default")) //java default
        return;
    
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    
    if(StringUtils.isNotEmpty(theme))
        SubstanceLookAndFeel.setCurrentTheme(theme);
    else if(StringUtils.isNotEmpty(skin))
        SubstanceLookAndFeel.setSkin((SubstanceSkin)newInstance(skin));
    String watermark = ObjectUtils.toString(config.get("UIWatermark")).trim();
    if(StringUtils.isNotEmpty(watermark))
        SubstanceLookAndFeel.setCurrentWatermark((SubstanceWatermark)newInstance(watermark));
    String buttonShaper = ObjectUtils.toString(config.get("UIButtonShaper")).trim();
    if(StringUtils.isNotEmpty(buttonShaper))
        SubstanceLookAndFeel.setCurrentButtonShaper((SubstanceButtonShaper)newInstance(buttonShaper));
    String borderPainter = ObjectUtils.toString(config.get("UIBorderPainter")).trim();
    if(StringUtils.isNotEmpty(borderPainter))
        SubstanceLookAndFeel.setCurrentBorderPainter((SubstanceBorderPainter)newInstance(borderPainter));
    String gradientPainter = ObjectUtils.toString(config.get("UIGradientPainter")).trim();
    if(StringUtils.isNotEmpty(gradientPainter))
        SubstanceLookAndFeel.setCurrentGradientPainter((SubstanceGradientPainter)newInstance(gradientPainter));
}
 
Example 12
Project: unitstack   File: ListObjectsResponder.java   View Source Code Vote up 5 votes
private List<S3Object> filterS3Objects(List<S3Object> objects, String marker, String prefix,
    int maxObjects) {
  int skip = 0;
  if (StringUtils.isNotEmpty(marker)) {
    skip = IntStream.range(0, objects.size())
        .filter(index -> !StringUtils.equals(objects.get(index).getKey(), marker)).findFirst()
        .orElse(0);
  }
  return objects.stream().filter(s3Object -> hasObjectKeyPrefixIfExists(prefix, s3Object))
      .skip(skip).limit(maxObjects).collect(Collectors.toList());
}
 
Example 13
Project: Biliomi   File: SortDirectiveQueryProcessor.java   View Source Code Vote up 5 votes
/**
 * Use the "sort" query parameter to sort a list of entities.
 * - Chains sorting directives in order of appearance
 * - Supports sorting on sub-properties by providing the path as "Property.SubProperty".
 *
 * @param entities    The list of entities to sort
 * @param queryParams A map with the value of the "sort" query parameter
 * @return The sorted list of entities
 * @throws IOException When Jackson is unnable to unmarshal the sorting directives
 */

@Override
public List<T> process(List<T> entities, Map<String, Object> queryParams) throws Exception {
  if (entities.size() > 1 && queryParams.containsKey(PARAM_NAME_SORT)) {
    try {
      String sorters = (String) queryParams.get(PARAM_NAME_SORT);
      Collection<RestSortDirective> sortDirectives = null;
      // noinspection unchecked This error is inevitable depending on user input
      Class<T> rootClass = (Class<T>) entities.get(0).getClass();

      if (StringUtils.isNotEmpty(sorters)) {
        sortDirectives = JacksonMarshaller.unmarshalCollection(sorters, RestSortDirective.class);
      }

      if (sortDirectives != null && sortDirectives.size() > 0) {
        Comparator<T> comparatorChain = buildComparatorChain(sortDirectives, rootClass);

        //noinspection unchecked ComparatorChain implements Comparator
        entities.sort(comparatorChain);
      }
    } catch (Exception e) {
      LogManager.getLogger(this.getClass()).error(e);
      throw e;
    }
  }

  return entities;
}
 
Example 14
Project: atlas   File: AwoPropHandler.java   View Source Code Vote up 5 votes
public void process(TBuildType buildType, BundleConfig bundleConfig) throws Exception {

        String propfile = EnvHelper.getEnv("awoprop");

        if (StringUtils.isEmpty(propfile)) {
            return;
        }

        Properties properties = new Properties();
        properties.load(new FileInputStream(propfile));

        String ap_path = properties.getProperty(AP_PATH);
        boolean refresh_ap = "true".equals(properties.getProperty(REFRESH_AP));
        String mtl_url = properties.getProperty(MTL_URL);

        if (!refresh_ap && StringUtils.isNotEmpty(ap_path) && new File(ap_path).exists()) {
            //not need download
            System.out.println("[awo] ap file exist");
        }

        if (StringUtils.isEmpty(mtl_url)) {
            throw new StopExecutionException("mtl_url is not configed");
        }

        ap_path = ApDownloader.downloadAP(mtl_url, new File(propfile).getParentFile()).getAbsolutePath();
        properties.setProperty(AP_PATH, ap_path);
        properties.store(new FileOutputStream(propfile), "update path");

        buildType.setBaseApFile(new File(ap_path));

        bundleConfig.setAwoBuildEnabled(true);
        bundleConfig.setAwoDynDeploy("true".equals(properties.getProperty(SUPPORT_DYN, "true")));
        bundleConfig.setAwoApkBuild("true".equals(properties.getProperty(SUPPORT_APK, "true")));
    }
 
Example 15
Project: RestyPass   File: RestyServiceProcessor.java   View Source Code Vote up 5 votes
/**
 * Sets fallback.
 *
 * @param restyService the resty service
 * @param properties   the properties
 */
protected void setFallback(RestyService restyService, RestyCommandConfig properties) {
    properties.setFallbackEnabled(restyService.fallbackEnabled());

    //fallback class
    properties.setFallbackClass(restyService.fallbackClass());
    // com.github.df.restypass.servertest.entity name
    if (StringUtils.isNotEmpty(restyService.fallbackBean())) {
        properties.setFallbackBean(restyService.fallbackBean());
    }
}
 
Example 16
Project: uncode-scheduler   File: ZKManager.java   View Source Code Vote up 5 votes
public List<String> getIpBlacklist() {
    List<String> ips = new ArrayList<String>();
    String list = this.properties.getProperty(KEYS.ipBlacklist.key);
    if (StringUtils.isNotEmpty(list)) {
        ips = Arrays.asList(list.split(","));
    }
    return ips;
}
 
Example 17
Project: AEM   File: AssetPathServiceImpl.java   View Source Code Vote up 5 votes
/**
 * @param componentResource A content resource containing a fileReference property.
 * @param renditionName The name of the rendition node
 * @param assetIndex The position of the asset path under the resource
 * @return componentAssetPath The path to the image
 */
public String getComponentAssetPath(Resource componentResource, String renditionName, int assetIndex) throws Exception {
    renditionName = renditionName.isEmpty()? getRenditionName(componentResource) : renditionName;
    String imagePath = BLANK;
    if(null != componentResource){
        if(ImageUtils.hasContent(componentResource, assetIndex)) {
            String fileReference;
            if (assetIndex == -1) {
                fileReference = ResourceUtils.getPropertyAsString(componentResource, FILE_REFERENCE);
            } else {
                List<String> fileReferences = ResourceUtils.getPropertyAsStrings(componentResource, FILE_REFERENCES);
                fileReference = fileReferences.get(assetIndex);
            }
            String fileName = Text.getName(fileReference);
            if (StringUtils.isNotEmpty(renditionName)) {
                Resource damAssetResource = componentResource.getResourceResolver().getResource(fileReference);
                if(ImageUtils.isImage(damAssetResource)) {
                    imagePath = buildAssetPath(componentResource.getPath(), renditionName, fileName, assetIndex);
                } else {
                    imagePath = buildAssetPath(componentResource.getPath(), fileName, assetIndex);
                }
            } else {
                imagePath = buildAssetPath(componentResource.getPath(), fileName, assetIndex);
            }
        }
    }
    return imagePath;
}
 
Example 18
Project: AEM   File: ImageUtils.java   View Source Code Vote up 5 votes
@Deprecated
public static String getImagePath(Resource resource, String renditionName){
    String imagePath = "";
    if(null != resource){
        if(hasContent(resource)){
            if (StringUtils.isNotEmpty(renditionName)) {
                imagePath = getTransformedImagePath(resource, renditionName);
            } else {
                imagePath = getSrc(resource);
            }
        }
    }
    return imagePath;
}
 
Example 19
Project: chat-sdk-android-push-firebase   File: AbstractNetworkAdapter.java   View Source Code Vote up 4 votes
public boolean backendlessEnabled(){
    return StringUtils.isNotEmpty(context.getString(R.string.backendless_app_id)) && StringUtils.isNotEmpty(context.getString(R.string.backendless_secret_key));
}
 
Example 20
Project: lemcloud   File: DateUtil.java   View Source Code Vote up 4 votes
public static boolean isDate(String dateAsText) {
    return StringUtils.isNotEmpty(dateAsText) && dateAsText.matches(DATE_PATTERN);
}