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, String message) 

Source Link

Document

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

 Validate.notEmpty(myString, "The string must not be empty"); 

Usage

From source file:net.femtoparsec.jwhois.gui.JWhoIsGUIModel.java

public JWhoIsGUIModel(GenericWhoIs<S> whoIs, JResultGUIFactory<S> jResultGUIFactory,
        Set<Source> proposedSources, Set<Source> selectedSources) {
    Validate.notNull(whoIs, "whoIs");
    Validate.notNull(jResultGUIFactory, "jResultGUIFactory");
    Validate.noNullElements(proposedSources, "proposedSources");
    Validate.notEmpty(proposedSources, "proposedSources");

    Validate.noNullElements(selectedSources, "selectedSources");

    this.whoIs = whoIs;
    this.proxy = null;
    this.jResultGUIFactory = jResultGUIFactory;
    this.preferredFormat = Format.RPSL;
    this.sources = new HashSet<Source>(proposedSources);
    this.selectedSources = new HashSet<Source>(CollectionUtils.intersection(proposedSources, selectedSources));
}

From source file:ch.algotrader.dao.TransactionDaoImpl.java

@Override
public List<Transaction> findCashflowsByStrategyAndMinDate(String strategyName, Date minDate) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notNull(minDate, "minDate is null");

    return findCaching("Transaction.findCashflowsByStrategyAndMinDate", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("minDate", minDate));
}

From source file:com.bibisco.manager.PropertiesManager.java

public void updateProperties(Map<String, String> pMapProperties) {

    mLog.debug("Start updateProperties(Map<String, String>)");

    Validate.notEmpty(pMapProperties, "Properties map cannot be empty");

    SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryBibisco();
    SqlSession lSqlSession = lSqlSessionFactory.openSession();

    try {/*from www.  j a va  2  s  .  c o m*/

        PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class);
        for (String lStrProperty : pMapProperties.keySet()) {
            Properties lProperties = new Properties();
            lProperties.setProperty(lStrProperty);
            lProperties.setValue(pMapProperties.get(lStrProperty));
            lPropertiesMapper.updateByPrimaryKey(lProperties);
            mMapProperties.put(lStrProperty, pMapProperties.get(lStrProperty));
        }

        lSqlSession.commit();

    } catch (Throwable t) {
        mLog.error(t);
        lSqlSession.rollback();
        throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION);
    } finally {
        lSqlSession.close();
    }

    mLog.debug("End updateProperties()");
}

From source file:ch.algotrader.dao.security.CombinationDaoImpl.java

@Override
public List<Combination> findSubscribedByStrategyAndComponentType(String strategyName,
        Class<? extends Security> type) {

    Validate.notEmpty(strategyName, "Strategy name is empty");

    return findCaching("Combination.findSubscribedByStrategyAndComponentType", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("type", type.getSimpleName()));
}

From source file:com.evolveum.midpoint.repo.sql.data.common.embedded.REmbeddedNamedReference.java

public static void copyFromJAXB(ObjectReferenceType jaxb, REmbeddedNamedReference repo,
        PrismContext prismContext) {/*from w w  w .  j  a v  a 2  s  .c  o m*/
    Validate.notNull(repo, "Repo object must not be null.");
    Validate.notNull(jaxb, "JAXB object must not be null.");
    Validate.notEmpty(jaxb.getOid(), "Target oid must not be null.");
    REmbeddedReference.copyFromJAXB(jaxb, repo, prismContext);

    repo.setTargetName(RPolyString.copyFromJAXB(jaxb.getTargetName()));
}

From source file:com.beyondjservlet.gateway.servlet.HttpMappingRuleResolver.java

public HttpMappingResult findMappingRule(String contextPath) {

    Validate.notEmpty(contextPath, "contextPath must not be empty");

    if (contextPath == null) {
        return null;
    }/*from w  w  w  . ja  va2  s. c o m*/

    if (!contextPath.equals("/") && !contextPath.startsWith("/")) {
        contextPath = "/" + contextPath;
    }

    MappingResult answer = null;
    if (contextPath != null && contextPath.length() > 0 && !contextPath.equals("/")) {
        answer = resolver.findWebContextMappingRule(contextPath);
    }
    return answer != null ? new HttpMappingResult(answer) : null;
}

From source file:net.camelpe.extension.camel.spi.CdiRegistry.java

/**
 * @see org.apache.camel.spi.Registry#lookup(java.lang.String,
 *      java.lang.Class)/*from   ww  w  .  j a  v a 2  s  .  c  o m*/
 */
@Override
public <T> T lookup(final String name, final Class<T> type) {
    Validate.notEmpty(name, "name");
    Validate.notNull(type, "type");
    getLog().trace("Looking up bean using name = [{}] having expected type = [{}] in CDI registry ...", name,
            type.getName());

    return type.cast(lookup(name));
}

