本文整理汇总了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");
}