org.apache.commons.lang.Validate.notEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.apache.commons.lang.Validate.notEmpty()方法的一些代码示例,展示了Validate.notEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.notEmpty()方法的具体详情如下:
包路径:org.apache.commons.lang.Validate
类名称:Validate
方法名:notEmpty

Validate.notEmpty介绍

[英]Validate that the specified argument string is neither null nor a length of zero (no characters); otherwise throwing an exception with the specified message.

Validate.notEmpty(myString);

The message in the exception is "The validated string is empty".
[中]验证指定的参数字符串既不是null也不是长度为零(无字符);否则,将使用指定的消息引发异常。

Validate.notEmpty(myString);

异常中的消息是“已验证的字符串为空”。

代码示例

代码示例来源:origin: apache/storm

/**
 * AbstractMongoBolt Constructor.
 * @param url The MongoDB server url
 * @param collectionName The collection where reading/writing data
 */
public AbstractMongoBolt(String url, String collectionName) {
  Validate.notEmpty(url, "url can not be blank or null");
  Validate.notEmpty(collectionName, "collectionName can not be blank or null");
  this.url = url;
  this.collectionName = collectionName;
}

代码示例来源:origin: apache/storm

public SimpleJdbcMapper(List<Column> schemaColumns) {
  Validate.notEmpty(schemaColumns);
  this.schemaColumns = schemaColumns;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Validate that the specified argument collection is neither <code>null</code> 
 * nor a size of zero (no elements); otherwise throwing an exception. 
 *
 * <pre>Validate.notEmpty(myCollection);</pre>
 * 
 * <p>The message in the exception is &quot;The validated collection is 
 * empty&quot;.</p>
 * 
 * @param collection the collection to check
 * @throws IllegalArgumentException if the collection is empty
 */
public static void notEmpty(Collection collection) {
  notEmpty(collection, "The validated collection is empty");
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Validate that the specified argument map is neither <code>null</code> 
 * nor a size of zero (no elements); otherwise throwing an exception. 
 *
 * <pre>Validate.notEmpty(myMap);</pre>
 * 
 * <p>The message in the exception is &quot;The validated map is 
 * empty&quot;.</p>
 * 
 * @param map the map to check
 * @throws IllegalArgumentException if the map is empty
 * @see #notEmpty(Map, String)
 */
public static void notEmpty(Map map) {
  notEmpty(map, "The validated map is empty");
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Validate that the specified argument array is neither <code>null</code> 
 * nor a length of zero (no elements); otherwise throwing an exception. 
 *
 * <pre>Validate.notEmpty(myArray);</pre>
 * 
 * <p>The message in the exception is &quot;The validated array is 
 * empty&quot;.
 * 
 * @param array the array to check
 * @throws IllegalArgumentException if the array is empty
 */
public static void notEmpty(Object[] array) {
  notEmpty(array, "The validated array is empty");
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Validate that the specified argument string is 
 * neither <code>null</code> nor a length of zero (no characters); 
 * otherwise throwing an exception with the specified message.
 *
 * <pre>Validate.notEmpty(myString);</pre>
 * 
 * <p>The message in the exception is &quot;The validated 
 * string is empty&quot;.</p>
 * 
 * @param string the string to check
 * @throws IllegalArgumentException if the string is empty
 */
public static void notEmpty(String string) {
  notEmpty(string, "The validated string is empty");
}

代码示例来源:origin: apache/storm

@Override
public void prepare(Map<String, Object> conf) {
  this.isoMachines = (Map<String, Number>) conf.get(DaemonConfig.ISOLATION_SCHEDULER_MACHINES);
  Validate.notEmpty(isoMachines);
}

代码示例来源:origin: apache/storm

public AbstractHBaseBolt(String tableName, HBaseMapper mapper) {
  Validate.notEmpty(tableName, "Table name can not be blank or null");
  Validate.notNull(mapper, "mapper can not be null");
  this.tableName = tableName;
  this.mapper = mapper;
}

代码示例来源:origin: apache/storm

protected void prepare() {
  Validate.notEmpty(options.url, "url can not be blank or null");
  Validate.notEmpty(options.collectionName, "collectionName can not be blank or null");
  this.mongoClient = new MongoDbClient(options.url, options.collectionName);
}

代码示例来源:origin: apache/storm

protected MongoMapState(Map<String, Object> map, Options options) {
  this.options = options;
  this.map = map;
  this.serializer = options.serializer;
  Validate.notEmpty(options.url, "url can not be blank or null");
  Validate.notEmpty(options.collectionName, "collectionName can not be blank or null");
  Validate.notNull(options.queryCreator, "queryCreator can not be null");
  Validate.notNull(options.mapper, "mapper can not be null");
  this.mongoClient = new MongoDbClient(options.url, options.collectionName);
}

代码示例来源:origin: apache/storm

/**
 * RocketMqSpout Constructor.
 * @param properties Properties Config
 */
public RocketMqSpout(Properties properties) {
  Validate.notEmpty(properties, "Consumer properties can not be empty");
  this.properties = properties;
  scheme = RocketMqUtils.createScheme(properties);
}

代码示例来源:origin: apache/storm

public SimpleJdbcLookupMapper(Fields outputFields, List<Column> queryColumns) {
  super(queryColumns);
  Validate.notEmpty(outputFields.toList());
  this.outputFields = outputFields;
}

代码示例来源:origin: citerus/dddsample-core

/**
 * Constructor.
 *
 * @param legs List of legs for this itinerary.
 */
public Itinerary(final List<Leg> legs) {
 Validate.notEmpty(legs);
 Validate.noNullElements(legs);
 this.legs = legs;
}

代码示例来源:origin: citerus/dddsample-core

Schedule(final List<CarrierMovement> carrierMovements) {
 Validate.notNull(carrierMovements);
 Validate.noNullElements(carrierMovements);
 Validate.notEmpty(carrierMovements);
 this.carrierMovements = carrierMovements;
}

代码示例来源:origin: apache/storm

protected void prepare() {
  Validate.notEmpty(options.properties, "Producer properties can not be empty");
  Validate.notNull(options.selector, "TopicSelector can not be null");
  Validate.notNull(options.mapper, "TupleToMessageMapper can not be null");
  producer = new DefaultMQProducer();
  producer.setInstanceName(UUID.randomUUID().toString());
  RocketMqConfig.buildProducerConfigs(options.properties, producer);
  try {
    producer.start();
  } catch (MQClientException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * @param keyStorePath
 *          the keyStorePath to set
 */
public void setKeyStore( String keyStore ) {
 Validate.notNull( keyStore, BaseMessages.getString( PKG, "WebServer.Error.IllegalSslParameter", XML_TAG_KEY_STORE,
   NULL ) );
 Validate.notEmpty( keyStore, BaseMessages.getString( PKG, "WebServer.Error.IllegalSslParameter", XML_TAG_KEY_STORE,
   EMPTY ) );
 this.keyStore = keyStore;
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * @param keyStorePassword
 *          the keyStorePassword to set
 */
public void setKeyStorePassword( String keyStorePassword ) {
 Validate.notNull( keyStorePassword, BaseMessages.getString( PKG, "WebServer.Error.IllegalSslParameter",
   XML_TAG_KEY_STORE_PASSWORD, NULL ) );
 Validate.notEmpty( keyStorePassword, BaseMessages.getString( PKG, "WebServer.Error.IllegalSslParameter",
   XML_TAG_KEY_STORE_PASSWORD, EMPTY ) );
 this.keyStorePassword = keyStorePassword;
}

代码示例来源:origin: apache/storm

public SimpleJdbcMapper(String tableName, ConnectionProvider connectionProvider) {
  Validate.notEmpty(tableName);
  Validate.notNull(connectionProvider);
  int queryTimeoutSecs = 30;
  connectionProvider.prepare();
  JdbcClient client = new JdbcClient(connectionProvider, queryTimeoutSecs);
  this.schemaColumns = client.getColumnSchema(tableName);
}

代码示例来源:origin: apache/storm

@Override
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
  Validate.notEmpty(properties, "Producer properties can not be empty");
  Validate.notNull(selector, "TopicSelector can not be null");
  Validate.notNull(mapper, "TupleToMessageMapper can not be null");
  producer = new DefaultMQProducer();
  producer.setInstanceName(String.valueOf(context.getThisTaskId()));
  RocketMqConfig.buildProducerConfigs(properties, producer);
  try {
    producer.start();
  } catch (MQClientException e) {
    throw new RuntimeException(e);
  }
  this.collector = collector;
  this.batchHelper = new BatchHelper(batchSize, collector);
  this.messages = new LinkedList<>();
}

代码示例来源:origin: apache/storm

/**
   * Build Common Configs.
   * @param props Properties
   * @param client ClientConfig
   */
  public static void buildCommonConfigs(Properties props, ClientConfig client) {
    String nameServers = props.getProperty(NAME_SERVER_ADDR);
    Validate.notEmpty(nameServers);
    client.setNamesrvAddr(nameServers);

    client.setPollNameServerInterval(getInteger(props,
        NAME_SERVER_POLL_INTERVAL, DEFAULT_NAME_SERVER_POLL_INTERVAL));
    client.setHeartbeatBrokerInterval(getInteger(props,
        BROKER_HEART_BEAT_INTERVAL, DEFAULT_BROKER_HEART_BEAT_INTERVAL));
  }
}

相关文章

微信公众号

最新文章

更多