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:ch.algotrader.dao.SubscriptionDaoImpl.java

@Override
public List<Subscription> findNonPositionSubscriptions(String strategyName) {

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

    return findCaching("Subscription.findNonPositionSubscriptions", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName));
}

From source file:com.edmunds.zookeeper.connection.ZooKeeperConfig.java

/**
 * Validates this ZooKeeper configuration.
 *//*from ww  w  .  j a va2 s .c o m*/
public void validate() {
    Validate.notEmpty(hostName, "ZooKeeper hostName not specified");
    Validate.isTrue(port > 0, "ZooKeeper port must be greater than zero");
    Validate.isTrue(sessionTimeout > 0, "ZooKeeper session timeout must be greater than zero");
    Validate.isTrue(dnsRetryCount >= 0, "ZooKeeper DNS lookup can not be negative");

    if (!StringUtils.isBlank(pathPrefix)) {
        if (!pathPrefix.startsWith("/")) {
            throw new IllegalArgumentException("ZooKeeper path prefix must start with '/'");
        } else if (pathPrefix.endsWith("/")) {
            throw new IllegalArgumentException("ZooKeeper path prefix must not end with '/'");
        }
    }
}

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

public static void copyFromJAXB(ObjectReferenceType jaxb, REmbeddedReference repo, PrismContext prismContext) {
    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.");

    repo.setType(ClassMapper.getHQLTypeForQName(jaxb.getType()));
    repo.setRelation(RUtil.qnameToString(jaxb.getRelation()));
    repo.setTargetOid(jaxb.getOid());/*from ww w  .ja  v  a  2  s . c  om*/

}

From source file:ch.algotrader.service.SubscriptionServiceImpl.java

/**
 * {@inheritDoc}/*  w w  w .ja v  a2s . c  o  m*/
 */
@Override
public void unsubscribeMarketDataEvent(final String strategyName, final long securityId,
        final String feedType) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notNull(feedType, "Feed type is null");

    this.marketDataService.unsubscribe(strategyName, securityId, feedType);

    initMarketDataEventSubscriptions();

}

From source file:it.gualtierotesta.gdocx.GTbl.java

/**
 * Set table look//from w  ww  .  ja  va  2s.  c o  m
 *
 * @param sLookValue look value (for ex. "01E0" )
 * @return same GTbl instance
 */
@Nonnull
public GTbl look(@Nonnull final String sLookValue) {

    Validate.notEmpty(sLookValue, "Look value not valid");

    final CTTblLook ctTblLook = FACTORY.createCTTblLook();
    ctTblLook.setVal(sLookValue);
    tblPr.setTblLook(ctTblLook);
    return this;
}

From source file:com.vmware.identity.idm.server.provider.localos.LocalOsIdentityProvider.java

public LocalOsIdentityProvider(IIdentityStoreData store) {
    Validate.notNull(store, "store Must not be null.");
    Validate.notNull(store.getExtendedIdentityStoreData(),
            "store.getExtendedIdentityStoreData() Must not be null.");

    Validate.notEmpty(store.getName(), "IIdentityStoreData MUST have a name.");
    Validate.isTrue(store.getDomainType() == DomainType.LOCAL_OS_DOMAIN,
            "IIdentityStoreData must represent a 'LOCAL_OS_DOMAIN'.");

    Validate.isTrue(/*from ww  w  .  j a v a 2  s. c  o m*/
            store.getExtendedIdentityStoreData()
                    .getProviderType() == IdentityStoreType.IDENTITY_STORE_TYPE_LOCAL_OS,
            "IIdentityStoreData must represent a store of " + "'IDENTITY_STORE_TYPE_LOCAL_OS' type.");

    Validate.notNull(store.getExtendedIdentityStoreData().getAttributeMap(),
            "store.getExtendedIdentityStoreData().getAttributeMap() Must not be null.");

    this._store = store;
}

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

public void updateProperty(String pStrProperty, String pStrValue) {

    mLog.debug("Start updateProperty(", pStrProperty, ",", pStrValue, ")");

    Validate.notEmpty(pStrProperty, "Property cannot be empty");
    SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance().getSqlSessionFactoryBibisco();
    SqlSession lSqlSession = lSqlSessionFactory.openSession();
    try {//from   w  ww.j av a  2 s .  co  m

        PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class);
        Properties lProperties = new Properties();
        lProperties.setProperty(pStrProperty);
        lProperties.setValue(pStrValue);
        lPropertiesMapper.updateByPrimaryKey(lProperties);
        mMapProperties.put(pStrProperty, pStrValue);

        lSqlSession.commit();

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

    mLog.debug("End updateProperty(", pStrProperty, ",", pStrValue, ")");
}

From source file:edu.snu.leader.hidden.personality.StandardUpdateRulePersonalityCalculator.java

