本文整理了Java中org.eclipse.leshan.util.Validate.notEmpty()
方法的一些代码示例,展示了Validate.notEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.notEmpty()
方法的具体详情如下:
包路径:org.eclipse.leshan.util.Validate
类名称: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: eclipse/leshan
private SecurityInfo(String endpoint, String identity, byte[] preSharedKey, PublicKey rawPublicKey,
boolean useX509Cert) {
Validate.notEmpty(endpoint);
this.endpoint = endpoint;
this.identity = identity;
this.preSharedKey = preSharedKey;
this.rawPublicKey = rawPublicKey;
this.useX509Cert = useX509Cert;
}
代码示例来源:origin: eclipse/leshan
/**
* <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 "The validated collection is empty".
* </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: eclipse/leshan
/**
* <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 "The validated array is empty".
*
* @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: eclipse/leshan
/**
* <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 "The validated string is empty".
* </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: eclipse/leshan
/**
* <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 "The validated map is empty".
* </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: eclipse/leshan
/**
* Creates a new instance for setting the configuration options for a {@link LeshanClient} instance.
*
* The builder is initialized with the following default values:
* <ul>
* <li><em>local address</em>: a local address and an ephemeral port (picked up during binding)</li>
* <li><em>object enablers</em>:
* <ul>
* <li>Security(0) with one instance (DM server security): uri=<em>coap://leshan.eclipse.org:5683</em>, mode=NoSec
* </li>
* <li>Server(1) with one instance (DM server): id=12345, lifetime=5minutes</li>
* <li>Device(3): manufacturer=Eclipse Leshan, modelNumber=model12345, serialNumber=12345</li>
* </ul>
* </li>
* </ul>
*
* @param endpoint the end-point to identify the client on the server
*/
public LeshanClientBuilder(String endpoint) {
Validate.notEmpty(endpoint);
this.endpoint = endpoint;
}
代码示例来源:origin: eclipse/leshan
public FileSecurityStore(String file) {
Validate.notEmpty(file);
filename = file;
loadFromFile();
}
代码示例来源:origin: eclipse/leshan
public Attribute(String coRELinkParam, Object value) {
Validate.notEmpty(coRELinkParam);
this.model = modelMap.get(coRELinkParam);
if (model == null) {
throw new IllegalArgumentException(String.format("Unsupported attribute '%s'", coRELinkParam));
}
this.value = ensureMatchingValue(model, value);
}
代码示例来源:origin: eclipse/leshan
public ObjectModel(int id, String name, String description, String version, boolean multiple, boolean mandatory,
Collection<ResourceModel> resources) {
Validate.notEmpty(version);
this.id = id;
this.name = name;
this.description = description;
this.version = version;
this.multiple = multiple;
this.mandatory = mandatory;
Map<Integer, ResourceModel> resourcesMap = new HashMap<>(resources.size());
for (ResourceModel resource : resources) {
ResourceModel old = resourcesMap.put(resource.id, resource);
if (old != null) {
LOG.debug("Model already exists for resource {} of object {}. Overriding it.", resource.id, id);
}
resourcesMap.put(resource.id, resource);
}
this.resources = Collections.unmodifiableMap(resourcesMap);
}
代码示例来源:origin: eclipse/leshan
public void setInstancesForObject(int objectId, LwM2mInstanceEnabler... instances) {
ObjectModel objectModel = model.getObjectModel(objectId);
if (objectModel == null) {
throw new IllegalArgumentException(
"Cannot set Instances Class for Object " + objectId + " because no model is defined for this id.");
}
Validate.notNull(instances);
Validate.notEmpty(instances);
if (instances.length > 1 && !objectModel.multiple)
throw new IllegalArgumentException("Cannot set more than one instance for the single Object " + objectId);
this.instances.put(objectId, instances);
}
代码示例来源:origin: eclipse/leshan
/**
* @param filename the file path to persist the registry
*/
public BootstrapStoreImpl(String filename) {
Validate.notEmpty(filename);
GsonBuilder builder = new GsonBuilder();
builder.setPrettyPrinting();
this.gson = builder.create();
this.gsonType = new TypeToken<Map<String, BootstrapConfig>>() {
}.getType();
this.filename = filename;
this.loadFromFile();
}
代码示例来源:origin: eclipse/leshan
/**
* Construct a {@link SecurityInfo} when using DTLS with Pre-Shared Keys.
*/
public static SecurityInfo newPreSharedKeyInfo(String endpoint, String identity, byte[] preSharedKey) {
Validate.notEmpty(identity);
Validate.notNull(preSharedKey);
return new SecurityInfo(endpoint, identity, preSharedKey, null, false);
}
代码示例来源:origin: eclipse/leshan
public Builder(String registrationId, String endpoint, Identity identity,
InetSocketAddress registrationEndpointAddress) {
Validate.notNull(registrationId);
Validate.notEmpty(endpoint);
Validate.notNull(identity);
Validate.notNull(registrationEndpointAddress);
this.registrationId = registrationId;
this.endpoint = endpoint;
this.identity = identity;
this.registrationEndpointAddress = registrationEndpointAddress;
}
代码示例来源:origin: eclipse/leshan
Validate.notEmpty(endpoint);
Validate.notNull(identity);
Validate.notNull(registrationEndpointAddress);
代码示例来源:origin: eclipse/leshan
@Override
public byte[] encodeTimestampedData(List<TimestampedLwM2mNode> timestampedNodes, ContentFormat format,
LwM2mPath path, LwM2mModel model) throws CodecException {
Validate.notEmpty(timestampedNodes);
if (format == null) {
throw new CodecException("Content format is mandatory. [%s]", path);
}
LOG.debug("Encoding time-stamped nodes for path {} and format {}", timestampedNodes, path, format);
byte[] encoded;
switch (format.getCode()) {
case ContentFormat.JSON_CODE:
encoded = LwM2mNodeJsonEncoder.encodeTimestampedData(timestampedNodes, path, model, converter);
break;
default:
throw new CodecException("Cannot encode timestampedNode with format %s. [%s]", format, path);
}
LOG.trace("Encoded node timestampedNode: {}", timestampedNodes, encoded);
return encoded;
}
代码示例来源:origin: eclipse/leshan
Validate.notEmpty(objectEnablers);
Validate.notNull(coapConfig);
代码示例来源:origin: org.eclipse.leshan/leshan-client
public LeshanClient(final InetSocketAddress clientAddress, final InetSocketAddress serverAddress,
final CoapServer serverLocal, final LwM2mClientObjectDefinition... objectDevice) {
Validate.notNull(clientAddress);
Validate.notNull(serverLocal);
Validate.notNull(serverAddress);
Validate.notNull(objectDevice);
Validate.notEmpty(objectDevice);
serverLocal.setMessageDeliverer(new LwM2mServerMessageDeliverer(serverLocal.getRoot()));
final Endpoint endpoint = new CoAPEndpoint(clientAddress);
serverLocal.addEndpoint(endpoint);
clientSideServer = serverLocal;
for (final LwM2mClientObjectDefinition def : objectDevice) {
if (clientSideServer.getRoot().getChild(Integer.toString(def.getId())) != null) {
throw new IllegalArgumentException("Trying to load Client Object of name '" + def.getId()
+ "' when one was already added.");
}
final CaliforniumBasedObject clientObject = new CaliforniumBasedObject(def);
clientSideServer.add(clientObject);
}
requestSender = new CaliforniumLwM2mClientRequestSender(serverLocal.getEndpoint(clientAddress), serverAddress,
getObjectModel());
}
内容来源于网络,如有侵权,请联系作者删除!