當前位置: 首頁>>代碼示例>>Java>>正文


Java Assert.hasText方法代碼示例

本文整理匯總了Java中org.springframework.util.Assert.hasText方法的典型用法代碼示例。如果您正苦於以下問題:Java Assert.hasText方法的具體用法?Java Assert.hasText怎麽用?Java Assert.hasText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.util.Assert的用法示例。


在下文中一共展示了Assert.hasText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: delete

import org.springframework.util.Assert; //導入方法依賴的package包/類
@Override
public void delete(final String path) {

    Assert.hasText(path, "Path must not be empty");

    try {
        sessionTemplate.delete(path);
    } catch (HttpStatusCodeException e) {

        if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
            return;
        }

        throw VaultResponses.buildException(e, path);
    }
}
 
開發者ID:JetBrains,項目名稱:teamcity-hashicorp-vault-plugin,代碼行數:17,代碼來源:VaultTemplate.java

示例2: removeCookie

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * 移除cookie
 * 
 * @param request
 *            HttpServletRequest
 * @param response
 *            HttpServletResponse
 * @param name
 *            cookie名稱
 * @param path
 *            路徑
 * @param domain
 *            域
 */
public static void removeCookie(HttpServletRequest request, HttpServletResponse response, String name, String path,
		String domain) {
	Assert.notNull(request);
	Assert.notNull(response);
	Assert.hasText(name);
	try {
		name = URLEncoder.encode(name, "UTF-8");
		Cookie cookie = new Cookie(name, null);
		cookie.setMaxAge(0);
		if (StringUtils.isNotEmpty(path)) {
			cookie.setPath(path);
		}
		if (StringUtils.isNotEmpty(domain)) {
			cookie.setDomain(domain);
		}
		response.addCookie(cookie);
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
}
 
開發者ID:wenjian-li,項目名稱:spring_mybatis_shiro,代碼行數:35,代碼來源:CookieUtils.java

示例3: findField

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * <p>根據屬性字段名稱獲取@{code java.lang.reflect.Field}</p>
 * 
 * @param targetClass
 * @param fieldName
 * @return
 */
public static Field findField(Class<?> targetClass, String fieldName) {
	Assert.notNull(targetClass, "Parameter 'targetClass' must be not null!");
	Assert.hasText(fieldName, "Parameter 'fieldName' must be not empty!");
	Class<?> searchType = targetClass;
	while (!Object.class.equals(searchType) && searchType != null) {
		Field[] fields = searchType.getDeclaredFields();
		for (Field field : fields) {
			if (fieldName.equals(field.getName())) {
				return field;
			}
		}
		searchType = searchType.getSuperclass();
	}
	return null;
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:23,代碼來源:ReflectionUtils.java

示例4: getAccessibleField

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * 循環向上轉型, 獲取對象的DeclaredField, 並強製設置為可訪問.
 * <p/>
 * 如向上轉型到Object仍無法找到, 返回null.
 *
 * @param targetClass 目標對象Class
 * @param fieldName   class中的字段名
 * @return {@link java.lang.reflect.Field}
 */
public static Field getAccessibleField(final Class targetClass,
                                       final String fieldName) {
    Assert.notNull(targetClass, "targetClass不能為空");
    Assert.hasText(fieldName, "fieldName不能為空");
    for (Class<?> superClass = targetClass; superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            Field field = superClass.getDeclaredField(fieldName);
            field.setAccessible(true);
            return field;
        } catch (NoSuchFieldException e) {
        }
    }
    return null;
}
 
開發者ID:egzosn,項目名稱:spring-jdbc-orm,代碼行數:25,代碼來源:ReflectionUtils.java

示例5: locateBundle

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * Locates (through the {@link ArtifactLocator}) an OSGi bundle given as a
 * String.
 * 
 * The default implementation expects the argument to be in Comma Separated
 * Values (CSV) format which indicates an artifact group, id, version and
 * optionally the type.
 * 
 * @param bundleId the bundle identifier in CSV format
 * @return a resource pointing to the artifact location
 */
protected Resource locateBundle(String bundleId) {
	Assert.hasText(bundleId, "bundleId should not be empty");

	// parse the String
	String[] artifactId = StringUtils.commaDelimitedListToStringArray(bundleId);

	Assert.isTrue(artifactId.length >= 3, "the CSV string " + bundleId + " contains too few values");
	// TODO: add a smarter mechanism which can handle 1 or 2 values CSVs
	for (int i = 0; i < artifactId.length; i++) {
		artifactId[i] = StringUtils.trimWhitespace(artifactId[i]);
	}

	ArtifactLocator aLocator = getLocator();

	return (artifactId.length == 3 ? aLocator.locateArtifact(artifactId[0], artifactId[1], artifactId[2])
			: aLocator.locateArtifact(artifactId[0], artifactId[1], artifactId[2], artifactId[3]));
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:29,代碼來源:AbstractDependencyManagerTests.java

示例6: setFieldValue

import org.springframework.util.Assert; //導入方法依賴的package包/類
public static void setFieldValue(Object object, String propertyName,
        Object newValue, boolean targetAccessible)
        throws NoSuchFieldException, IllegalAccessException {
    Assert.notNull(object);
    Assert.hasText(propertyName);

    Field field = getDeclaredField(object, propertyName);

    boolean accessible = field.isAccessible();
    field.setAccessible(targetAccessible);

    field.set(object, newValue);

    field.setAccessible(accessible);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:16,代碼來源:BeanUtils.java

示例7: DefaultPublisherFactory

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * Create {@link DefaultPublisherFactory} instance based on the provided {@link GcpProjectIdProvider}.
 * <p>The {@link GcpProjectIdProvider} must not be null, neither provide an empty {@code projectId}.
 * @param projectIdProvider provides the GCP project ID
 */
public DefaultPublisherFactory(GcpProjectIdProvider projectIdProvider) {
	Assert.notNull(projectIdProvider, "The project ID provider can't be null.");

	this.projectId = projectIdProvider.getProjectId();
	Assert.hasText(this.projectId, "The project ID can't be null or empty.");
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-gcp,代碼行數:12,代碼來源:DefaultPublisherFactory.java

示例8: HandlerMethod

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * Create an instance from a bean name, a method, and a {@code BeanFactory}.
 * The method {@link #createWithResolvedBean()} may be used later to
 * re-create the {@code HandlerMethod} with an initialized the bean.
 */
public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) {
	Assert.hasText(beanName, "Bean name is required");
	Assert.notNull(beanFactory, "BeanFactory is required");
	Assert.notNull(method, "Method is required");
	Assert.isTrue(beanFactory.containsBean(beanName),
			"BeanFactory [" + beanFactory + "] does not contain bean [" + beanName + "]");
	this.bean = beanName;
	this.beanFactory = beanFactory;
	this.method = method;
	this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
	this.parameters = initMethodParameters();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:HandlerMethod.java

示例9: createQuery

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * 根據查詢HQL與參數列表創建Query對象.
 *
 * @param values 命名參數,按名稱綁定.
 */
public Query createQuery(final String queryString, final Map<String, ?> values) {
    Assert.hasText(queryString, "queryString不能為空");
    Query query = getSession().createQuery(queryString);
    if (values != null) {
        query.setProperties(values);
    }
    return query;
}
 
開發者ID:dragon-yuan,項目名稱:Ins_fb_pictureSpider_WEB,代碼行數:14,代碼來源:GenericDao.java

示例10: createSqlQueryMappingColumns

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * Return a query using native SQL and column mapping.
 *
 * @param sql           native SQL
 * @param columnMapping column mapping,key is dbColumn, value is propertyName.
 * @return the created Query using native SQL and column mapping config.
 */
public <T> Query<T> createSqlQueryMappingColumns(Class<T> entityType,
                                                 String sql,
                                                 Map<String, String> columnMapping) {
  Assert.notNull(entityType, "entityType must not null");
  Assert.hasText(sql, "sql must has text");
  Assert.notEmpty(columnMapping, "columnMapping must not empty");
  RawSqlBuilder rawSqlBuilder = RawSqlBuilder.parse(sql);
  columnMapping.entrySet().forEach(entry -> {
    rawSqlBuilder.columnMapping(entry.getKey(), entry.getValue());
  });
  return ebeanServer.find(entityType).setRawSql(rawSqlBuilder.create());
}
 
開發者ID:hexagonframework,項目名稱:spring-data-ebean,代碼行數:20,代碼來源:EbeanQueryChannelService.java

示例11: setDatabaseType

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * @param databaseType the databaseType to set
 */
public void setDatabaseType(String databaseType) {
	Assert.hasText(databaseType, "databaseType must not be empty nor null");
	this.databaseType = databaseType;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dashboard,代碼行數:8,代碼來源:SqlPagingQueryProviderFactoryBean.java

示例12: setScript

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * Set a fresh script String, overriding the previous script.
 * @param script the script String
 */
public synchronized void setScript(String script) {
	Assert.hasText(script, "Script must not be empty");
	this.modified = !script.equals(this.script);
	this.script = script;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:StaticScriptSource.java

示例13: Version

import org.springframework.util.Assert; //導入方法依賴的package包/類
@JsonCreator
public Version(@JsonProperty("build_number") String buildNumber) {
	Assert.hasText(buildNumber, "Build Number must not be empty");
	this.buildNumber = buildNumber;
}
 
開發者ID:spring-io,項目名稱:artifactory-resource,代碼行數:6,代碼來源:Version.java

示例14: isConnectable

import org.springframework.util.Assert; //導入方法依賴的package包/類
/**
 * @param host must not be {@literal null} or empty.
 * @param port
 * @return {@literal true} if the TCP port accepts a connection.
 */
public static boolean isConnectable(String host, int port) {

	Assert.hasText(host, "Host must not be null or empty!");

	try (Socket socket = new Socket()) {

		socket.setSoLinger(true, 0);
		socket.connect(new InetSocketAddress(host, port), (int) TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS));

		return true;

	} catch (Exception e) {
		return false;
	}
}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:21,代碼來源:CassandraSocket.java

示例15: findHumanTask

import org.springframework.util.Assert; //導入方法依賴的package包/類
public HumanTaskDTO findHumanTask(String humanTaskId) {
    Assert.hasText(humanTaskId, "humanTaskId不能為空");

    TaskInfo taskInfo = taskInfoManager.get(Long.parseLong(humanTaskId));

    return this.convertHumanTaskDto(taskInfo);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:8,代碼來源:HumanTaskConnectorImpl.java


注:本文中的org.springframework.util.Assert.hasText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。