本文整理汇总了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());
}
}
示例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);
}
}
示例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;
}
示例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");
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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());
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例15: onDisabled
import java.util.Objects; //导入方法依赖的package包/类
@Override
public void onDisabled() {
if(Objects.nonNull(getLocalPlayer()))
getLocalPlayer().noClip = false;
}