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


Java Objects.nonNull方法代碼示例

本文整理匯總了Java中java.util.Objects.nonNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Objects.nonNull方法的具體用法?Java Objects.nonNull怎麽用?Java Objects.nonNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Objects的用法示例。


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

示例1: updateJob

import java.util.Objects; //導入方法依賴的package包/類
public void updateJob(String group, String name, JobDescriptor descriptor) {
	try {
		JobDetail oldJobDetail = scheduler.getJobDetail(jobKey(name, group));
		if(Objects.nonNull(oldJobDetail)) {
			JobDataMap jobDataMap = oldJobDetail.getJobDataMap();
			jobDataMap.put("subject", descriptor.getSubject());
			jobDataMap.put("messageBody", descriptor.getMessageBody());
			jobDataMap.put("to", descriptor.getTo());
			jobDataMap.put("cc", descriptor.getCc());
			jobDataMap.put("bcc", descriptor.getBcc());
			JobBuilder jb = oldJobDetail.getJobBuilder();
			JobDetail newJobDetail = jb.usingJobData(jobDataMap).storeDurably().build();
			scheduler.addJob(newJobDetail, true);
			log.info("Updated job with key - {}", newJobDetail.getKey());
			return;
		}
		log.warn("Could not find job with key - {}.{} to update", group, name);
	} catch (SchedulerException e) {
		log.error("Could not find job with key - {}.{} to update due to error - {}", group, name, e.getLocalizedMessage());
	}
}
 
開發者ID:juliuskrah,項目名稱:quartz-manager,代碼行數:22,代碼來源:EmailService.java

示例2: after

import java.util.Objects; //導入方法依賴的package包/類
@Override
protected void after(Description description, Throwable testFailure) throws Throwable {
    super.after(description, testFailure);
    try {
        if (Objects.nonNull(testFailure)) {
            LOGGER.error("\n\n\nTest failed with error: ", testFailure);
            TestReportFile testReportFile = TestReportFile.forTest(description).withPostix("_action.log").build();
            FileUtils.copyFile(tempFile, testReportFile.getFile());
        }
    } finally {
        if (!tempFile.delete()) {
            LOGGER.error("Could not delete temp file at " + tempFile.getAbsolutePath());
        }
        tempFile = null;
        Logger.getLogger(LOGGER_NAME).removeAppender(APPENDER_NAME);
    }
}
 
開發者ID:willhaben,項目名稱:willtest,代碼行數:18,代碼來源:SeleniumEventListener.java

示例3: completeCommitTxTransaction

import java.util.Objects; //導入方法依賴的package包/類
/**
 * 完成提交自身的事務
 *
 * @param txGroupId 事務組id
 * @param taskKey   子事務的taskKey
 * @param status    狀態  {@linkplain com.happylifeplat.transaction.common.enums.TransactionStatusEnum}
 * @return true 成功 false 失敗
 */
