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


Java ObjectUtils類代碼示例

本文整理匯總了Java中org.apache.commons.lang3.ObjectUtils的典型用法代碼示例。如果您正苦於以下問題:Java ObjectUtils類的具體用法?Java ObjectUtils怎麽用?Java ObjectUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: findAll

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
@Override
public Page<T> findAll(final Set<T> groups, final String criteria, final Pageable pageable, final Map<String, Comparator<T>> customComparators) {
	// Create the set with the right comparator
	final List<Sort.Order> orders = IteratorUtils.toList(ObjectUtils.defaultIfNull(pageable.getSort(), new ArrayList<Sort.Order>()).iterator());
	orders.add(DEFAULT_ORDER);
	final Sort.Order order = orders.get(0);
	Comparator<T> comparator = customComparators.get(order.getProperty());
	if (order.getDirection() == Direction.DESC) {
		comparator = Collections.reverseOrder(comparator);
	}
	final Set<T> result = new TreeSet<>(comparator);

	// Filter the groups, filtering by the criteria
	addFilteredByPattern(groups, criteria, result);

	// Apply in-memory pagination
	return inMemoryPagination.newPage(result, pageable);
}
 
開發者ID:ligoj,項目名稱:plugin-id-ldap,代碼行數:19,代碼來源:AbstractContainerLdaRepository.java

示例2: writeIssueData

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * Complete the standard data with temporal data (not SLA), sub task, and components
 */
@Override
protected void writeIssueData(final IssueDetails issue, final Writer writer, final Format df, final Format idf) throws IOException {
	// Write static data
	super.writeIssueData(issue, writer, df, idf);

	// Time spent
	writer.write(';');
	writer.write(String.valueOf(ObjectUtils.defaultIfNull((Object) issue.getTimeSpent(), "")));

	// Time estimate
	writer.write(';');
	writer.write(String.valueOf(ObjectUtils.defaultIfNull((Object) issue.getTimeEstimate(), "")));

	// Time initial estimate
	writer.write(';');
	writer.write(String.valueOf(ObjectUtils.defaultIfNull((Object) issue.getTimeEstimateInit(), "")));

	// Optional parent
	writer.write(';');
	writer.write(String.valueOf(ObjectUtils.defaultIfNull(subTasks.get(issue.getId()), "")));

	// Custom non fixed fields
	writeCustomData((IssueSla) issue, writer, df);
}
 
開發者ID:ligoj,項目名稱:plugin-bt-jira,代碼行數:28,代碼來源:CsvWithCustomFieldsStreamingOutput.java

示例3: write

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
@Override
public void write(final Kryo kryo, final Output output, final RegisteredService service) {
    kryo.writeObject(output, service.getServiceId());
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getName(), ""));
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getDescription(), ""));
    kryo.writeObject(output, service.getId());
    kryo.writeObject(output, service.getEvaluationOrder());
    kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogo(), getEmptyUrl()));
    kryo.writeObject(output, service.getLogoutType());
    kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogoutUrl(), getEmptyUrl()));
    kryo.writeObject(output, ImmutableSet.copyOf(service.getRequiredHandlers()));
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getTheme(), ""));

    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getPublicKey(),
            new RegisteredServicePublicKeyImpl()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getProxyPolicy(),
            new RefuseRegisteredServiceProxyPolicy()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAttributeReleasePolicy(),
            new ReturnAllowedAttributeReleasePolicy()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getUsernameAttributeProvider(),
            new DefaultRegisteredServiceUsernameProvider()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAccessStrategy(),
            new DefaultRegisteredServiceAccessStrategy()));
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:25,代碼來源:RegisteredServiceSerializer.java

示例4: save

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
private void save(final SlaEditionVo vo, final Sla entity) {
	DescribedBean.copy(vo, entity);
	entity.setStop(StringUtils.join(identifierHelper.normalize(vo.getStop()), ','));
	entity.setStart(StringUtils.join(identifierHelper.normalize(vo.getStart()), ','));
	entity.setThreshold(vo.getThreshold());
	vo.setPause(ObjectUtils.defaultIfNull(vo.getPause(), new ArrayList<>()));
	vo.setPriorities(ObjectUtils.defaultIfNull(vo.getPriorities(), new ArrayList<>()));
	vo.setResolutions(ObjectUtils.defaultIfNull(vo.getResolutions(), new ArrayList<>()));
	vo.setTypes(ObjectUtils.defaultIfNull(vo.getTypes(), new ArrayList<>()));
	checkSlaBounds(vo);
	entity.setPause(StringUtils.join(identifierHelper.normalize(vo.getPause()), ','));
	entity.setPriorities(StringUtils.join(vo.getPriorities(), ','));
	entity.setResolutions(StringUtils.join(vo.getResolutions(), ','));
	entity.setTypes(StringUtils.join(vo.getTypes(), ','));
	slaRepository.saveAndFlush(entity);
}
 
