本文整理匯總了Java中org.apache.commons.lang3.Validate.notBlank方法的典型用法代碼示例。如果您正苦於以下問題:Java Validate.notBlank方法的具體用法?Java Validate.notBlank怎麽用?Java Validate.notBlank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.Validate
的用法示例。
在下文中一共展示了Validate.notBlank方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAccessibleField
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredField, 並強製設置為可訪問.
* <p>
* 如向上轉型到Object仍無法找到, 返回null.
*/
public static Field getAccessibleField(final Object obj, final String fieldName) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(fieldName, "fieldName can't be blank");
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
try {
Field field = superClass.getDeclaredField(fieldName);
makeAccessible(field);
return field;
} catch (NoSuchFieldException e) {//NOSONAR
// Field不在當前類定義,繼續向上轉型
continue;// new add
}
}
return null;
}
示例2: parseAndinstantiate
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public static Segment parseAndinstantiate(String segmentText, Seperators seperators, HashMap<String, Class<? extends Segment>> zSegmentDefinitions) throws ParseException {
Validate.notBlank(segmentText);
Validate.notNull(seperators);
String segmentName = getSegmentName(segmentText, seperators);
Class<? extends Segment> segmentClass = getSegmentClass(segmentName, zSegmentDefinitions);
try {
Constructor<? extends Segment> constructor = segmentClass.getConstructor(String.class, Seperators.class);
if (constructor == null)
throw new ParseException("Could not find constructor for segment " + segmentClass);
return constructor.newInstance(segmentText, seperators);
} catch (Exception e) {
throw new ParseException("Could not instantiate segment " + segmentClass);
}
}
示例3: getAccessibleMethodByName
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredMethod,並強製設置為可訪問.
* 如向上轉型到Object仍無法找到, 返回null.
* 隻匹配函數名。
*
* 用於方法需要被多次調用的情況. 先使用本函數先取得Method,然後調用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
Method[] methods = searchType.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName)) {
makeAccessible(method);
return method;
}
}
}
return null;
}
示例4: init
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
/**
* initialize the (implementation) internalCompiler by providing a workspace directory which could be used
* to save the dependencies and compiled *.class file
*
* @param workspace
* @param dependencyResolver
* @param internalCompiler
*/
public void init(String workspace, DependencyResolver dependencyResolver, InternalCompiler internalCompiler) {
log.info("initializing internalCompiler with workspace {}", workspace);
Validate.notBlank(workspace, "provided workspace cannot be null");
Validate.notNull(dependencyResolver, "provded dependency resolver cannot be null");
Validate.notNull(internalCompiler, "provided internalCompiler cannot be null");
this.workspace = workspace;
this.dependencyResolver = dependencyResolver;
this.internalCompiler = internalCompiler;
final File workspaceDir = Paths.get(workspace).toAbsolutePath().toFile();
Validate.isTrue(workspaceDir.isDirectory(), "provided workspace must be a directory.");
Validate.isTrue(workspaceDir.canRead() && workspaceDir.canWrite(), "read or write permission denied.");
log.info("initialized.");
}
示例5: getAccessibleMethodByName
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
/**
* 循環向上轉型, 獲取對象的DeclaredMethod,並強製設置為可訪問.
* 如向上轉型到Object仍無法找到, 返回null.
* 隻匹配函數名。
* <p/>
* 用於方法需要被多次調用的情況. 先使用本函數先取得Method,然後調用Method.invoke(Object obj, Object... args)
*/
public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
Validate.notNull(obj, "object can't be null");
Validate.notBlank(methodName, "methodName can't be blank");
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
Method[] methods = searchType.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals(methodName)) {
makeAccessible(method);
return method;
}
}
}
return null;
}
示例6: afterPropertiesSet
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
if (!QiniuProvider.NAME.equals(provider) && !FdfsProvider.NAME.equals(provider)) {
throw new RuntimeException("Provider[" + provider + "] not support");
}
if (QiniuProvider.NAME.equals(provider)) {
Validate.notBlank(accessKey, "[accessKey] not defined");
Validate.notBlank(secretKey, "[secretKey] not defined");
fsProvider = new QiniuProvider(urlprefix, groupName, accessKey, secretKey);
} else if (FdfsProvider.NAME.equals(provider)) {
Validate.isTrue(servers != null && servers.matches("^.+[:]\\d{1,5}\\s*$"),
"[servers] is not valid");
String[] serversArray = servers.split(",|;");
fsProvider = new FdfsProvider(urlprefix, groupName, serversArray, connectTimeout,
maxThreads);
}
}
示例7: Message
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public Message(final String messageText, HashMap<String, Class<? extends Segment>> zSegmentDefinitions) throws ParseException {
Validate.notBlank(messageText);
this.originalMessageText = messageText;
this.zSegmentDefinitions = zSegmentDefinitions;
parse(messageText);
}
示例8: mapPractitionerUuidWithLocalHospitalIdentifiers
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public UUID mapPractitionerUuidWithLocalHospitalIdentifiers(String surname, String forename, String localPrimaryAssigningAuthority, String localPrimaryIdentifierValue) throws MapperException {
Validate.notBlank(surname + forename);
Validate.notBlank(localPrimaryAssigningAuthority);
Validate.notBlank(localPrimaryIdentifierValue);
String identifier = ResourceMapParameters.create()
.put(SurnameKey, surname)
.put(ForenameKey, forename)
.put(PractitionerIdentifierAssigningAuthorityCodeKey, localPrimaryAssigningAuthority)
.put(PractitionerIdentifierValueKey, localPrimaryIdentifierValue)
.createIdentifyingString();
return this.mapper.mapScopedResourceUuid(ResourceType.Practitioner, identifier);
}
示例9: mapPractitionerUuidWithConsultantCode
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public UUID mapPractitionerUuidWithConsultantCode(String surname, String forename, String consultantCode) throws MapperException {
Validate.notBlank(surname + forename);
Validate.notBlank(consultantCode);
String identifier = ResourceMapParameters.create()
.put(SurnameKey, surname)
.put(ForenameKey, forename)
.put(ConsultantCodeKey, consultantCode)
.createIdentifyingString();
return this.mapper.mapScopedResourceUuid(ResourceType.Practitioner, identifier);
}
示例10: init
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
@PostConstruct
public void init() throws MalformedURLException {
Validate.notBlank(scriptDir, "script.directory cannot be empty");
final File directory = Paths.get(scriptDir).toAbsolutePath().toFile();
log.info("script.directory is {}", directory.toString());
Validate.isTrue(directory.isDirectory(), "script.directory must be a directory.");
Validate.isTrue(directory.canRead(), "script.directory must be readable.");
runtime = new Runtime(getScriptClassLoader(directory));
}
示例11: run
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
@Override
public String run(Context context) throws Exception {
final String functionName = context.getString("name");
final String language = context.getString("language");
final String artifact = context.getString("artifact");
final Boolean dind = context.getBoolean("dind");
final URI artifactURI = new URI(artifact);
Validate.notBlank(functionName, "name parameter cannot be empty.");
Validate.notBlank(language, "language parameter cannot be empty.");
Validate.notBlank(artifact, "artifact parameter cannot be empty.");
final Task task = Task.builder()
.name(functionName)
.dind(dind)
.language(language)
.volumes(context.getString("volumes"))
.artifact(artifactURI)
.build();
final Future<TaskResult> runningResult = engine.run(task);
try {
return runningResult.get().getTaskId().getId();
} catch (Exception ex) {
//TODO: log ex
return null;
}
}
示例12: mapParametersUuid
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public UUID mapParametersUuid(String messageControlId, String parametersType) throws MapperException {
Validate.notBlank(messageControlId);
Validate.notBlank(parametersType);
String identifier = ResourceMapParameters.create()
.put(MessageControlIdKey, messageControlId)
.put(ParametersTypeKey, parametersType)
.createIdentifyingString();
return this.mapper.mapScopedResourceUuid(ResourceType.Parameters, identifier);
}
示例13: mapMessageHeaderUuid
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
public UUID mapMessageHeaderUuid(String messageControlId) throws MapperException {
Validate.notBlank(messageControlId);
String identifier = ResourceMapParameters.create()
.put(MessageControlIdKey, messageControlId)
.createIdentifyingString();
return this.mapper.mapScopedResourceUuid(ResourceType.MessageHeader, identifier);
}
示例14: fetchResource
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) {
Validate.notBlank(theUri, "theUri must not be null or blank");
if (theClass.equals(StructureDefinition.class)) {
return (T) fetchStructureDefinition(theContext, theUri);
}
if (theClass.equals(ValueSet.class) || theUri.startsWith(URL_PREFIX_VALUE_SET)) {
return (T) fetchValueSet(theContext, theUri);
}
return null;
}
開發者ID:nhsconnect,項目名稱:careconnect-reference-implementation,代碼行數:16,代碼來源:SNOMEDUKMockValidationSupport.java
示例15: validate
import org.apache.commons.lang3.Validate; //導入方法依賴的package包/類
private void validate() {
Validate.notNull(config, "config");
Validate.notBlank(dateTimeFormatPattern, "dateTimeFormatPattern");
Validate.notBlank(timeZoneId, "timeZoneId");
Validate.isTrue(
!StringUtils.isBlank(template) || !StringUtils.isBlank(templateUri),
"both template and templateUri are blank");
}