本文整理匯總了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;
}