開發者ID:ligoj,項目名稱:plugin-bt,代碼行數:17,代碼來源:BugTrackerResource.java

示例5: write

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
@Override
public void write(final Kryo kryo, final Output output, final RegisteredService service) {
    kryo.writeObject(output, service.getServiceId());
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getName(), StringUtils.EMPTY));
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getDescription(), StringUtils.EMPTY));
    kryo.writeObject(output, service.getId());
    kryo.writeObject(output, service.getEvaluationOrder());
    kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogo(), getEmptyUrl()));
    kryo.writeObject(output, service.getLogoutType());
    kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogoutUrl(), getEmptyUrl()));
    kryo.writeObject(output, new HashSet<>(service.getRequiredHandlers()));
    kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getTheme(), StringUtils.EMPTY));

    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getPublicKey(),
            new RegisteredServicePublicKeyImpl()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getProxyPolicy(),
            new RefuseRegisteredServiceProxyPolicy()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAttributeReleasePolicy(),
            new ReturnAllowedAttributeReleasePolicy()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getUsernameAttributeProvider(),
            new DefaultRegisteredServiceUsernameProvider()));
    writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAccessStrategy(),
            new DefaultRegisteredServiceAccessStrategy()));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:25,代碼來源:RegisteredServiceSerializer.java

示例6: handleConfigurationModifiedEvent

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * Handle configuration modified event.
 *
 * @param event the event
 */
@EventListener
public void handleConfigurationModifiedEvent(final CasConfigurationModifiedEvent event) {
    if (this.contextRefresher == null) {
        LOGGER.warn("Unable to refresh application context, since no refresher is available");
        return;
    }

    if (event.isEligibleForContextRefresh()) {
        LOGGER.info("Received event [{}]. Refreshing CAS configuration...", event);
        Collection<String> keys = null;
        try {
            keys = this.contextRefresher.refresh();
            LOGGER.debug("Refreshed the following settings: [{}].", keys);
        } catch (final Throwable e) {
            LOGGER.trace(e.getMessage(), e);
        } finally {
            rebind();
            LOGGER.info("CAS finished rebinding configuration with new settings [{}]",
                    ObjectUtils.defaultIfNull(keys, Collections.emptyList()));
        }
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:28,代碼來源:CasConfigurationEventListener.java

示例7: writeData

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * Write issue data
 */
private void writeData(final JiraChangeItem change, final String key, final Writer writer, final Format df, final Format idf) throws IOException {
	// Write static data
	writer.write(change.getId().toString());
	writer.write(';');
	writer.write(key);
	writer.write(';');
	writer.write(ObjectUtils.defaultIfNull(change.getAuthor(), change.getReporter()));
	writer.write(';');
	writer.write(ObjectUtils.defaultIfNull(change.getFromStatus(), "").toString());
	writer.write(';');
	writer.write(String.valueOf(change.getToStatus()));
	writer.write(';');
	writer.write(idf.format(ObjectUtils.defaultIfNull(statusText.get(change.getFromStatus()), "")));
	writer.write(';');
	writer.write(idf.format(statusText.get(change.getToStatus())));
	writer.write(';');
	writer.write(df.format(change.getCreated()));
	writer.write(';');
	writer.write(String.valueOf(change.getCreated().getTime()));
}
 
開發者ID:ligoj,項目名稱:plugin-bt-jira,代碼行數:24,代碼來源:CsvStatusStreamingOutput.java

示例8: createNode

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * 創建節點
 *
 * @param path
 * @param data
 * @param mode
 * @return
 */
public boolean createNode(String path, String data, CreateMode mode) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat == null) {
            mode = mode == null ? CreateMode.PERSISTENT : mode;
            String opResult;
            if (ObjectUtils.allNotNull(data)) {
                opResult = zkClient.create().creatingParentContainersIfNeeded().withMode(mode).forPath(path, data.getBytes(Charsets.UTF_8));
            } else {
                opResult = zkClient.create().creatingParentContainersIfNeeded().withMode(mode).forPath(path);
            }
            return Objects.equal(opResult, path);
        }
        return Boolean.TRUE;
    } catch (Exception e) {
        log.error("create node fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:31,代碼來源:ZkUtils.java

示例9: deleteNode

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * 刪除節點  遞歸刪除子節點
 *
 * @param path
 * @param version
 * @return
 */
public boolean deleteNode(String path, Integer version) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat != null) {
            if (version == null) {
                zkClient.delete().deletingChildrenIfNeeded().forPath(path);
            } else {
                zkClient.delete().deletingChildrenIfNeeded().withVersion(version).forPath(path);
            }
        }
        return Boolean.TRUE;
    } catch (Exception e) {
        log.error("delete node fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:27,代碼來源:ZkUtils.java

示例10: setNodeData

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * 設置節點數據
 *
 * @param path
 * @param data
 * @param version
 * @return
 */
public boolean setNodeData(String path, byte[] data, Integer version) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return Boolean.FALSE;
    }
    try {
        Stat stat = exists(path);
        if (stat != null) {
            if (version == null) {
                zkClient.setData().forPath(path, data);
            } else {
                zkClient.setData().withVersion(version).forPath(path, data);
            }
            return Boolean.TRUE;
        }
    } catch (Exception e) {
        log.error("set node data fail! path: {}, error: {}", path, e);
    }
    return Boolean.FALSE;
}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:28,代碼來源:ZkUtils.java

