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

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

Introduction

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

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty ("") and not null.

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

Usage

From source file:com.bellman.bible.android.control.readingplan.ReadingPlanControl.java

/**
 * allow front end to determine if a plan needs has been selected
 *//* ww w  .  ja v  a  2s . c  o m*/
public boolean isReadingPlanSelected() {
    return StringUtils.isNotEmpty(getCurrentPlanCode());
}

From source file:edu.purdue.cybercenter.dm.activiti.CrisUserManager.java

public List<User> findUserByQueryCriteria(Object query, Page page) {
    List<User> userList = new ArrayList<>();
    UserQueryImpl userQuery = (UserQueryImpl) query;

    if (StringUtils.isNotEmpty(userQuery.getId())) {
        userList.add(findUserById(userQuery.getId()));
        return userList;
    } else if (StringUtils.isNotEmpty(userQuery.getLastName())) {
        userList.add(findUserById(userQuery.getLastName()));
        return userList;
    } else {//  ww w .ja v a2  s. c o  m
        //TODO: get all users from your identity domain and convert them to List<User>
        return null;
    } //TODO: you can add other search criteria that will allow extended support using the Activiti engine API

}

From source file:com.glaf.core.context.ApplicationContext.java

public static void setContextPath(String pContextPath) {
    if (StringUtils.isNotEmpty(pContextPath)) {
        if (StringUtils.isEmpty(contextPath)) {
            contextPath = pContextPath;/*w  w w .ja v a2  s  .  c  om*/
        }
    }
}

From source file:com.glaf.core.todo.config.TodoConfig.java

