當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。