示例11: listenerPathChildrenCache

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
     * 設置子節點更改監聽
     *
     * @param path
     * @throws Exception
     */
    public boolean listenerPathChildrenCache(String path, BiConsumer<CuratorFramework, PathChildrenCacheEvent> biConsumer) {

        if (!ObjectUtils.allNotNull(zkClient, path, biConsumer)) {
            return Boolean.FALSE;
        }
        try {
            Stat stat = exists(path);
            if (stat != null) {
                PathChildrenCache watcher = new PathChildrenCache(zkClient, path, true);
                watcher.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
                //該模式下 watcher在重連的時候會自動 rebuild 否則需要重新rebuild
                watcher.getListenable().addListener(biConsumer::accept, pool);
                if (!pathChildrenCaches.contains(watcher)) {
                    pathChildrenCaches.add(watcher);
                }
//                else{
//                    watcher.rebuild();
//                }
                return Boolean.TRUE;
            }
        } catch (Exception e) {
            log.error("listen path children cache fail! path:{} , error:{}", path, e);
        }
        return Boolean.FALSE;
    }
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:32,代碼來源:ZkUtils.java

示例12: readTargetChildsData

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * 讀取指定節點的子菜單的值
 *
 * @param path
 * @return
 */
public Map<String, String> readTargetChildsData(String path) {
    if (!ObjectUtils.allNotNull(zkClient, path)) {
        return null;
    }
    Map<String, String> map = null;
    try {
        Stat stat = exists(path);
        if (stat != null) {
            List<String> childrens = zkClient.getChildren().forPath(path);
            GetDataBuilder dataBuilder = zkClient.getData();
            if (childrens != null) {
                map = childrens.stream().collect(Collectors.toMap(Function.identity(), (child) -> {
                    try {
                        return new String(dataBuilder.forPath(ZKPaths.makePath(path, child)), Charsets.UTF_8);
                    } catch (Exception e1) {
                        return null;
                    }
                }));
            }
        }
    } catch (Exception e) {
        log.error("get target childs data fail!, path:{} , error:{}", path, e);
    }
    return map;

}
 
開發者ID:lee123lee123,項目名稱:GoPush,代碼行數:33,代碼來源:ZkUtils.java

示例13: createNotifyUrl

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * 創建響應URL
 * @param transOrder
 * @param backType 1:前台頁麵;2:後台接口
 * @return
 */