@Override
public Boolean completeCommitTxTransaction(String txGroupId, String taskKey, int status) {
    HeartBeat heartBeat = new HeartBeat();
    heartBeat.setAction(NettyMessageActionEnum.COMPLETE_COMMIT.getCode());
    TxTransactionGroup txTransactionGroup = new TxTransactionGroup();
    txTransactionGroup.setId(txGroupId);
    TxTransactionItem item = new TxTransactionItem();
    item.setTaskKey(taskKey);
    item.setStatus(status);
    txTransactionGroup.setItemList(Collections.singletonList(item));
    heartBeat.setTxTransactionGroup(txTransactionGroup);
    final Object object = nettyClientMessageHandler.sendTxManagerMessage(heartBeat);
    if (Objects.nonNull(object)) {
        return (Boolean) object;
    }
    return false;
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:26,代碼來源:NettyMessageServiceImpl.java

示例4: afterChangeValueOf

import java.util.Objects; //導入方法依賴的package包/類
@Override
public void afterChangeValueOf(WebElement webElement, WebDriver webDriver, CharSequence[] charSequences) {
    if(Objects.nonNull(charSequences)) {
        StringBuilder stringBuilder = new StringBuilder();
        for (CharSequence charSequence : charSequences) {
            stringBuilder.append("['").append(charSequence).append("']");
        }
        LOGGER.info("Input in: " + getElementSelector(webElement) + " --- Input text: " + stringBuilder.toString());
    } else {
        LOGGER.info("Input in: " + getElementSelector(webElement) + " --- Cleared field");
    }
}
 
開發者ID:willhaben,項目名稱:willtest,代碼行數:13,代碼來源:SeleniumEventListener.java

示例5: getLatestSlackUpdatedTime

import java.util.Objects; //導入方法依賴的package包/類
private long getLatestSlackUpdatedTime() {
	Employee employee = employeeRepository.findOne(new Sort(Sort.Direction.DESC, EMPLOYEE_FIELDS.SLACK_UPDATEDTIME));
	if (Objects.nonNull(employee)) {
		return employee.getSlackUt();
	}
	return 0; 
}
 
開發者ID:Zymr,項目名稱:visitormanagement,代碼行數:8,代碼來源:EmployeeService.java

示例6: findTransactionGroupStatus

import java.util.Objects; //導入方法依賴的package包/類
/**
 * 獲取事務組狀態
 *
 * @param txGroupId 事務組id
 * @return 事務組狀態
 */
@Override
public int findTransactionGroupStatus(String txGroupId) {
    HeartBeat heartBeat = new HeartBeat();
    heartBeat.setAction(NettyMessageActionEnum.GET_TRANSACTION_GROUP_STATUS.getCode());
    TxTransactionGroup txTransactionGroup = new TxTransactionGroup();
    txTransactionGroup.setId(txGroupId);

    final Object object = nettyClientMessageHandler.sendTxManagerMessage(heartBeat);
    if (Objects.nonNull(object)) {
        return (Integer) object;
    }
    return TransactionStatusEnum.ROLLBACK.getCode();

}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:21,代碼來源:NettyMessageServiceImpl.java

示例7: escapeFormat

import java.util.Objects; //導入方法依賴的package包/類
private static String escapeFormat(final String string, final String... replacements) {
	final String[] replacementsNew = new String[replacements.length];
	for (int i = 0; i < replacements.length; i++) {
		final String replacementValue = replacements[i];
		if (Objects.nonNull(replacementValue)) {
			replacementsNew[i] = replacementValue.replace("'", "''");
		}
	}
	return MessageFormat.format(string, (Object[]) replacementsNew);
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:11,代碼來源:FavouritesController.java

示例8: createTestResult

import java.util.Objects; //導入方法依賴的package包/類
private TestResult createTestResult(final String uuid, final Description description) {
    final String className = description.getClassName();
    final String methodName = description.getMethodName();
    final String name = Objects.nonNull(methodName) ? methodName : className;
    final String fullName = Objects.nonNull(methodName) ? String.format("%s.%s", className, methodName) : className;
    final String suite = Optional.ofNullable(description.getTestClass().getAnnotation(DisplayName.class))
            .map(DisplayName::value).orElse(className);

    final TestResult testResult = new TestResult()
            .withUuid(uuid)
            .withHistoryId(getHistoryId(description))
            .withName(name)
            .withFullName(fullName)
            .withLinks(getLinks(description))
            .withLabels(
                    new Label().withName("package").withValue(getPackage(description.getTestClass())),
                    new Label().withName("testClass").withValue(className),
                    new Label().withName("testMethod").withValue(name),
                    new Label().withName("suite").withValue(suite),
                    new Label().withName("host").withValue(getHostName()),
                    new Label().withName("thread").withValue(getThreadName())
            );
    testResult.getLabels().addAll(getLabels(description));
    getDisplayName(description).ifPresent(testResult::setName);
    getDescription(description).ifPresent(testResult::setDescription);
    return testResult;
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:28,代碼來源:AllureJunit4.java

示例9: destroy

import java.util.Objects; //導入方法依賴的package包/類
@PreDestroy
public void destroy() throws Exception {
    if (Objects.nonNull(consumer)) {
        consumer.shutdown();
    }
    logger.info("consumer shutdown, {}", this.toString());
}
 
開發者ID:rhwayfun,項目名稱:spring-boot-rocketmq-starter,代碼行數:8,代碼來源:AbstractRocketMqConsumer.java

示例10: firstNonNullOrEmpty

import java.util.Objects; //導入方法依賴的package包/類
/**
 * Returns an {@link Optional} of the first non-null Object found within the given objects.
 *
 * @param objects
 *            objects to get the first non-null from
 * @return first non-null object or an empty {@link Optional}
 */
@SafeVarargs
public static <T> Optional<T> firstNonNullOrEmpty(final T... objects) {
	for (final T t : objects) {
		if (Objects.nonNull(t)) {
			return Optional.of(t);
		}
	}

	return Optional.empty();
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:18,代碼來源:OptionalUtility.java

示例11: initializeProcess

import java.util.Objects; //導入方法依賴的package包/類
private void initializeProcess() throws Exception {

        String userHome = System.getProperty("user.home");
        Path dataDir = Paths.get(userHome).resolve(".terminalfx");
        IOHelper.copyLibPty(dataDir);

        if (Platform.isWindows()) {
            this.termCommand = "cmd.exe".split("\\s+");
        } else {
            this.termCommand = "/bin/bash -i".split("\\s+");
        }

        if(Objects.nonNull(shellStarter)){
            this.termCommand = shellStarter.split("\\s+");
        }

        Map<String, String> envs = new HashMap<>(System.getenv());
        envs.put("TERM", "xterm");

        System.setProperty("PTY_LIB_FOLDER", dataDir.resolve("libpty").toString());

        this.process = PtyProcess.exec(termCommand, envs, userHome);

        process.setWinSize(new WinSize(columns, rows));
        this.inputReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        this.errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        this.outputWriter = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));

        ThreadHelper.start(() -> {
            printReader(inputReader);
        });

        ThreadHelper.start(() -> {
            printReader(errorReader);
        });

        process.waitFor();

    }
 
開發者ID:javaterminal,項目名稱:cloudterm,代碼行數:40,代碼來源:TerminalService.java

示例12: execute

import java.util.Objects; //導入方法依賴的package包/類
@Override
public void execute() {
    if (withTry && Objects.nonNull(recoverFunc)) {
        Try.apply(worker).recoverWith(recoverFunc);
        return;
    }

    if (withTry) {
        Try.apply(worker);
        return;
    }

    worker.execute();
}
 
開發者ID:lilbond,項目名稱:java-commons,代碼行數:15,代碼來源:Exec.java

示例13: withCompressionMetadata

import java.util.Objects; //導入方法依賴的package包/類
/**
 * Provide {@link CompressionMetadata} to use when reading compressed file.
 *
 * @param metadata CompressionMetadata to use
 * @return this object
 */
public Builder withCompressionMetadata(CompressionMetadata metadata)
{
    this.compressed = Objects.nonNull(metadata);
    this.compressionMetadata = metadata;
    return this;
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:13,代碼來源:FileHandle.java

示例14: isGreaterThanOrEqual

import java.util.Objects; //導入方法依賴的package包/類
public static Predicate<Double> isGreaterThanOrEqual(final Double target) {
  return (null == target) ? Objects::isNull : me -> Objects.nonNull(me) && me >= target;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:4,代碼來源:MPredicateHelper.java

示例15: onDisabled

import java.util.Objects; //導入方法依賴的package包/類
@Override
public void onDisabled() {
    if(Objects.nonNull(getLocalPlayer()))
        getLocalPlayer().noClip = false;
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:6,代碼來源:FlyMod.java


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