本文整理汇总了Java中org.apache.commons.lang3.Validate.notEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Validate.notEmpty方法的具体用法?Java Validate.notEmpty怎么用?Java Validate.notEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.Validate
的用法示例。
在下文中一共展示了Validate.notEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMainHospitalLocation
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public static Location createMainHospitalLocation(String odsSiteCode, Reference mainHospitalOrganisationReference, Mapper mapper) throws MapperException, TransformException {
Validate.notEmpty(odsSiteCode, "odsSiteCode");
MappedOrganisation mappedOrganisation = mapper.getOrganisationMapper().mapOrganisation(odsSiteCode);
if (mappedOrganisation == null)
throw new TransformException("Could not map HSCSite organisation from OdsSiteCode " + odsSiteCode + " when creating hospital location");
if (mappedOrganisation.getOrganisationClass() != OrganisationClass.HSC_SITE)
throw new TransformException("Trying to create a hospital location and OrganisationClass is not HSCSite");
Location location = new Location()
.setName(mappedOrganisation.getOrganisationName())
.addIdentifier(IdentifierConverter.createOdsCodeIdentifier(mappedOrganisation.getOdsCode()))
.setStatus(Location.LocationStatus.ACTIVE)
.setAddress(AddressConverter.createWorkAddress(mappedOrganisation.getAddressLine1(), mappedOrganisation.getAddressLine2(), mappedOrganisation.getTown(), mappedOrganisation.getPostcode()))
.setManagingOrganization(mainHospitalOrganisationReference)
.setType(LocationCommon.createType(V3RoleCode.HOSP))
.setPhysicalType(LocationCommon.createLocationPhysicalType(LocationPhysicalType.BU))
.setMode(Location.LocationMode.INSTANCE);
UUID id = mapper.getResourceMapper().mapLocationUuid(mappedOrganisation.getOdsCode());
location.setId(id.toString());
return location;
}
示例2: getAccessibleField
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
* 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
*
* 如向上转型到Object仍无法找到, 返回null.
*
* 因为class.getFiled(); 不能获取父类的private函数, 因此采用循环向上的getDeclaredField();
*/
@SuppressWarnings("rawtypes")
public static Field getAccessibleField(final Class clazz, final String fieldName) {
Validate.notNull(clazz, "clazz can't be null");
Validate.notEmpty(fieldName, "fieldName can't be blank");
for (Class<?> superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Field field = superClass.getDeclaredField(fieldName);
ClassUtil.makeAccessible(field);
return field;
} catch (NoSuchFieldException e) {// NOSONAR
// Field不在当前类定义,继续向上转型
}
}
return null;
}
示例3: Pokemon
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public Pokemon(Integer number, String name, String about, PokemonTypes types, String buddyDistance,
Set<String> weaknesses, Set<String> resistantTo) {
Validate.notNull(number, "Number is null!");
Validate.notNull(types, "Types is null!");
Validate.notEmpty(name, "Name is empty!");
if (types != PokemonTypes.NONE) {
Validate.notEmpty(weaknesses, "Weaknesses is empty!");
Validate.notEmpty(resistantTo, "ResistantTo is empty!");
}
this.number = number;
this.name = name;
this.about = about;
this.types = types;
this.buddyDistance = buddyDistance;
this.weaknesses = weaknesses;
resistant = resistantTo;
}
示例4: putResourceUuid
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void putResourceUuid(ResourceType resourceType, String identifier, UUID resourceUuid) throws MapperException {
Validate.notNull(resourceType);
Validate.notEmpty(identifier);
Validate.notNull(resourceUuid);
if (!resourceTypesToCache.contains(resourceType))
return;
ResourceUuidKey combinedKey = new ResourceUuidKey(resourceType.toString(), identifier);
UUID previousValue = hashMap.putIfAbsent(combinedKey, resourceUuid);
if (previousValue != null)
if (!previousValue.equals(resourceUuid))
throw new MapperException("Tried to put key " + combinedKey.toString() + " with resource UUID " + resourceUuid.toString() + " but different resource UUID already exists " + previousValue.toString());
}
示例5: Schedule
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
Schedule(List<CarrierMovement> carrierMovements) {
Validate.notNull(carrierMovements);
Validate.noNullElements(carrierMovements);
Validate.notEmpty(carrierMovements);
this.carrierMovements = carrierMovements;
}
示例6: AttributeModifier
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public AttributeModifier(UUID idIn, String nameIn, double amountIn, int operationIn)
{
this.isSaved = true;
this.id = idIn;
this.name = nameIn;
this.amount = amountIn;
this.operation = operationIn;
Validate.notEmpty(nameIn, "Modifier name cannot be empty", new Object[0]);
Validate.inclusiveBetween(0L, 2L, (long)operationIn, "Invalid operation");
}
示例7: registerKafkaSubscriber
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
/**
*
*/
@SuppressWarnings("rawtypes")
private void registerKafkaSubscriber() {
// 状态:启动中
status.set(1);
Validate.notEmpty(this.configs, "configs is required");
Validate.notEmpty(this.configs.getProperty("group.id"),
"kafka configs[group.id] is required");
Validate.notEmpty(this.configs.getProperty("bootstrap.servers"),
"kafka configs[bootstrap.servers] is required");
StringBuffer sb = new StringBuffer();
Iterator itr = this.configs.entrySet().iterator();
while (itr.hasNext()) {
Entry e = (Entry) itr.next();
sb.append(e.getKey()).append(" = ").append(e.getValue()).append("\n");
}
logger.info("\n============kafka.Consumer.Config============\n" + sb.toString() + "\n");
ConsumerContext consumerContext = new ConsumerContext(configs, groupId, consumerId,
topicHandlers, processThreads);
if (useNewAPI) {
consumer = new NewApiTopicConsumer(consumerContext);
} else {
consumer = new OldApiTopicConsumer(consumerContext);
}
consumerContext.setOffsetLogHanlder(offsetLogHanlder);
consumer.start();
// 状态:运行中
status.set(2);
}
示例8: putMappedCode
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void putMappedCode(String context, String code, String codeSystem, String term, MappedCode mappedCode) {
Validate.notEmpty(context);
Validate.notEmpty(code + term);
Validate.notNull(mappedCode);
CodeCacheKey codeCacheKey = new CodeCacheKey(context, code, codeSystem, term);
if (!this.codeActionsToCache.contains(mappedCode.getAction())) {
hashMap.remove(codeCacheKey);
return;
}
hashMap.put(codeCacheKey, mappedCode);
}
示例9: setName
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void setName(String name) {
Validate.notEmpty(name);
this.name = name;
}
示例10: Itinerary
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public Itinerary(List<Leg> legs) {
Validate.notEmpty(legs);
Validate.noNullElements(legs);
this.legs = legs;
}
示例11: lookupOrganisationViaRest
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public static MappedOrganisation lookupOrganisationViaRest(String odsCode) throws MapperException, UnirestException {
Validate.notEmpty(odsCode);
HttpResponse<JsonNode> response = Unirest.get(ORGANISATAION_REST_URL + odsCode).asJson();
if (response.getStatus() == 404)
return null;
if (response.getStatus() != 200)
throw new MapperException("Status " + Integer.toString(response.getStatus()) + " returned when getting organisation " + odsCode + " from " + ORGANISATAION_REST_URL + odsCode);
JSONObject organisation = response.getBody().getObject();
MappedOrganisation mappedOrganisation = new MappedOrganisation()
.setOrganisationName(StringHelper.formatName(organisation.getString("name")))
.setOdsCode(organisation.getString("odsCode"))
.setOrganisationClass(OrganisationClass.fromOrganisationClassName(organisation.getString("recordClass")));
if (StringUtils.isEmpty(mappedOrganisation.getOdsCode()))
throw new MapperException("Returned ODS code is empty");
if (StringUtils.isEmpty(mappedOrganisation.getOrganisationName()))
throw new MapperException("Returned organisation name is empty");
JSONObject address = getFirstJSONObject(getArray(organisation, "addresses"));
if (address != null) {
JSONArray addressLines = getArray(address, "addressLines");
if (addressLines != null) {
if (addressLines.length() > 0)
mappedOrganisation.setAddressLine1(AddressConverter.formatAddressLine(addressLines.getString(0)));
if (addressLines.length() > 1) {
String line2 = AddressConverter.formatAddressLine(addressLines.getString(1));
if (addressLines.length() > 2)
line2 = line2 + ", " + AddressConverter.formatAddressLine(addressLines.getString(2));
mappedOrganisation.setAddressLine2(line2);
}
}
mappedOrganisation.setTown(AddressConverter.formatAddressLine(address.getString("town")));
mappedOrganisation.setCounty(AddressConverter.formatAddressLine(address.getString("county")));
mappedOrganisation.setPostcode(AddressConverter.formatPostcode(address.getString("postCode")));
}
JSONArray roles = getArray(organisation, "roles");
OrganisationType organisationType = null;
if (roles != null) {
String primaryRole = null;
List<String> otherRoles = new ArrayList<>();
for (int i = 0; i < roles.length(); i++) {
JSONObject role = roles.getJSONObject(i);
if (role.getBoolean("primaryRole"))
primaryRole = role.getString("code");
else
otherRoles.add(role.getString("code"));
}
organisationType = getOrganisationType(primaryRole);
for (String roleCode : otherRoles) {
if (organisationType != null)
break;
organisationType = getOrganisationType(roleCode);
}
}
if (organisationType != null)
mappedOrganisation.setOrganisationType(organisationType);
return mappedOrganisation;
}
示例12: setEmoteMessageId
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void setEmoteMessageId(String emoteMessageId) {
Validate.notEmpty(emoteMessageId, "Emote message id is empty");
this.emoteMessageId = emoteMessageId;
}
示例13: validate
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
private void validate(Integer clientId, String clientSecret) {
Validate.notNull(clientId, "The 'clientId' parameter is mandatory");
Validate.notNull(clientSecret, "The 'clientSecret' parameter is mandatory");
Validate.notEmpty(clientSecret, "The 'clientSecret' parameter cannot be empty");
}
示例14: validate
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
private void validate(String query) {
Validate.notEmpty(query, "The 'query' parameter is mandatory");
}
示例15: setCreator
import org.apache.commons.lang3.Validate; //导入方法依赖的package包/类
public void setCreator(String creator) {
Validate.notEmpty(creator, "Creator is empty");
this.creator = creator;
}