/**
 * Initializes the updater/*from ww w.j a  v  a2s . co m*/
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.personality.PersonalityCalculator#initialize(edu.snu.leader.hidden.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( simState )");

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

    // Get the discount value
    String discountStr = props.getProperty(_DISCOUNT_KEY);
    Validate.notEmpty(discountStr, "Personality discount (key=" + _DISCOUNT_KEY + ") may not be empty");
    _discount = Float.parseFloat(discountStr);
    _LOG.info("Using _discount=[" + _discount + "]");

    // Get the true winner discount value
    String trueWinnerDiscountStr = props.getProperty(_TRUE_WINNER_DISCOUNT_KEY);
    if (null != trueWinnerDiscountStr) {
        _trueWinnerDiscount = Float.parseFloat(trueWinnerDiscountStr);
    } else {
        _trueWinnerDiscount = _discount;
    }
    _LOG.info("Using _trueWinnerDiscount=[" + _trueWinnerDiscount + "]");

    // Get the true loser discount value
    String trueLoserDiscountStr = props.getProperty(_TRUE_LOSER_DISCOUNT_KEY);
    if (null != trueLoserDiscountStr) {
        _trueLoserDiscount = Float.parseFloat(trueLoserDiscountStr);
    } else {
        _trueLoserDiscount = _discount;
    }
    _LOG.info("Using _trueLoserDiscount=[" + _trueLoserDiscount + "]");

    // Get the winner reward
    String winnerRewardStr = props.getProperty(_WINNER_REWARD_KEY);
    Validate.notEmpty(winnerRewardStr, "Winner reward (key=[" + _WINNER_REWARD_KEY + "]) may not be empty");
    _winnerReward = Float.parseFloat(winnerRewardStr);
    _LOG.info("Using _winnerReward=[" + _winnerReward + "]");

    // Get the loser penalty
    String loserPenaltyStr = props.getProperty(_LOSER_PENALTY_KEY);
    Validate.notEmpty(loserPenaltyStr, "Loser penalty (key=[" + _LOSER_PENALTY_KEY + "]) may not be empty");
    _loserPenalty = Float.parseFloat(loserPenaltyStr);
    _LOG.info("Using _loserPenalty=[" + _loserPenalty + "]");

    // Get the true winner effect flag
    String trueWinnerEffectStr = props.getProperty(_TRUE_WINNER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(trueWinnerEffectStr,
            "True winner effects active flag (key=[" + _TRUE_WINNER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _trueWinnerEffectActive = Boolean.parseBoolean(trueWinnerEffectStr);
    _LOG.info("Using _trueWinnerEffectActive=[" + _trueWinnerEffectActive + "]");

    // Get the true loser effect flag
    String trueLoserEffectStr = props.getProperty(_TRUE_LOSER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(trueLoserEffectStr,
            "True loser effects active flag (key=[" + _TRUE_LOSER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _trueLoserEffectActive = Boolean.parseBoolean(trueLoserEffectStr);
    _LOG.info("Using _trueLoserEffectActive=[" + _trueLoserEffectActive + "]");

    // 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 + "]");

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

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

@Override
public Transaction findByExtId(final String extId) {

    Validate.notEmpty(extId, "ExtId is empty");

    return findUnique("Transaction.findByExtId", QueryType.BY_NAME, new NamedParam("extId", extId));
}

From source file:edu.snu.leader.hidden.personality.DirectionUpdateRulePersonalityCalculator.java

/**
 * Initializes the updater//from ww  w .  j a v a 2  s.  c  o  m
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.personality.PersonalityCalculator#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
    _simState = simState;
    Properties props = simState.getProps();

    // Import the preferred directions
    String directionsFileStr = props.getProperty(_DIRECTIONS_FILE_KEY);
    Validate.notEmpty(directionsFileStr,
            "Directions file (key=[" + _DIRECTIONS_FILE_KEY + "]) may not be empty");
    _LOG.info("Using directionsFileStr=[" + directionsFileStr + "]");
    loadDirectionChanges(directionsFileStr);

    // Get the first direction
    DirectionChange first = _directionChanges.peek();
    if ((first != null) && (first.simIndex <= 0)) {
        // Save the data
        _direction = first.direction;
        _sigma = first.sigma;
        _gaussian = new Gaussian(0.0f, _sigma);
        _maxGaussianValue = 1.0f / (_sigma * (float) Math.sqrt(2.0f * Math.PI));
        _LOG.debug("Initial direction [" + _direction + "]");

        // Pull it off the queue
        _directionChanges.poll();
    }

    // Get the modify winner discount flag
    String modifyWinnerDiscountStr = props.getProperty(_MODIFY_WINNER_DISCOUNT_KEY);
    Validate.notEmpty(modifyWinnerDiscountStr,
            "Modify winner discount flag (key=[" + _MODIFY_WINNER_DISCOUNT_KEY + "]) may not be empty");
    _modifyWinnerDiscount = Boolean.parseBoolean(modifyWinnerDiscountStr);
    _LOG.info("Using _modifyWinnerDiscount=[" + _modifyWinnerDiscount + "]");

    // Get the modify winner reward flag
    String modifyWinnerRewardStr = props.getProperty(_MODIFY_WINNER_REWARD_KEY);
    Validate.notEmpty(modifyWinnerRewardStr,
            "Modify winner discount flag (key=[" + _MODIFY_WINNER_REWARD_KEY + "]) may not be empty");
    _modifyWinnerReward = Boolean.parseBoolean(modifyWinnerRewardStr);
    _LOG.info("Using _modifyWinnerReward=[" + _modifyWinnerReward + "]");

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