本文整理汇总了Java中org.springframework.util.StringUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isEmpty方法的具体用法?Java StringUtils.isEmpty怎么用?Java StringUtils.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: search
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public List<Favorite> search(String userId, String appId, Pageable page) {
boolean isUserIdEmpty = StringUtils.isEmpty(userId);
boolean isAppIdEmpty = StringUtils.isEmpty(appId);
if (isAppIdEmpty && isUserIdEmpty) {
throw new BadRequestException("user id and app id can't be empty at the same time");
}
//search by userId
if (isAppIdEmpty && !isUserIdEmpty) {
return favoriteRepository.findByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId, page);
}
//search by appId
if (!isAppIdEmpty && isUserIdEmpty) {
return favoriteRepository.findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc(appId, page);
}
//search by userId and appId
return Arrays.asList(favoriteRepository.findByUserIdAndAppId(userId, appId));
}
示例2: encode
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public static byte[] encode(String secret, String data) throws Exception {
if (StringUtils.isEmpty(secret) || StringUtils.isEmpty(data)) {
throw new IllegalArgumentException("Secret and Data must be supplied.");
}
Mac mac = Mac.getInstance("HmacSHA256");
// get the bytes of the hmac key and data string
// byte[] secretByte = secret.getBytes();
byte[] secretByte = new Hex().decode(secret.getBytes());
// byte[] secretByte = hexStringToByteArray(secret);
byte[] dataBytes = data.getBytes("UTF-8");
SecretKey secretKey = new SecretKeySpec(secretByte, "HmacSHA256");
mac.init(secretKey);
byte[] doFinal = mac.doFinal(dataBytes);
return doFinal;
// byte[] hexB = new Hex().encode(doFinal);
// return hexB;
}
示例3: build
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* by map
* @param map
* @return
*/
public HbaseFindBuilder build(Map<String,String> map) {
if (map == null || map.size() <= 0) {
return this;
}
PropertyDescriptor p = null;
byte[] qualifierByte = null;
for (String value : map.values()) {
if (StringUtils.isEmpty(value)) {
continue;
}
p = fieldsMap.get(value.trim());
qualifierByte = result.getValue(family.getBytes(), HumpNameOrMethodUtils.humpEntityForVar(value).getBytes());
if (qualifierByte != null && qualifierByte.length > 0) {
beanWrapper.setPropertyValue(p.getName(), Bytes.toString(qualifierByte));
propertiesSet.add(p.getName());
}
}
return this;
}
示例4: getFormattedElement
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getFormattedElement(AccessLogParam accessLogParam) {
HttpServerRequest request = accessLogParam.getRoutingContext().request();
if (null == request) {
return EMPTY_RESULT;
}
SocketAddress remoteAddress = request.remoteAddress();
if (null == remoteAddress) {
return EMPTY_RESULT;
}
String remoteHost = remoteAddress.host();
if (StringUtils.isEmpty(remoteHost)) {
return EMPTY_RESULT;
}
return remoteHost;
}
示例5: getSort
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public String getSort() {
if(StringUtils.isEmpty(sort)){
return "createdAt";
}else{
return sort;
}
}
示例6: getOrder
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public String getOrder() {
//默诵为顺序
if (StringUtils.isEmpty(order)) {
return "ASC";
}
return order;
}
示例7: filterByLocation
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private List<User> filterByLocation(List<User> unfiltered, String location) {
if (StringUtils.isEmpty(location)) {
return unfiltered;
}
return unfiltered.stream()
.filter(user -> user.getLdapDetails().getLocation().equals(location))
.collect(Collectors.toList());
}
示例8: convert
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private Identifier convert(Identifier identifier) {
if (identifier == null || StringUtils.isEmpty(identifier.getText())) {
return identifier;
}
String newName = addUnderscores(identifier.getText());
return Identifier.toIdentifier(newName);
}
示例9: cloudVaultConfigurer
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
@Bean
public VaultConnectorConfigurer cloudVaultConfigurer() {
List<String> activeProfiles = Arrays.asList(environment.getActiveProfiles());
List<SecretBackendMetadata> backends = new ArrayList<SecretBackendMetadata>();
List<String> order = connectorVaultProperties.getBackends();
if (order.size() == 1
&& order.contains(VaultConnectorGenericBackendProperties.DEFAULT)) {
order = getDefaultOrder(vaultServiceInfo);
}
for (String cloudBackend : order) {
String backend = getBackend(cloudBackend, vaultServiceInfo);
List<String> contexts = GenericSecretBackendMetadata.buildContexts(
genericBackendProperties, activeProfiles);
if (StringUtils.isEmpty(backend)) {
throw new IllegalArgumentException(String.format(
"Cannot resolve backend for %s", cloudBackend));
}
for (String context : contexts) {
backends.add(GenericSecretBackendMetadata.create(backend, context));
}
}
return new VaultConnectorConfigurer(backends);
}
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:34,代码来源:VaultConnectorBootstrapConfiguration.java
示例10: mediaUrl
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public static String mediaUrl(String requestUrl, String targetUrl) {
String lowerUrl = targetUrl.toLowerCase();
if (lowerUrl.startsWith(HTTP_PROTOCOL) || lowerUrl.startsWith(HTTPS_PROTOCOL)) {
return targetUrl;
}
if (lowerUrl.startsWith(BASE_PATH) && !StringUtils.isEmpty(requestUrl)) {
URI uri = URI.create(requestUrl);
String hostUrl = uri.getScheme() + "://" + uri.getHost();
return hostUrl + targetUrl;
} else {
return HTTP_PROTOCOL + targetUrl;
}
}
示例11: parseDeviceData
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
protected DeviceData parseDeviceData(DocumentContext document) throws ParseException {
long ts = System.currentTimeMillis();
String deviceName = eval(document, deviceNameJsonExpression);
String deviceType = null;
if (!StringUtils.isEmpty(deviceTypeJsonExpression)) {
deviceType = eval(document, deviceTypeJsonExpression);
}
if (!StringUtils.isEmpty(deviceName)) {
List<KvEntry> attrData = getKvEntries(document, attributes);
List<TsKvEntry> tsData = getTsKvEntries(document, timeseries, ts);
return new DeviceData(deviceName, deviceType, attrData, tsData);
} else {
return null;
}
}
示例12: isAuthValid
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public boolean isAuthValid() {
if(AuthScheme.BASIC == authScheme) {
return !StringUtils.isEmpty(actuatorUsername) && !StringUtils.isEmpty(actuatorPassword);
}
return true;
}
示例13: correctSwagger
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
* 查找必填但是没值的字段,将之设置为默认值
* 如果无法构造默认值,则抛出异常
*/
protected void correctSwagger() {
if (StringUtils.isEmpty(swagger.getSwagger())) {
swagger.setSwagger("2.0");
}
correctBasePath();
correctInfo();
correctProduces();
correctConsumes();
}
示例14: getServerName
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
static String getServerName(String argName) {
if (StringUtils.isEmpty(argName)) {
return "服务器";
} else {
return argName + " ";
}
}
示例15: buildQuery
import org.springframework.util.StringUtils; //导入方法依赖的package包/类
private Query buildQuery(NewsQueryRequest request) {
QueryBuilder queryBuilder = new QueryBuilder();
if (!StringUtils.isEmpty(request.getTitle())) {
queryBuilder.add(Criteria.where("title").regex(request.getTitle()));
}
if (!StringUtils.isEmpty(request.getCategory())) {
queryBuilder.add(Criteria.where("category").regex(request.getCategory()));
}
if (request.getPublished() != null) {
queryBuilder.add(Criteria.where("published").is(request.getPublished().booleanValue()));
}
if (request.getNewsType() != null) {
queryBuilder.add(Criteria.where("newsType").is(request.getNewsType()));
}
if (request.getCreatedAtBegin() != null && request.getCreatedAtEnd() != null) {
queryBuilder.and(Criteria.where("createdAt").gte(request.getCreatedAtBegin()))
.and(Criteria.where("createdAt").lte(request.getCreatedAtEnd()));
} else if (request.getCreatedAtBegin() != null) {
queryBuilder.add(Criteria.where("createdAt").gte(request.getCreatedAtBegin()));
} else if (request.getCreatedAtEnd() != null) {
queryBuilder.add(Criteria.where("createdAt").lte(request.getCreatedAtEnd()));
}
if (request.getBeginDate() != null && request.getEndDate() != null) {
queryBuilder.and(Criteria.where("publishedAt").gte(request.getBeginDate()))
.and(Criteria.where("publishedAt").lte(request.getEndDate()));
} else if (request.getBeginDate() != null) {
queryBuilder.add(Criteria.where("publishedAt").gte(request.getBeginDate()));
} else if (request.getEndDate() != null) {
queryBuilder.add(Criteria.where("publishedAt").lte(request.getEndDate()));
}
return queryBuilder.build();
}