Example usage for org.apache.commons.lang Validate notEmpty

List of usage examples for org.apache.commons.lang Validate notEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang Validate notEmpty.

Prototype

public static void notEmpty(String string) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString); 

The message in the exception is 'The validated string is empty'.

Usage

From source file:com.vmware.identity.idm.IDPConfig.java

/**
 * set the upn suffix for the idp/* w w w . j  av  a  2  s .  c o  m*/
 * @param upnSuffix can be null, but otherwise cannot be empty
 */
public void setUpnSuffix(String upnSuffix) {
    if (upnSuffix != null) {
        Validate.notEmpty(upnSuffix);
    }
    this.upnSuffix = upnSuffix;
}

From source file:de.gmorling.scriptabledataset.ScriptableDataSet.java

/**
 * Creates a new ScriptableDataSet.//from  www.j  a va 2  s  .c  om
 * 
 * @param wrapped
 *            Another data set to be wrapped by this scriptable data set.
 *            Must not be null.
 * @param configurations
 *            At least one scriptable data set configuration.
 */
public ScriptableDataSet(IDataSet wrapped, ScriptableDataSetConfig... configurations) {

    Validate.notNull(wrapped);

    Validate.notNull(configurations);
    Validate.noNullElements(configurations);
    Validate.notEmpty(configurations);

    this.wrapped = wrapped;
    this.configurations = Arrays.asList(configurations);
}

From source file:hudson.plugins.clearcase.action.AbstractCheckoutAction.java

@Override
public boolean isViewValid(Launcher launcher, FilePath workspace, String viewTag)
        throws IOException, InterruptedException {
    Validate.notEmpty(viewPath);
    FilePath filePath = new FilePath(workspace, viewPath);
    boolean viewPathExists = filePath.exists();
    try {//www.j  a  va 2 s.  co m
        String currentViewTag = cleartool.lscurrentview(viewPath);
        return cleartool.doesViewExist(viewTag) && viewPathExists && viewTag.equals(currentViewTag);
    } catch (IOException e) {
        return false;
    }
}

From source file:com.vmware.identity.idm.server.AuthSessionFactoryCache.java

public void removeFactory(String tenantName) throws AuthenticationException {
    Validate.notEmpty(tenantName);
    AuthenticationSessionFactory api = _factoryLookup.remove(tenantName); //remove is thread safe
    if (api != null) {
        api.close();//from  w ww  .j ava 2  s .  com
    }

    logger.debug("Removed RSA AuthSessionFactory for tenant: " + tenantName);
}

From source file:com.netflix.simianarmy.aws.janitor.SimpleDBJanitorResourceTracker.java

/**
 * Returns a list of AWSResource objects. You need to override this method if more
 * specific resource types (e.g. subtypes of AWSResource) need to be obtained from
 * the SimpleDB./*w ww. ja v a  2s. c o m*/
 */
@Override
public List<Resource> getResources(ResourceType resourceType, CleanupState state, String resourceRegion) {
    Validate.notEmpty(resourceRegion);
    List<Resource> resources = new ArrayList<Resource>();
    StringBuilder query = new StringBuilder();
    query.append(String.format("select * from %s where ", domain));
    if (resourceType != null) {
        query.append(String.format("resourceType='%s' and ", resourceType));
    }
    if (state != null) {
        query.append(String.format("state='%s' and ", state));
    }
    query.append(String.format("region='%s'", resourceRegion));

    LOGGER.debug(String.format("Query is '%s'", query));

    List<Item> items = querySimpleDBItems(query.toString());
    for (Item item : items) {
        try {
            resources.add(parseResource(item));
        } catch (Exception e) {
            // Ignore the item that cannot be parsed.
            LOGGER.error(String.format("SimpleDB item %s cannot be parsed into a resource.", item));
        }
    }
    LOGGER.info(String.format(
            "Retrieved %d resources from SimpleDB in domain %s for resource type %s"
                    + " and state %s and region %s",
            resources.size(), domain, resourceType, state, resourceRegion));
    return resources;
}

From source file:com.dsh105.commodus.StringUtil.java

/**
 * Builds a sentence list from an array of strings.
 * Example: {"one", "two", "three"} returns "one, two and three".
 *
 * @param words The string array to build into a list,
 * @return String representing the list.
 *//*from w  ww.ja  v a 2 s  . com*/
public static String buildSentenceList(String... words) {
    Validate.notEmpty(words);
    if (words.length == 1) {
        return words[0];
    } else if (words.length == 2) {
        return combineArray(0, " and ", words);
    } else {
        // This is where the fun starts!
        String[] initial = Arrays.copyOfRange(words, 0, words.length - 1);
        String list = combineArray(0, ", ", initial);
        list += " and " + words[words.length - 1];
        return list;
    }
}

From source file:ca.uhn.hl7v2.testpanel.model.conf.ConformanceMessage.java

/**
 * {@inheritDoc}/*from  w  ww  .  j  a va  2  s .c  o  m*/
 */
@Override
public Structure get(String theName, int theRep) throws HL7Exception {
    Validate.notEmpty(theName);

    Structure retVal = mySupport.getNonStandardSegmentIfNameExists(theName, theRep);
    if (retVal != null) {
        return retVal;
    }

    Structure[] currentReps = getAll(theName);
    int currentRepsNum = currentReps.length;
    if (theRep > currentRepsNum) {
        throw new HL7Exception("Can't create rep " + theRep + " as there are currently only " + currentRepsNum);
    }

    if (theRep < currentRepsNum) {
        return super.get(theName, theRep);
    }

    if (getClass(theName) == GenericSegment.class) {
        retVal = super.get(theName, theRep);
    } else {
        retVal = mySupport.get(theName, theRep);
        insertRepetition(theName, retVal, theRep);
    }
    return retVal;
}

From source file:net.iglyduck.utils.sqlbuilder.ExpressUnit.java

protected ExpressUnit init(Object exp) {
    Validate.notNull(exp);//from ww w  . j av  a  2 s . c o m

    if (exp instanceof String) {
        Validate.notEmpty((String) exp);
    } else if (exp instanceof ExpressUnit) {
        Validate.isTrue(!((ExpressUnit) exp).isEmpty());
    } else {
        Validate.isTrue(false);
    }

    ExpressItem item = new ExpressItem().item(exp);

    head = item;
    tail = item;

    return this;
}

From source file:net.iglyduck.utils.sqlbuilder.TempTable.java

public TempTable group(String item) {
    Validate.notEmpty(item);

    if (groups == null) {
        groups = new ArrayList<String>();
    }/*from www . ja  va 2  s  .c  om*/

    groups.add(item);
    return this;
}

From source file:ar.com.zauber.garfio.config.impl.PropertiesConfiguration.java

/**
 * @param filename//from  www  .j  ava2  s .c  o m
 * @throws  IOException on error
 */
private static Properties getProperties(final String filename) throws IOException {
    Validate.notEmpty(filename);
    final Properties config = new Properties();
    config.load(new FileInputStream(filename));
    return config;
}