List of usage examples for org.apache.commons.lang Validate notEmpty
public static void notEmpty(String string, String message)
Validate an argument, throwing IllegalArgumentException
if the argument String is empty (null
or zero length).
Validate.notEmpty(myString, "The string must not be empty");
From source file:ch.algotrader.adapter.fix.DefaultFixAdapter.java
@Override public void createSession(String sessionQualifier) throws BrokerAdapterException { Validate.notEmpty(sessionQualifier, "Session qualifier is empty"); createSessionInternal(sessionQualifier, true); }
From source file:me.pagekite.glen3b.library.bukkit.datastore.Message.java
/** * Creates an instance of Message with the specified key and value. Does not add to any {@link MessageProvider}. * @param key The {@link MessageProvider} key for this message. * @param value The value of the message. *//*from w w w . ja va 2 s . co m*/ public Message(String key, String value) { Validate.notEmpty(key, "The key cannot be null or empty."); Validate.notNull(value, "The message cannot be null."); _key = key; _value = value; }
From source file:edu.snu.leader.hidden.SimulationState.java
/** * Initialize the simulation state//from ww w. ja v a 2s . c o m * * @param props */ public void initialize(Properties props) { _LOG.trace("Entering initialize( props )"); // Save the properties _props = props; // _LOG.warn( props.toString() ); // Get the random number generator seed String randomSeedStr = props.getProperty(_RANDOM_SEED_KEY); Validate.notEmpty(randomSeedStr, "Random seed is required"); long seed = Long.parseLong(randomSeedStr); _random = new MersenneTwisterFast(seed); // Get the number of individuals to create String individualCountStr = _props.getProperty(_INDIVIDUAL_COUNT_KEY); Validate.notEmpty(individualCountStr, "Individual count (key=" + _INDIVIDUAL_COUNT_KEY + ") may not be empty"); _individualCount = Integer.parseInt(individualCountStr); // Get the number of nearest neighbors String nearestNeighborCountStr = _props.getProperty(_NEAREST_NEIGHBOR_COUNT_KEY); Validate.notEmpty(nearestNeighborCountStr, "Nearest neighbor count (key=" + _NEAREST_NEIGHBOR_COUNT_KEY + ") may not be empty"); _nearestNeighborCount = Integer.parseInt(nearestNeighborCountStr); // Get the distance used to calculate of nearest neighbors String nearestNeighborDistanceStr = _props.getProperty(_NEAREST_NEIGHBOR_DISTANCE_KEY); // Validate.notEmpty( nearestNeighborDistanceStr, // "Nearest neighbor distance (key=" // + _NEAREST_NEIGHBOR_DISTANCE_KEY // + ") may not be empty" ); if (null != nearestNeighborDistanceStr) { _nearestNeighborDistance = Float.parseFloat(nearestNeighborDistanceStr); } // Get the individual rebuild flag String rebuildIndividualsStr = _props.getProperty(_REBUILD_INDIVIDUALS_KEY); Validate.notEmpty(rebuildIndividualsStr, "Rebuild individuals flag (key=" + _REBUILD_INDIVIDUALS_KEY + ") may not be empty"); _rebuildIndividuals = Boolean.parseBoolean(rebuildIndividualsStr); // Get the flag that specifies how the group size is calculated String useNearestNeighborGroupSizeStr = _props.getProperty(_USE_NEAREST_NEIGHBOR_GROUP_SIZE_KEY); Validate.notEmpty(useNearestNeighborGroupSizeStr, "Use nearest neighbor as group size flag (key=" + _USE_NEAREST_NEIGHBOR_GROUP_SIZE_KEY + ") may not be empty"); _useNearestNeighborGroupSize = Boolean.parseBoolean(useNearestNeighborGroupSizeStr); // Get the simulation count String simulationCountStr = _props.getProperty(_SIMULATION_COUNT_KEY); Validate.notEmpty(simulationCountStr, "Simulation count is required"); _simulationCount = Integer.parseInt(simulationCountStr); // Load the event time calculator class String eventTimeCalcStr = props.getProperty(_EVENT_TIME_CALCULATOR_CLASS); Validate.notEmpty(eventTimeCalcStr, "Event time calculator class (key=" + _EVENT_TIME_CALCULATOR_CLASS + ") may not be empty"); _eventTimeCalc = (EventTimeCalculator) MiscUtils.loadAndInstantiate(eventTimeCalcStr, "Event time calculator class"); _eventTimeCalc.initialize(this); // Load the individual builder String indBuilderStr = props.getProperty(_INDIVIDUAL_BUILDER_CLASS); Validate.notEmpty(indBuilderStr, "Individual builder class (key=" + _INDIVIDUAL_BUILDER_CLASS + ") may not be empty"); _indBuilder = (IndividualBuilder) MiscUtils.loadAndInstantiate(indBuilderStr, "Individual builder class"); _indBuilder.initialize(this); // Load the personality calculator class String personalityCalculatorStr = props.getProperty(_PERSONALITY_CALCULATOR_CLASS); if (null != personalityCalculatorStr) { _personalityCalc = (PersonalityCalculator) MiscUtils.loadAndInstantiate(personalityCalculatorStr, "Personality calculator class"); } else { _personalityCalc = new ConstantPersonalityCalculator(); } _personalityCalc.initialize(this); /* Get the flag denoting whether the total number of departed * individuals should be used or the number of nearest neighbors * that have departed */ String useAllDepartedString = _props.getProperty(_USE_ALL_DEPARTED_KEY); if (null != useAllDepartedString) { _useAllDeparted = Boolean.parseBoolean(useAllDepartedString); _LOG.info("Using _useAllDeparted=[" + _useAllDeparted + "]"); } // Create the individuals createIndividuals(); _LOG.trace("Leaving initialize( props )"); }
From source file:com.firstdata.globalgatewaye4.CheckRequest.java
/** * @param cardholder_name {@link #String}[30] value of customer name. Required. * @return {@link #CheckRequest}// w w w . j a va2 s . co m */ @NotNull public CheckRequest cardholder_name(String cardholder_name) { Validate.notEmpty(cardholder_name, "cardholder_name cannot be empty."); Validate.isTrue(cardholder_name.length() <= 30, "cardholder_name contains too many characters. Less than 30 characters required."); this.cardholder_name = cardholder_name; return this; }
From source file:com.eharmony.services.swagger.resource.DocumentationRepositoryResource.java
/** * Validates required fields on the documentation instance. * @param documentation Documentation to validate *//*from www . ja va2 s . c o m*/ private void validateDocumentation(Documentation documentation) { Validate.notEmpty(documentation.getCategory(), "Category is required"); Validate.notEmpty(documentation.getEnvironment(), "Environment is required"); Validate.notEmpty(documentation.getServiceDescription(), "Service description is required"); Validate.notEmpty(documentation.getServiceName(), "Service Name is required"); Validate.notEmpty(documentation.getSwaggerSpecUrl(), "Swagger Spec url is required"); Validate.notEmpty(documentation.getSwaggerUiUrl(), "Swagger UI url is required"); Validate.notEmpty(documentation.getServiceHost(), "Host is required"); }
From source file:ch.algotrader.service.ib.IBFixAllocationServiceImpl.java
/** * {@inheritDoc}/* ww w.j av a2s. c o m*/ */ @Override @ManagedOperation(description = "Modifies the default allocation method of an Account Group.") @ManagedOperationParameters({ @ManagedOperationParameter(name = "account", description = "account"), @ManagedOperationParameter(name = "group", description = "group"), @ManagedOperationParameter(name = "defaultMethod", description = "defaultMethod") }) public void setDefaultMethod(final String account, final String group, final String defaultMethod) { Validate.notEmpty(account, "Account is empty"); Validate.notEmpty(group, "Group is empty"); Validate.notEmpty(defaultMethod, "Default method is empty"); try { requestGroups(account); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new ServiceException(ex); } catch (SessionNotFound ex) { throw new ExternalServiceException(ex); } Group groupObject = this.groups.get(group); if (group != null) { groupObject.setDefaultMethod(defaultMethod); } else { throw new ExternalServiceException("group does not exist " + group); } try { postGroups(account); } catch (SessionNotFound ex) { throw new ExternalServiceException(ex); } }
From source file:ch.algotrader.adapter.fix.DefaultFixAdapter.java
@Override public void openSession(String sessionQualifier) throws BrokerAdapterException { Validate.notEmpty(sessionQualifier, "Session qualifier is empty"); createSessionInternal(sessionQualifier, false); }
From source file:ch.algotrader.dao.PositionDaoImpl.java
@Override public List<Position> findOpenTradeablePositionsByStrategy(String strategyName) { Validate.notEmpty(strategyName, "Strategy name is empty"); return findCaching("Position.findOpenTradeablePositionsByStrategy", QueryType.BY_NAME, new NamedParam("strategyName", strategyName)); }
From source file:ch.algotrader.service.ib.IBNativeReferenceDataServiceImpl.java
@Override @Transactional(propagation = Propagation.REQUIRED) public void retrieveStocks(long securityFamilyId, String symbol) { Validate.notEmpty(symbol, "Symbol is empty"); SecurityFamily securityFamily = this.securityFamilyDao.get(securityFamilyId); int requestId = (int) this.requestIdGenerator.generateId(); Contract contract = new Contract(); contract.m_symbol = symbol;/* w ww .ja v a 2 s. com*/ contract.m_currency = securityFamily.getCurrency().toString(); contract.m_exchange = securityFamily.getExchange().getIbCode(); contract.m_secType = "STK"; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Request stock details; request id = {}; symbol = {}", requestId, contract.m_symbol); } PromiseImpl<List<ContractDetails>> promise = new PromiseImpl<>(null); this.pendingRequests.addContractDetailRequest(requestId, promise); this.iBSession.reqContractDetails(requestId, contract); Set<ContractDetails> contractDetailsSet = getContractDetailsBlocking(promise); retrieveStocks(securityFamily, contractDetailsSet); }
From source file:ch.algotrader.service.PositionServiceImpl.java
/** * {@inheritDoc}/*from w w w. j a v a 2 s .c om*/ */ @Override public void transferPosition(final long positionId, final String targetStrategyName) { Validate.notEmpty(targetStrategyName, "Target strategy name is empty"); Position position = this.positionDao.get(positionId); if (position == null) { throw new IllegalArgumentException("position with id " + positionId + " does not exist"); } Strategy targetStrategy = this.strategyDao.findByName(targetStrategyName); Security security = position.getSecurity(); SecurityFamily family = security.getSecurityFamily(); MarketDataEventVO marketDataEvent = this.marketDataCacheService.getCurrentMarketDataEvent(security.getId()); BigDecimal price = position.getMarketPrice(marketDataEvent); // debit transaction Transaction debitTransaction = Transaction.Factory.newInstance(); debitTransaction.setUuid(UUID.randomUUID().toString()); debitTransaction.setDateTime(this.engineManager.getCurrentEPTime()); debitTransaction.setQuantity(-position.getQuantity()); debitTransaction.setPrice(price); debitTransaction.setCurrency(family.getCurrency()); debitTransaction.setType(TransactionType.TRANSFER); debitTransaction.setSecurity(security); debitTransaction.setStrategy(position.getStrategy()); // persiste the transaction this.transactionService.persistTransaction(debitTransaction); // credit transaction Transaction creditTransaction = Transaction.Factory.newInstance(); creditTransaction.setUuid(UUID.randomUUID().toString()); creditTransaction.setDateTime(this.engineManager.getCurrentEPTime()); creditTransaction.setQuantity(position.getQuantity()); creditTransaction.setPrice(price); creditTransaction.setCurrency(family.getCurrency()); creditTransaction.setType(TransactionType.TRANSFER); creditTransaction.setSecurity(security); creditTransaction.setStrategy(targetStrategy); // persiste the transaction this.transactionService.persistTransaction(creditTransaction); }