本文整理匯總了Java中org.apache.commons.collections.MapUtils.isNotEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java MapUtils.isNotEmpty方法的具體用法?Java MapUtils.isNotEmpty怎麽用?Java MapUtils.isNotEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.collections.MapUtils
的用法示例。
在下文中一共展示了MapUtils.isNotEmpty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isDefined
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* 判斷對象是不是定義了 <br>
* List的話,不為NULL和空<br>
* 字符串的的話,不為NULL或空<br>
* Integer的話,不為NULL或0<br>
*
* @param obj
* 要判斷的對象
* @return 是否定義了
*/
public static boolean isDefined(Object obj) {
if (obj instanceof Collection) {
return CollectionUtils.isNotEmpty((Collection<?>) obj);
}
if (obj instanceof Map) {
return MapUtils.isNotEmpty((Map<?, ?>) obj);
}
if (obj instanceof String) {
return StringUtils.isNotEmpty((String) obj);
}
if (obj instanceof Integer) {
return obj != null && (Integer) obj != 0;
}
return obj != null;
}
示例2: onChanged
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public void onChanged(String parentPath, List<String> currentChildren) {
if (currentChildren == null) {
LOGGER.error("{} is null", parentPath);
return;
} else {
LOGGER.warn("{} is changed to '{}'", parentPath, currentChildren);
}
Map<Integer, String> zkRedisCluster = new HashMap<Integer, String>();
for (String node : currentChildren) {
String nodeData = client.getData(String.class, parentPath + SLASH + node);
zkRedisCluster.put(Integer.parseInt(node), nodeData);
}
if (MapUtils.isNotEmpty(zkRedisCluster) && !zkRedisCluster.equals(redisCluster)) {
redisCluster = zkRedisCluster;
if (isRedisAccessParallel) {
redisAccess = new RedisAccessParallel(zkRedisCluster);
} else {
redisAccess = new RedisAccessSerial(zkRedisCluster);
}
}
}
示例3: queryEntity
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public <T> T queryEntity(Class<T> entityClass, String sql, Object... params) {
T result;
try {
Map<String, String> columnMap = EntityHelper.getColumnMap(entityClass);
if (MapUtils.isNotEmpty(columnMap)) {
result = queryRunner.query(sql, new BeanHandler<T>(entityClass, new BasicRowProcessor(new BeanProcessor(columnMap))), params);
} else {
result = queryRunner.query(sql, new BeanHandler<T>(entityClass), params);
}
} catch (SQLException e) {
logger.error("查詢出錯!", e);
throw new RuntimeException(e);
}
printSQL(sql);
return result;
}
示例4: createWebTarget
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private static WebTarget createWebTarget(String uri, Map<String, String> queryParams) throws URISyntaxException
{
WebTarget webTarget = null;
URI u = new URI(uri);
Client client = ClientBuilder.newClient();
webTarget = client.target(u);
if (MapUtils.isNotEmpty(queryParams))
{
for (Entry<String, String> entry : queryParams.entrySet())
{
if (StringUtils.isNotBlank(entry.getKey()) && StringUtils.isNotBlank(entry.getValue()))
{
String value = UriComponent.encode(
entry.getValue(),
UriComponent.Type.QUERY_PARAM_SPACE_ENCODED);
webTarget = webTarget.queryParam(entry.getKey(), value);
}
}
}
return webTarget;
}
示例5: process
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* 替換模板內的占位符格式有以下三種:
* <ul>
* <li>template:<i>{}走路掉{}裏了</i> model:<i>["小明", "坑"]</i> --> <i><b>小明</b>走路掉<b>坑</b>裏了</i></li>
* <li>template:<i>{0}走路掉{1}裏了</i> model:<i>["小東", "缸"]</i> --> <i><b>小東</b>走路掉<b>缸</b>裏了</i></li>
* <li>template:<i>{name}走路掉{thing}裏了</i> model:<i>{"name": "小李", "thing": "池塘"}</i> --> <i><b>小李</b>走路掉<b>池塘</b>裏了</i></li>
* </ul>
* @param template 模板內容
* @param model 替換數據 - 可以是POJO對象或者Map類型或者數組
* @return
*/
@Override
public String process(String template, Object model) throws ParseTemplateException {
int mode = Strings.EMPTY_INDEX_MODEL | Strings.NUM_INDEX_MODEL | Strings.KEY_VALUE_MODEL;
try {
String roughTmpl;
if (model != null && model.getClass().isArray()
&& !model.getClass().getComponentType().isPrimitive()) {
roughTmpl = Strings.formatMix(template, mode, defaultVal, (Object[]) model);
} else {
roughTmpl = Strings.formatMix(template, mode, defaultVal, model);
}
if (MapUtils.isNotEmpty(this.globalModel)) {
roughTmpl = Strings.formatMix(roughTmpl, mode, defaultVal, this.globalModel);
}
return roughTmpl;
} catch (Exception e) {
throw new ParseTemplateException("Parse template error.", e);
}
}
示例6: toCustomFieldValues
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
public <CFV extends CustomFieldValue> void toCustomFieldValues(final Class<CFV> valueClass, final List<? extends CustomField> allowedFields, final Map<String, String> customValues, final Collection<CFV> fieldValues) {
if (MapUtils.isNotEmpty(customValues)) {
for (String internalName : customValues.keySet()) {
String value = customValues.get(internalName);
if (StringUtils.isNotEmpty(value)) {
CustomField field = customFieldHelper.findByInternalName(allowedFields, internalName);
if (field == null) {
throw new IllegalArgumentException("Couldn't find custom field with internal name: '" + internalName + "' or the field is not searchable");
} else {
CFV fieldValue;
try {
fieldValue = valueClass.newInstance();
} catch (Exception e) {
throw new IllegalStateException(e);
}
fieldValue.setField(field);
fieldValue.setValue(value);
fieldValues.add(fieldValue);
}
}
}
}
}
示例7: getPattrenId
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private Long getPattrenId(String modelType, Map<Long, Integer> contentionCounts, List<DiagnosisCount> diagnosisCount, Long claimantAge, Long claimCount, long size, long cddAge) {
List<DDMModelPattern> patterns = ddmDataService.getPatternId(modelType, claimantAge, claimCount, size, cddAge);
List<Long> diagPattren = new ArrayList<>();
List<Long> cntntPattrens = new ArrayList<>();
Long pattrenId = null;
if (CollectionUtils.isNotEmpty(patterns)) {
List<Long> patternsList = patterns.stream().map(DDMModelPattern::getPatternId).collect(Collectors.toList());
if(MapUtils.isNotEmpty(contentionCounts)){
LOG.info("Contention count :::::: " + contentionCounts);
cntntPattrens = ddmModelCntntService.getKneePatternId(contentionCounts, patternsList, modelType.toUpperCase());
}
if (CollectionUtils.isNotEmpty(cntntPattrens)) {
//List<Long> diagPatternsList = patterns.stream().map(DDMModelPattern::getPatternId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(diagnosisCount)) {
LOG.info("Diagnosis count :::::: " + diagnosisCount);
diagPattren = ddmModelDiagService.getKneePatternId(diagnosisCount, cntntPattrens, modelType.toUpperCase());
}
LOG.info("PATTREN SIZE :::::: " + diagPattren);
if (CollectionUtils.isNotEmpty(diagPattren)) {
pattrenId = diagPattren.get(0);
LOG.info("PATTREN ID :: " + pattrenId);
}
}
}
return pattrenId;
}
示例8: buildMultiPartEntity
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* @param buildMap
* @param partParam
*
* @return HttpEntity
*/
public static HttpEntity buildMultiPartEntity(Map<String, String> buildMap, Map<String, ContentBody> partParam) {
if (MapUtils.isEmpty(buildMap)) {
return null;
}
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
buildMap.forEach((k, v) -> builder.addTextBody(k, v));
if (MapUtils.isNotEmpty(partParam)) {
partParam.forEach((k, v) -> builder.addPart(k, v));
}
return builder.build();
}
示例9: parseUserAgent
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private static void parseUserAgent(XmTimeline timeline) {
if (MapUtils.isNotEmpty(timeline.getRequestHeaders())) {
String ua = timeline.getRequestHeaders().get("user-agent");
if (StringUtils.isNotBlank(ua)) {
ReadableUserAgent agent = parser.parse(ua);
timeline.setBrowser(agent.getName() + " " + agent.getVersionNumber().toVersionString());
timeline.setOpSystem(agent.getOperatingSystem().getName() + " "
+ agent.getOperatingSystem().getVersionNumber().toVersionString());
}
}
}
示例10: buildParamMap
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
protected Map<String, Object> buildParamMap(HttpServletRequest request) {
Map<String, Object> paramMap = new HashMap();
Map<String, String[]> maps = request.getParameterMap();
if (MapUtils.isNotEmpty(maps)) {
maps.forEach((key, value) -> paramMap.put(key, value[0]));
}
return paramMap;
}
示例11: updateCookies
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private void updateCookies(Map<String, NewCookie> newCookies)
{
if (MapUtils.isNotEmpty(newCookies))
{
cookies.putAll(newCookies);
}
}
示例12: init
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@PostConstruct
public void init() throws Exception {
Assert.isFalse(freeMarkerConfigurationFactory == null && configuration == null,
"freeMarkerConfigurationFactory and configuration are both null.");
if (configuration == null && freeMarkerConfigurationFactory != null) {
configuration = freeMarkerConfigurationFactory.createConfiguration();
}
if (MapUtils.isNotEmpty(this.globalModel)) {
configuration.setAllSharedVariables(new SimpleHash(this.globalModel, configuration.getObjectWrapper()));
}
}
示例13: sendTemplateMsg
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* 發送模板消息
*
* @param toUser 接受者OpenId
* @param templateId 使用的模板Id,通過{@link #getTemplateId(String)}獲取的
* @param url 微信中點擊消息後進入的頁麵
* @param datas 需要的數據
* @return 消息id
*/
public String sendTemplateMsg(String toUser, String templateId, String url, List<TemplateData> datas) {
Assert.hasText(toUser);
Assert.hasText(templateId);
Assert.hasText(url);
Assert.notNull(datas);
Map<String, Object> params = new HashMap<>(4);
params.put("touser", toUser);
params.put("template_id", templateId);
params.put("url", url);
Map<String, Map<String, String>> configs = new HashMap<>(datas.size());
for (TemplateData data : datas) {
String key = data.getKey();
String color = data.getColor();
String value = data.getValue();
Map<String, String> temp = new HashMap<>(2);
temp.put("color", color);
temp.put("value", value);
configs.put(key, temp);
}
params.put("data", configs);
Map<String, Object> result = WeChatRequest.post(String.format(WeChatUrl.API_SEND_TEMPLATE_MESSAGE, WeChat.accessToken()), params,
new TypeReference<Map<String, Object>>() {
});
return MapUtils.isNotEmpty(result) ? (result.get("msgid") != null ? result.get("msgid").toString() : StringUtils.EMPTY) : StringUtils.EMPTY;
}
示例14: getAttributeValue
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* Required provisioning entity attribute value can be retrieved by passing attribute key, return null if value is
* not found
* @param provisioningEntity
* @param claimURI
* @return
*/
public static String getAttributeValue(ProvisioningEntity provisioningEntity, String claimURI){
Map<org.wso2.carbon.identity.application.common.model.ClaimMapping, List<String>> attributes =
provisioningEntity.getAttributes();
if (MapUtils.isNotEmpty(attributes)) {
List<String> valueList = attributes.get(org.wso2.carbon.identity.application.common.model.ClaimMapping
.build(claimURI, null, null, false));
if (valueList != null && !valueList.isEmpty()) {
return valueList.get(0);
}
}
return null;
}
示例15: setClaimsForComplexAttribute
import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
* set claim mapping for complex attribute
* @param entry
* @param claimsMap
*/
private static void setClaimsForComplexAttribute(Attribute entry, Map<String, String> claimsMap) throws CharonException {
// reading attributes list of the complex attribute
ComplexAttribute entryOfComplexAttribute = (ComplexAttribute) entry;
Map<String, Attribute> entryAttributes = null;
if (entryOfComplexAttribute.getSubAttributesList() != null &&
MapUtils.isNotEmpty(entryOfComplexAttribute.getSubAttributesList())) {
entryAttributes = entryOfComplexAttribute.getSubAttributesList();
}
for (Attribute subEntry : entryAttributes.values()) {
// attribute can only be simple attribute and that also in the extension schema only
setClaimsForSimpleAttribute(subEntry, claimsMap);
}
}