public static void reload() {
    if (!loading.get()) {
        try {/*from  w  ww .  j  a v  a  2  s  . c o m*/
            loading.set(true);
            ISysTodoService todoService = ContextFactory.getBean("sysTodoService");
            List<Todo> list = todoService.getTodoList();
            if (list != null && !list.isEmpty()) {
                for (Todo todo : list) {
                    todoMap.put(todo.getCode(), todo);
                    todoMap.put(String.valueOf(todo.getId()), todo);
                    if (StringUtils.isNotEmpty(todo.getProcessName())) {
                        String key = todo.getProcessName();
                        if (!todoMap.containsKey(key)) {
                            todoMap.put(key, todo);
                        }
                        if (StringUtils.isNotEmpty(todo.getTaskName())) {
                            key = key + "_" + todo.getTaskName();
                            if (!todoMap.containsKey(key)) {
                                todoMap.put(key, todo);
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        } finally {
            loading.set(false);
        }
    }
}

From source file:com.adobe.cq.wcm.core.components.testing.MockAdapterFactory.java

@Override
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType getAdapter(Object o, Class<AdapterType> aClass) {
    if (aClass == ContentPolicyMapping.class && o instanceof Resource) {
        Resource resource = (Resource) o;
        ValueMap valueMap = resource.getValueMap();
        String policyPath = valueMap.get("cq:policy", StringUtils.EMPTY);
        Resource policyMappingResource = null;
        if (StringUtils.isNotEmpty(policyPath)) {
            policyMappingResource = resource;
        } else {/*w  w w.j  a  v  a  2 s .  c  om*/
            PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
            if (pageManager != null) {
                Page page = pageManager.getContainingPage(resource);
                if (page != null) {
                    Template template = page.getTemplate();
                    if (template != null && page.getPath().startsWith(template.getPath() + "/")) {
                        // in template; resolve relative to policies node
                        policyPath = template.getPath() + "/policies/"
                                + resource.getPath().replace(template.getPath() + "/structure/", "");
                        policyMappingResource = resource.getResourceResolver().getResource(policyPath);
                    }
                }
            }
        }
        if (policyMappingResource != null) {
            return (AdapterType) new MockContentPolicyMapping(policyMappingResource);
        }
    }
    return null;
}

From source file:com.google.code.siren4j.condition.NotEmptyCondition.java

public boolean evaluate(Object obj) {
    if (obj == null) {
        return false;
    }/*from  www .ja  v a  2 s  .co m*/
    boolean result = true;
    if (obj instanceof String) {
        result = StringUtils.isNotEmpty((String) obj);
    } else if (obj instanceof Collection<?>) {
        result = !((Collection<?>) obj).isEmpty();
    } else if (obj instanceof Map<?, ?>) {
        result = !((Map<?, ?>) obj).isEmpty();
    } else if (obj instanceof Object[]) {
        result = ArrayUtils.isNotEmpty((Object[]) obj);
    } else if (ComponentUtils.isNumeric(obj)) {
        result = ((Number) obj).intValue() != 0;
    } else if (obj instanceof Boolean) {
        throw new Siren4JRuntimeException("Unsupported value type for 'NOTEMPTY' condition: Boolean");
    }
    return result;
}

From source file:br.com.rzandonai.web.controller.UserProcessorImpl.java

public ResponseEntity processUser(final HttpServletRequest request, final User.Provider provider,
        final String id, final String displayName, final String email, final String picture, final String name,
        final String givenName, final String familyName) throws JOSEException, ParseException {

    User user = null;/*from  w  w  w  . j  a  va  2  s  . c o m*/
    switch (provider) {
    case FACEBOOK:
        user = userService.findByFacebook(id);
        break;
    case GOOGLE:
        user = userService.findByGoogle(id);
        break;
    default:
        return new ResponseEntity<String>("Unknown OAUTH2.0 Provider", HttpStatus.NOT_FOUND);
    }

    //If not found by provider try to find it by email
    if (user == null && StringUtils.isNotEmpty(email)) {
        user = userService.findByEmail(email);
    }

    // Step 3a. If user is already signed in then link accounts.
    User userToSave;
    final String authHeader = request.getHeader(AuthUtils.AUTH_HEADER_KEY);
    if (StringUtils.isNotBlank(authHeader)) {
        if (user == null) {
            return new ResponseEntity<String>(String.format(CONFLICT_MSG, provider.capitalize()),
                    HttpStatus.CONFLICT);
        }
        final String subject = AuthUtils.getSubject(authHeader);
        final User foundUser = userService.findOne(subject);
        if (foundUser == null) {
            return new ResponseEntity<String>(NOT_FOUND_MSG, HttpStatus.NOT_FOUND);
        }

        userToSave = foundUser;
        boolean updated = setUserProvider(provider, userToSave, id);
        if (userToSave.getDisplayName() == null) {
            userToSave.setDisplayName(displayName);
            updated = true;
        }
        if (userToSave.getPicture() == null) {
            userToSave.setPicture(picture);
            updated = true;
        }

        if (updated) {
            userToSave = userService.save(userToSave);
        }
    } else {
        // Step 3b. Create a new user account or return an existing one.
        if (user != null) {
            userToSave = user;
            if (setUserProvider(provider, userToSave, id)) {
                if (userToSave.getPicture() == null) {
                    userToSave.setPicture(picture);
                }
                userToSave = userService.save(userToSave);
            }
        } else {
            userToSave = new User();
            userToSave.setId(UUID.randomUUID().toString());
            userToSave.setDisplayName(displayName);
            userToSave.setEmail(email);
            userToSave.setName(name);
            userToSave.setGivenName(givenName);
            userToSave.setPicture(picture);
            userToSave.setFamilyName(familyName);

            setUserProvider(provider, userToSave, id);
            userToSave = userService.save(userToSave);
        }
    }

    Token token = AuthUtils.createToken(request.getRemoteHost(), userToSave.getId());
    return new ResponseEntity<Token>(token, HttpStatus.OK);
}

From source file:com.glaf.core.web.springmvc.MxSystemMailConfigController.java

@RequestMapping("/save")
public ModelAndView save(ModelMap modelMap, HttpServletRequest request) {
    String jx_view = request.getParameter("jx_view");

    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }/*  w w w  .  j a v a  2 s.c om*/

    String x_view = ViewProperties.getString("sys_mail.save");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/sys/mail/save", modelMap);

}

From source file:com.nridge.core.base.std.XMLUtl.java

public static void setAttrDoubleValue(Element anElement, String aName, double aValue) {
    Double doubleObject;// w  w  w  .java 2  s .  c om

    if (StringUtils.isNotEmpty(aName)) {
        doubleObject = aValue;
        anElement.setAttribute(aName, doubleObject.toString());
    }
}

From source file:com.mirth.connect.model.converters.ChannelConverter.java

@Override
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    if (value instanceof InvalidChannel) {
        try {/*from   w w w  .  j a  v  a 2  s . co  m*/
            DonkeyElement element = new DonkeyElement(((InvalidChannel) value).getChannelXml());

            String version = element.getAttribute(ObjectXMLSerializer.VERSION_ATTRIBUTE_NAME);
            if (StringUtils.isNotEmpty(version)) {
                writer.addAttribute(ObjectXMLSerializer.VERSION_ATTRIBUTE_NAME, version);
            }

            for (DonkeyElement child : element.getChildElements()) {
                copier.copy(new XppReader(new StringReader(child.toXml()), new MXParser()), writer);
            }
        } catch (Exception e) {
            throw new SerializerException(e);
        }
    } else {
        super.marshal(value, writer, context);
    }
}