当前位置: 首页>>代码示例>>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;未经允许,请勿转载。