public String createNotifyUrl(TransOrder transOrder, String backType) {
	String mchId = transOrder.getMchId();
	MchInfo mchInfo = super.baseSelectMchInfo(mchId);
	String resKey = mchInfo.getResKey();
	Map<String, Object> paramMap = new HashMap<>();
	paramMap.put("transOrderId", ObjectUtils.defaultIfNull(transOrder.getTransOrderId(), ""));           	// 轉賬訂單號
	paramMap.put("mchId", ObjectUtils.defaultIfNull(transOrder.getMchId(), ""));                      	 	// 商戶ID
	paramMap.put("mchOrderNo", ObjectUtils.defaultIfNull(transOrder.getMchTransNo(), ""));       		 	// 商戶訂單號
	paramMap.put("channelId", ObjectUtils.defaultIfNull(transOrder.getChannelId(), ""));              		// 渠道ID
	paramMap.put("amount", ObjectUtils.defaultIfNull(transOrder.getAmount(), ""));                      	// 支付金額
	paramMap.put("currency", ObjectUtils.defaultIfNull(transOrder.getCurrency(), ""));                 		// 貨幣類型
	paramMap.put("status", ObjectUtils.defaultIfNull(transOrder.getStatus(), ""));               			// 轉賬狀態
	paramMap.put("result", ObjectUtils.defaultIfNull(transOrder.getResult(), ""));               			// 轉賬結果
	paramMap.put("clientIp", ObjectUtils.defaultIfNull(transOrder.getClientIp(), ""));   					// 客戶端IP
	paramMap.put("device", ObjectUtils.defaultIfNull(transOrder.getDevice(), ""));               			// 設備
	paramMap.put("channelOrderNo", ObjectUtils.defaultIfNull(transOrder.getChannelOrderNo(), "")); 			// 渠道訂單號
	paramMap.put("param1", ObjectUtils.defaultIfNull(transOrder.getParam1(), ""));               		   	// 擴展參數1
	paramMap.put("param2", ObjectUtils.defaultIfNull(transOrder.getParam2(), ""));               		   	// 擴展參數2
	paramMap.put("transSuccTime", ObjectUtils.defaultIfNull(transOrder.getTransSuccTime(), ""));			// 轉賬成功時間
	paramMap.put("backType", backType==null ? "" : backType);
	// 先對原文簽名
	String reqSign = PayDigestUtil.getSign(paramMap, resKey);
	paramMap.put("sign", reqSign);   // 簽名
	// 簽名後再對有中文參數編碼
	try {
		paramMap.put("device", URLEncoder.encode(ObjectUtils.defaultIfNull(transOrder.getDevice(), ""), PayConstant.RESP_UTF8));
		paramMap.put("param1", URLEncoder.encode(ObjectUtils.defaultIfNull(transOrder.getParam1(), ""), PayConstant.RESP_UTF8));
		paramMap.put("param2", URLEncoder.encode(ObjectUtils.defaultIfNull(transOrder.getParam2(), ""), PayConstant.RESP_UTF8));
	}catch (UnsupportedEncodingException e) {
		_log.error("URL Encode exception.", e);
		return null;
	}
	String param = XXPayUtil.genUrlParams(paramMap);
	StringBuffer sb = new StringBuffer();
	sb.append(transOrder.getNotifyUrl()).append("?").append(param);
	return sb.toString();
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:44,代碼來源:BaseNotify4MchTrans.java

示例14: upload

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
/**
 * Upload a file of quote in add mode.
 * 
 * @param subscription
 *            The subscription identifier, will be used to filter the locations
 *            from the associated provider.
 * @param uploadedFile
 *            Instance entries files to import. Currently support only CSV
 *            format.
 * @param columns
 *            the CSV header names.
 * @param term
 *            The default {@link ProvInstancePriceTerm} used when no one is
 *            defined in the CSV line
 * @param ramMultiplier
 *            The multiplier for imported RAM values. Default is 1.
 * @param encoding
 *            CSV encoding. Default is UTF-8.
 * @throws IOException
 *             When the CSV stream cannot be written.
 */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("{subscription:\\d+}/upload")
public void upload(@PathParam("subscription") final int subscription, @Multipart(value = "csv-file") final InputStream uploadedFile,
		@Multipart(value = "columns", required = false) final String[] columns,
		@Multipart(value = "term", required = false) final String term,
		@Multipart(value = "memoryUnit", required = false) final Integer ramMultiplier,
		@Multipart(value = "encoding", required = false) final String encoding) throws IOException {
	subscriptionResource.checkVisibleSubscription(subscription).getNode().getId();

	// Check column's name validity
	final String[] sanitizeColumns = ArrayUtils.isEmpty(columns) ? DEFAULT_COLUMNS : columns;
	checkHeaders(ACCEPTED_COLUMNS, sanitizeColumns);

	// Build CSV header from array
	final String csvHeaders = StringUtils.chop(ArrayUtils.toString(sanitizeColumns)).substring(1).replace(',', ';') + "\n";

	// Build entries
	final String safeEncoding = ObjectUtils.defaultIfNull(encoding, StandardCharsets.UTF_8.name());
	csvForBean
			.toBean(InstanceUpload.class, new InputStreamReader(
					new SequenceInputStream(new ByteArrayInputStream(csvHeaders.getBytes(safeEncoding)), uploadedFile), safeEncoding))
			.stream().filter(Objects::nonNull).forEach(i -> persist(i, subscription, term, ramMultiplier));
}
 
開發者ID:ligoj,項目名稱:plugin-prov,代碼行數:46,代碼來源:ProvQuoteInstanceResource.java

示例15: handleError

import org.apache.commons.lang3.ObjectUtils; //導入依賴的package包/類
protected void handleError(Throwable e) {
    if (engine != null) {
        if (engine.getInteractiveMode() != null) {
            engine.getInteractiveMode().getExceptionHandler().handleException(e,
                    new GenericExceptionContext(engine, ObjectUtils.defaultIfNull(SpongeUtils.getSourceName(e), "interactive")));
        } else {
            engine.handleError("standalone", e);
        }
    } else {
        if (e instanceof StandaloneInitializationException && !testMode) {
            System.out.println(e.getMessage());
            System.out.println("");
            builder.printHelp();
        } else {
            logger.error("Error", e);
        }
    }

    if (testMode) {
        throw SpongeUtils.wrapException(e);
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:23,代碼來源:StandaloneEngineMain.java


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