Example usage for org.apache.commons.lang3 StringUtils isEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isEmpty.

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:io.servicecomb.swagger.generator.springmvc.processor.annotation.DeleteMappingMethodAnnotationProcessor.java

@Override
public void process(Object annotation, OperationGenerator operationGenerator) {
    DeleteMapping mappingAnnotation = (DeleteMapping) annotation;
    Operation operation = operationGenerator.getOperation();

    // path/value?
    this.processPath(mappingAnnotation.path(), operationGenerator);
    this.processPath(mappingAnnotation.value(), operationGenerator);
    this.processMethod(RequestMethod.DELETE, operationGenerator);
    this.processConsumes(mappingAnnotation.consumes(), operation);
    this.processProduces(mappingAnnotation.produces(), operation);

    if (StringUtils.isEmpty(operationGenerator.getHttpMethod())
            && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) {
        throw new Error("HttpMethod must not both be empty in class and method");
    }//ww w  .j a  v a 2 s .co  m
}

From source file:com.esri.geoevent.test.performance.ui.ConsumerUI.java

@Override
public void start(Stage primaryStage) {

    String modeStr = "Consumer";
    if (StringUtils.isEmpty(modeStr)) {
        System.err.print(UIMessages.getMessage("STARTUP_ERROR_MODE_NULL")
                + UIMessages.getMessage("STARTUP_MODE_TYPES", Mode.getAllowableValues()));
        Platform.exit();/*  ww  w  .j a va  2  s .  c om*/
        System.exit(0);
        return;
    }

    Mode mode = Mode.fromValue(modeStr);
    String fxmlFile = "";
    Object controller = null;
    switch (mode) {

    case Consumer:
        fxmlFile = "PerformanceCollector.fxml";
        controller = new ConsumerController();
        break;

    default:
        System.err.print(UIMessages.getMessage("STARTUP_ERROR_MODE_UNKNOWN", mode)
                + UIMessages.getMessage("STARTUP_MODE_TYPES", Mode.getAllowableValues()));
        Platform.exit();
        System.exit(0);
        return;
    }

    Platform.setImplicitExit(true);
    try {
        FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFile));
        if (controller != null) {
            loader.setController(controller);
        }
        Parent parent = (Parent) loader.load();
        Scene scene = new Scene(parent);

        primaryStage.setOnCloseRequest(new AppCloser());
        primaryStage.setTitle(UIMessages.getMessage("UI_TITLE", mode));
        primaryStage.setScene(scene);
        primaryStage.show();
        ConsumerUI.primaryStage = primaryStage;
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.dgtlrepublic.anitomyj.AnitomyJ.java

/**
 * Removes the extension from the {@code filename}.
 *
 * @param filename  the ref that will be updated with the new filename
 * @param extension the ref that will be updated with the file extension
 * @return true if then extension was separated from the filename
 *///  ww  w . ja  v  a  2  s  . com
private static boolean removeExtensionFromFilename(AtomicReference<String> filename,
        AtomicReference<String> extension) {
    int position;
    if (StringUtils.isEmpty(filename.get()) || (position = filename.get().lastIndexOf('.')) == -1)
        return false;

    /** remove file extension */
    extension.set(filename.get().substring(position + 1));
    if (extension.get().length() > 4)
        return false;
    if (!StringHelper.isAlphanumericString(extension.get()))
        return false;

    /** check if valid anime extension */
    String keyword = KeywordManager.normalzie(extension.get());
    if (!KeywordManager.getInstance().contains(kElementFileExtension, keyword))
        return false;

    filename.set(filename.get().substring(0, position));
    return true;
}

From source file:mobile.service.MobileService.java

/**
 * ?/*from ww  w.  j av a  2 s . c o  m*/
 * 
 * @return
 */
public static ServiceVOResult<CommonVO> getClientVersion() {
    String value = ConfigFactory.getString(Constants.APK_VERSION_INFO);
    if (StringUtils.isEmpty(value)) {
        ObjectNodeResult result = new ObjectNodeResult();
        result.errorkey("mobile.apk.version.nofounddata");
        return ServiceVOResult.create(result);
    }
    String[] args = value.split(",");
    if (args.length >= 3) {
        String version = args[0].trim();
        String versionName = args[1].trim();
        String downloadURL = args[2].trim();

        CommonVO vo = CommonVO.create();
        vo.set("version", version);
        vo.set("versionName", versionName);
        vo.set("downloadURL", downloadURL);

        return ServiceVOResult.success(vo);
    } else {
        ObjectNodeResult result = new ObjectNodeResult();
        result.errorkey("mobile.apk.version.nofounddata");
        return ServiceVOResult.create(result);
    }
}

From source file:ch.sbb.releasetrain.git.GITAccessor.java

