当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.isEmpty方法代码示例

本文整理汇总了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));
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:22,代码来源:FavoriteService.java

示例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;
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:20,代码来源:HmacUtils.java

示例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;
}
 
开发者ID:cwenao,项目名称:springboot_cwenao,代码行数:31,代码来源:HbaseFindBuilder.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:RemoteHostElement.java

示例5: getSort

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public String getSort() {
    if(StringUtils.isEmpty(sort)){
        return "createdAt";
    }else{
        return sort;
    }
}
 
开发者ID:wu05281,项目名称:admin-shiro,代码行数:8,代码来源:RoleDO.java

示例6: getOrder

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public String getOrder() {
    //默诵为顺序
    if (StringUtils.isEmpty(order)) {
        return "ASC";
    }
    return order;
}
 
开发者ID:egzosn,项目名称:spring-jdbc-orm,代码行数:8,代码来源:PageParams.java

示例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());
}
 
开发者ID:sinnerschrader,项目名称:SkillWill,代码行数:9,代码来源:UserService.java

示例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);
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:9,代码来源:PhysicalNamingStrategyImpl.java

示例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;
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:14,代码来源:WxUrlUtils.java

示例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;
    }
}
 
开发者ID:osswangxining,项目名称:iot-edge-greengrass,代码行数:16,代码来源:BasicJsonConverter.java

示例12: isAuthValid

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
public boolean isAuthValid() {
	if(AuthScheme.BASIC == authScheme) {
		return !StringUtils.isEmpty(actuatorUsername) && !StringUtils.isEmpty(actuatorPassword);
	}

	return true;
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:8,代码来源:Application.java

示例13: correctSwagger

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
/**
 * 查找必填但是没值的字段,将之设置为默认值
 * 如果无法构造默认值,则抛出异常
 */
protected void correctSwagger() {
  if (StringUtils.isEmpty(swagger.getSwagger())) {
    swagger.setSwagger("2.0");
  }

  correctBasePath();
  correctInfo();
  correctProduces();
  correctConsumes();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:SwaggerGenerator.java

示例14: getServerName

import org.springframework.util.StringUtils; //导入方法依赖的package包/类
static String getServerName(String argName) {
    if (StringUtils.isEmpty(argName)) {
        return "服务器";
    } else {
        return argName + " ";
    }
}
 
开发者ID:chenjazz,项目名称:DingTalkRobot-SpringBoot,代码行数:8,代码来源:ListenerUtils.java

示例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();
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:37,代码来源:NewsRepositoryImpl.java


注:本文中的org.springframework.util.StringUtils.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。