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.service.ib.IBFixAllocationServiceImpl.java

/**
 * {@inheritDoc}//from  www .  j  a va 2s  .  c  o  m
 */
@Override
@ManagedOperation(description = "Adds an Account Group to the specified Account.")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "account", description = "account"),
        @ManagedOperationParameter(name = "group", description = "group"),
        @ManagedOperationParameter(name = "defaultMethod", description = "The default allocation method to be used by this Account Group."),
        @ManagedOperationParameter(name = "initialChildAccount", description = "The first Child Account to add to this Account Group.") })
public void addGroup(final String account, final String group, final String defaultMethod,
        final String initialChildAccount) {

    Validate.notEmpty(account, "Account is empty");
    Validate.notEmpty(group, "Group is empty");
    Validate.notEmpty(defaultMethod, "Default method is empty");
    Validate.notEmpty(initialChildAccount, "Initial child account is empty");

    try {
        requestGroups(account);
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
        throw new ServiceException(ex);
    } catch (SessionNotFound ex) {
        throw new ExternalServiceException(ex);
    }

    Group groupObject = new Group(group, defaultMethod);
    groupObject.add(initialChildAccount);

    this.groups.add(groupObject);

    try {
        postGroups(account);
    } catch (SessionNotFound ex) {
        throw new ExternalServiceException(ex);
    }

}

From source file:com.manpowergroup.cn.core.utils.Reflections.java

/**
 * ?, ?DeclaredMethod,?.//from  w  ww . ja  v  a  2s .c o m
 * ?Object?, null.
 * ???+?
 * 
 * ?. ?Method,?Method.invoke(Object obj, Object... args)
 */
public static Method getAccessibleMethod(final Object obj, final String methodName,
        final Class<?>... parameterTypes) {
    Validate.notNull(obj, "object can't be null");
    Validate.notEmpty(methodName, "methodName can't be blank");

    for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType
            .getSuperclass()) {
        try {
            Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
            makeAccessible(method);
            return method;
        } catch (NoSuchMethodException e) {
            // Method??,?
        }
    }
    return null;
}

From source file:face4j.DefaultFaceClient.java

/**
 * @see {@link FaceClient#removeTags(String)}
 *///from   www.j  a  va  2s  . c om
public List<RemovedTag> removeTags(final String tids) throws FaceClientException, FaceServerException {
    Validate.notEmpty(tids, "Tag ids cannot be empty");

    final Parameters params = new Parameters("tids", tids);
    final String json = executePost(Api.REMOVE_TAGS, params);
    final RemoveTagResponse response = new RemoveTagResponseImpl(json);

    return response.getRemovedTags();
}

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

@Override
public List<Security> findSubscribedByFeedTypeAndStrategyInclFamily(String feedType, String strategyName) {

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

    return findCaching("Security.findSubscribedByFeedTypeAndStrategyInclFamily", QueryType.BY_NAME,
            new NamedParam("feedType", feedType), new NamedParam("strategyName", strategyName));
}

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

public static void copyFromJAXB(ObjectReferenceType jaxb, RObjectReference 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  w  ww  .  jav a 2  s .c o m
}

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

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

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

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

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

@Override
public Order createOrderByOrderPreference(final String name) {

    Validate.notEmpty(name, "Name is empty");

    OrderPreference orderPreference = this.orderPreferenceDao.findByName(name);
    if (orderPreference == null) {
        throw new ServiceException("Order preference '" + name + "' not found");
    }//ww  w .j a  v  a2s. c  o m
    Class<?> orderClazz;
    Order order;
    try {

        // create an order instance
        orderClazz = Class.forName(orderPreference.getOrderType().getValue());
        order = (Order) orderClazz.newInstance();

        // populate the order with the properties
        BeanUtil.populate(order, orderPreference.getPropertyNameValueMap());

    } catch (ReflectiveOperationException e) {
        throw new ServiceException(e);
    }

    // set the account if defined
    if (orderPreference.getDefaultAccount() != null) {
        order.setAccount(orderPreference.getDefaultAccount());
    }

    return order;
}

From source file:ch.algotrader.adapter.fix.DefaultFixAdapter.java

@Override
public void openSessionForService(String orderServiceType) throws BrokerAdapterException {

    Validate.notEmpty(orderServiceType, "Order service type is empty");

    Collection<String> sessionQualifiers = this.lookupService
            .getActiveSessionsByOrderServiceType(orderServiceType);
    if (sessionQualifiers == null || sessionQualifiers.isEmpty()) {

        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("There are no active sessions for order service type {}", orderServiceType);
        }//  w  ww  . jav a  2 s . co m
        return;
    }
    for (String sessionQualifier : sessionQualifiers) {
        openSession(sessionQualifier);
    }
}

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

/**
 * {@inheritDoc}//from   ww  w  .  ja v  a 2s .  c  o  m
 */
@Override
public void closeAllPositionsByStrategy(final String strategyName, final boolean unsubscribe) {

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

    for (Position position : this.positionDao.findOpenPositionsByStrategy(strategyName)) {
        if (position.isOpen()) {
            closePosition(position.getId(), unsubscribe);
        }
    }

}

From source file:ch.algotrader.dao.marketData.TickDaoImpl.java

@Override
public List<Tick> findByIdsInclSecurityAndUnderlying(List<Long> ids) {

    Validate.notEmpty(ids, "Ids are empty");

    return find("Tick.findByIdsInclSecurityAndUnderlying", QueryType.BY_NAME, new NamedParam("ids", ids));
}