@PostConstruct
public void init() {

    String configUrl = System.getProperty("config.url");
    String configBranch = System.getProperty("config.branch");
    String configUser = System.getProperty("config.user");
    String configPassword = System.getProperty("config.password");

    userhome = System.getProperty("user.home");

    if (!StringUtils.isEmpty(configUrl) && !StringUtils.isEmpty(configBranch)
            && !StringUtils.isEmpty(configUser) && !StringUtils.isEmpty(configPassword)) {
        model = new GitModel("", configUrl, configBranch, configUser, configPassword);
    } else {/*from   w  w w  .  java2  s.c  o  m*/
        File file = new File(userhome + "/.releasetrain/gitConfig.yaml");
        String str = "";
        if (file.exists()) {
            try {
                str = FileUtils.readFileToString(file);
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
            Yaml yaml = new Yaml();
            yaml.setBeanAccess(BeanAccess.FIELD);
            model = (GitModel) yaml.load(str);

        } else {
            model = new GitModel("", "", "", "", "");
        }
    }
    writeModel();
    reset();
}

From source file:com.ludgerpeters.acl.AuthenticationFilterImp.java

@Override
public Result filter(FilterChain filterChain, Context context) {
    logger.info("Filter hit with url: " + context.getRequestPath());
    Session session = context.getSession();
    AuthenticationAcl aclAnnotation = context.getRoute().getControllerMethod()
            .getAnnotation(AuthenticationAcl.class);
    if (aclAnnotation == null) {
        aclAnnotation = context.getRoute().getControllerClass().getAnnotation(AuthenticationAcl.class);
    }//from   w w w  .j  a v  a2 s. c  om
    String userId = session.get("user.id");
    if (StringUtils.isEmpty(userId)) {
        logger.info("User ID is empty");
        //@TODO need to add redirection logic
    } else {
        logger.info("User ID is not empty it is : " + userId);
        if (aclAnnotation != null) {
            if (validatePermissions(userId, aclAnnotation, context)) {
                logger.info("User Passes the permission check");
                return filterChain.next(context);
            } else {
                //@TODO need to add redirection logic to redirect here
                logger.info("User Does not have sufficient privileges");
            }
        }
    }
    return filterChain.next(context);
}

From source file:com.thruzero.common.core.support.ValueTransformer.java

public String getStringValue(final String defaultValue) {
    String result = getStringValue();

    return StringUtils.isEmpty(result) ? defaultValue : result;
}

From source file:com.adobe.cq.wcm.core.components.internal.resource.ImageResourceWrapper.java

public ImageResourceWrapper(@Nonnull Resource resource, @Nonnull String resourceType) {
    super(resource);
    if (StringUtils.isEmpty(resourceType)) {
        throw new IllegalArgumentException(
                "The " + ImageResourceWrapper.class.getName() + " needs to override the resource type of "
                        + "the wrapped resource, but the resourceType argument was null or empty.");
    }//from   w w  w.  j av  a  2s.  c o  m
    this.resourceType = resourceType;
    valueMap = new ValueMapDecorator(new HashMap<>(resource.getValueMap()));
    valueMap.put(ResourceResolver.PROPERTY_RESOURCE_TYPE, resourceType);
}

From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiI18NAjaxEditActionBean.java

protected List<Pair<String, GWikiI18NArtefakt>> getArtefakts() {
    if (StringUtils.isEmpty(pageId) == true || StringUtils.isEmpty(key) == true) {
        wikiContext.addSimpleValidationError("pageId or key is not set");
        return null;
    }//www . j a  va 2s.  c  o  m
    GWikiElement el = wikiContext.getWikiWeb().findElement(pageId);
    if ((el instanceof GWikiI18nElement) == false) {
        wikiContext.addSimpleValidationError("Cannot find pageId or not i18n: " + pageId);
        return null;
    }
    i18El = (GWikiI18nElement) el;
    Map<String, GWikiArtefakt<?>> map = new HashMap<String, GWikiArtefakt<?>>();
    List<Pair<String, GWikiI18NArtefakt>> ret = new ArrayList<Pair<String, GWikiI18NArtefakt>>();
    i18El.collectParts(map);
    for (Map.Entry<String, GWikiArtefakt<?>> me : map.entrySet()) {
        if ((me.getValue() instanceof GWikiI18NArtefakt) == false) {
            continue;
        }
        ret.add(Pair.make(me.getKey(), (GWikiI18NArtefakt) me.getValue()));
    }
    return ret;
}

From source file:com.mocktpo.api.LicenseApiController.java

@RequestMapping(value = "/api/licenses/require", method = RequestMethod.POST)
public ResponseEntity<Void> require(@RequestBody RequireActivationVo vo) {
    logger.debug("{}.{}() accessed.", this.getClass().getSimpleName(),
            Thread.currentThread().getStackTrace()[1].getMethodName());
    String email = vo.getEmail();
    String hardware = vo.getHardware();
    List<License> lz = service.findByEmail(email);
    if (null != lz && lz.size() > 0) { // email exists, filled in by agents previously.
        License lic = lz.get(0);//from w  w w  . j ava 2 s .  co  m
        String licensedHardware = lic.getHardware();
        if (StringUtils.isEmpty(licensedHardware)) { // hardware remains blank
            lic.setHardware(hardware);
            Date date = new Date();
            lic.setDateUpdated(date);
            service.update(lic);
            EmailUtils.sendActivationCode(lic);
            return ResponseEntity.ok().build();
        } else {
            if (licensedHardware.equals(hardware)) { // same hardware registered
                EmailUtils.sendActivationCode(lic);
                return ResponseEntity.ok().build();
            } else {
                return ResponseEntity.status(HttpStatus.CONFLICT).build(); // different hardware registered
            }
        }
    } else {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); // email never exists
    }
}