From source file:ch.algotrader.dao.security.SecurityDaoImpl.java

@Override
public Security findByRic(String ric) {

    Validate.notEmpty(ric, "ric is empty");

    return findUniqueCaching("Security.findByRic", QueryType.BY_NAME, new NamedParam("ric", ric));
}

From source file:io.cloudslang.lang.compiler.scorecompiler.ScoreCompilerImpl.java

@Override
public CompilationModellingResult compileSource(Executable executable, Set<Executable> path) {
    List<RuntimeException> exceptions = new ArrayList<>();
    Map<String, Executable> filteredDependencies = new HashMap<>();
    //we handle dependencies only if the file has imports
    boolean hasDependencies = CollectionUtils.isNotEmpty(executable.getExecutableDependencies())
            && executable.getType().equals(SlangTextualKeys.FLOW_TYPE);
    if (hasDependencies) {
        try {//  w ww.  j  a  v a 2s. co  m
            Validate.notEmpty(path, "Source " + executable.getName()
                    + " has dependencies but no path was given to the compiler");
            Validate.noNullElements(path, "Source " + executable.getName() + " has empty dependencies");
        } catch (RuntimeException ex) {
            exceptions.add(ex);
        }

        //we add the current executable since a dependency can require it
        List<Executable> availableExecutables = new ArrayList<>(path);
        availableExecutables.add(executable);

        try {
            //than we match the references to the actual dependencies
            filteredDependencies = dependenciesHelper.matchReferences(executable, availableExecutables);

            handleOnFailureCustomResults(executable, filteredDependencies);

            List<RuntimeException> errors = compileValidator.validateModelWithDependencies(executable,
                    filteredDependencies);
            exceptions.addAll(errors);
        } catch (RuntimeException ex) {
            exceptions.add(ex);
        }

    }

    try {
        //next we create an execution plan for the required executable
        ExecutionPlan executionPlan = compileToExecutionPlan(executable);

        //and also create execution plans for all other dependencies
        Converter<Executable, ExecutionPlan> converter = new Converter<Executable, ExecutionPlan>() {
            @Override
            public ExecutionPlan convert(Executable compiledExecutable) {
                return compileToExecutionPlan(compiledExecutable);
            }
        };
        Map<String, ExecutionPlan> dependencies = convertMap(filteredDependencies, converter);
        Collection<Executable> executables = new ArrayList<>(filteredDependencies.values());
        executables.add(executable);

        HashSet<String> subflowsUuids = new HashSet<>(dependencies.keySet());
        subflowsUuids.addAll(executable.getExternalExecutableDependencies());
        executionPlan.setSubflowsUUIDs(subflowsUuids);
        CompilationArtifact compilationArtifact = new CompilationArtifact(executionPlan, dependencies,
                executable.getInputs(), getSystemPropertiesFromExecutables(executables));
        return new CompilationModellingResult(compilationArtifact, exceptions);
    } catch (RuntimeException ex) {
        exceptions.add(ex);
    }
    return new CompilationModellingResult(null, exceptions);
}

From source file:edu.snu.leader.hidden.builder.ForcedPersonalityDistributionIndividualBuilder.java

/**
 * Initializes the builder//from  ww  w.  ja va  2  s .co  m
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.builder.AbstractIndividualBuilder#initialize(edu.snu.leader.hidden.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( simState )");

    // Call the superclass implementation
    super.initialize(simState);

    // Get the properties
    Properties props = simState.getProps();

    // Get the min personality
    String minPersonalityStr = props.getProperty(_MIN_PERSONALITY_KEY);
    Validate.notEmpty(minPersonalityStr,
            "Minimum personality value (key=" + _MIN_PERSONALITY_KEY + ") may not be empty");
    _minPersonality = Float.parseFloat(minPersonalityStr);
    _LOG.info("Using _minPersonality=[" + _minPersonality + "]");

    // Get the max personality
    String maxPersonalityStr = props.getProperty(_MAX_PERSONALITY_KEY);
    Validate.notEmpty(maxPersonalityStr,
            "Maximum personality value (key=" + _MAX_PERSONALITY_KEY + ") may not be empty");
    _maxPersonality = Float.parseFloat(maxPersonalityStr);
    _LOG.info("Using _maxPersonality=[" + _maxPersonality + "]");

    // Get the max personality individual count
    String maxPersonalityIndCountStr = props.getProperty(_MAX_PERSONALITY_IND_COUNT_KEY);
    Validate.notEmpty(maxPersonalityStr, "Maximum personality individual count value (key="
            + _MAX_PERSONALITY_IND_COUNT_KEY + ") may not be empty");
    _maxPersonalityIndCount = Integer.parseInt(maxPersonalityIndCountStr);
    _LOG.info("Using _maxPersonalityIndCount=[" + _maxPersonalityIndCount + "]");

    _LOG.trace("Leaving initialize( simState )");
}