本文整理汇总了Java中java.util.Objects.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java Objects.isNull方法的具体用法?Java Objects.isNull怎么用?Java Objects.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Objects
的用法示例。
在下文中一共展示了Objects.isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParameter
import java.util.Objects; //导入方法依赖的package包/类
private Query setParameter(SQLQuery query, Object... values) {
if (Objects.isNull(values) || values.length == 0) {
return query;
}
int i = 0;
for (Object value : values) {
query.setParameter(i, value);
i++;
}
return query;
}
示例2: getRunningScript
import java.util.Objects; //导入方法依赖的package包/类
@Override
public String getRunningScript(Node node) {
if (!Strings.isNullOrEmpty(node.getPlugin())) {
Plugin plugin = pluginService.find(node.getPlugin());
if (Objects.isNull(plugin)) {
throw new FlowException("Not found plugin, plugin name is " + node.getPlugin());
}
if (Objects.isNull(plugin.getPluginDetail())) {
throw new FlowException("Not found plugin detail, plugin name is " + node.getPlugin());
}
String pluginFolder = Paths
.get(AppConfig.DEFAULT_AGENT_REPO_DIR,
new SyncRepo(plugin.getName(), plugin.getCurrentTag()).toString())
.toString();
return "cd " + pluginFolder + Unix.LINE_SEPARATOR + plugin.getPluginDetail().getRun();
}
return node.getScript();
}
示例3: serialize
import java.util.Objects; //导入方法依赖的package包/类
/**
* 序列化对象 对象应实现Serializable接口
*
* @param obj 要序列化的对象
* @param <T> 对象类型
* @return byte数组
*/
public static <T extends Serializable> byte[] serialize(T obj) {
if (Objects.isNull(obj)) {
throw new NullPointerException("传入对象不能为空");
}
try (ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(arrayOutputStream)
) {
objectOutputStream.writeObject(obj);
return arrayOutputStream.toByteArray();
} catch (IOException e) {
logger.severe(e.getMessage());
}
return null;
}
示例4: invokeFieldGettersMethodToCustomizeString
import java.util.Objects; //导入方法依赖的package包/类
/**
* 反射调用对象字段的Getters方法,结果定制输出成字符串
* <p>
* 只适用于个别业务场景
*
* @param object
* @param fieldName
* @return 结果定制化
*/
public static String invokeFieldGettersMethodToCustomizeString ( Object object , String fieldName ) {
final Object methodResult = invokeFieldGettersMethod( object , fieldName );
if ( Objects.isNull( methodResult ) ) {
return StringUtils.EMPTY;
}
if ( methodResult.getClass().isEnum() ) {
return invokeFieldGettersMethod( methodResult , "comment" ).toString();
} else if ( methodResult instanceof Date ) {
return DateUtils.formatDateByStyle( ( Date ) methodResult );
}
return methodResult.toString();
}
示例5: updateRetry
import java.util.Objects; //导入方法依赖的package包/类
/**
* 更改恢复次数
*
* @param id 事务id
* @param retry 恢复次数
* @param applicationName 应用名称
* @return true 成功
*/
@Override
public Boolean updateRetry(String id, Integer retry, String applicationName) {
if (StringUtils.isBlank(id) || StringUtils.isBlank(applicationName) || Objects.isNull(retry)) {
return Boolean.FALSE;
}
String keyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(applicationName);
final String key = RepositoryPathUtils.buildRedisKey(keyPrefix,id);
final byte[] bytes = jedisClient.get(key.getBytes());
try {
final CoordinatorRepositoryAdapter adapter =
objectSerializer.deSerialize(bytes, CoordinatorRepositoryAdapter.class);
adapter.setRetriedCount(retry);
adapter.setLastTime(DateUtils.getDateYYYY());
jedisClient.set(key, objectSerializer.serialize(adapter));
return Boolean.TRUE;
} catch (Exception e) {
e.printStackTrace();
return Boolean.FALSE;
}
}
示例6: setDataSourceKey
import java.util.Objects; //导入方法依赖的package包/类
/**
* 设置数据源key
*/
private void setDataSourceKey ( JoinPoint joinPoint , final String defaultKey ) {
final Method method = this.currentMethod( joinPoint );
final DynamicDataSource dynamicDataSource = method.getAnnotation( DynamicDataSource.class );
if ( Objects.isNull( dynamicDataSource ) ) {
DynamicMultipleDataSource.setDataSourceKey( defaultKey );
return;
}
DynamicMultipleDataSource.setDataSourceKey( dynamicDataSource.value() );
}
开发者ID:yujunhao8831,项目名称:spring-boot-mybatisplus-multiple-datasource,代码行数:13,代码来源:DataSourceSwitch.java
示例7: invoke
import java.util.Objects; //导入方法依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (Object.class.equals(method.getDeclaringClass())) {
return method.invoke(this, args);
} else {
final Myth myth = method.getAnnotation(Myth.class);
if (Objects.isNull(myth)) {
return this.handlers.get(method).invoke(args);
}
try {
final MythTransactionManager mythTransactionManager =
SpringBeanUtils.getInstance().getBean(MythTransactionManager.class);
final MythParticipant participant = buildParticipant(myth, method, args);
if (Objects.nonNull(participant)) {
mythTransactionManager.registerParticipant(participant);
}
return this.handlers.get(method).invoke(args);
} catch (Throwable throwable) {
throwable.printStackTrace();
return null;
}
}
}
示例8: updateByNodes
import java.util.Objects; //导入方法依赖的package包/类
@Override
public Node updateByNodes(final String path, final List<Node> children) {
Node flow = find(PathUtil.rootPath(path)).root();
// validate plugin
pluginValidation(children);
// find exist yml
Yml exist = ymlService.get(flow.getPath());
Node flowForYml = Objects.isNull(exist) ?
new Node(flow.getPath(), flow.getName()) :
ymlService.build(flow, exist.getFile());
// set latest children and parse to yml
flowForYml.setChildren(children);
String ymlFromRoot = ymlService.parse(flowForYml);
// set YML status to found and update yml
ymlService.saveOrUpdate(flow, ymlFromRoot);
flowDao.update(flow);
updateYmlState(flow, FlowEnvs.YmlStatusValue.FOUND, null);
// reset cache
getTreeCache().evict(flow.getPath());
//retry find flow
return find(PathUtil.rootPath(path)).root();
}
示例9: coolNamedMethod
import java.util.Objects; //导入方法依赖的package包/类
public Filter coolNamedMethod(Filter.AfterFilter filter) {
final FieldDescriptor descriptor = factory.getField(filter.getField());
if(Objects.isNull(descriptor)){
return null;
} else {
return filter;
}
}
示例10: confirm
import java.util.Objects; //导入方法依赖的package包/类
/**
* 调用confirm方法 这里主要如果是发起者调用 这里调用远端的还是原来的方法,不过上下文设置了调用confirm
* 那么远端的服务则会调用confirm方法。。
*/
void confirm() throws TccRuntimeException {
LogUtil.debug(LOGGER, () -> "开始执行tcc confirm 方法!start");
final TccTransaction currentTransaction = getCurrentTransaction();
if (Objects.isNull(currentTransaction)) {
return;
}
currentTransaction.setStatus(TccActionEnum.CONFIRMING.getCode());
coordinatorCommand.execute(new CoordinatorAction(CoordinatorActionEnum.UPDATE, currentTransaction));
final List<Participant> participants = currentTransaction.getParticipants();
List<Participant> failList = Lists.newArrayListWithCapacity(participants.size());
boolean success = true;
if (CollectionUtils.isNotEmpty(participants)) {
for (Participant participant : participants) {
try {
TccTransactionContext context = new TccTransactionContext();
context.setAction(TccActionEnum.CONFIRMING.getCode());
context.setTransId(participant.getTransId());
TransactionContextLocal.getInstance().set(context);
executeParticipantMethod(participant.getConfirmTccInvocation());
} catch (Exception e) {
LogUtil.error(LOGGER, "执行confirm方法异常:{}", () -> e);
success = false;
failList.add(participant);
}
}
executeHandler(success, currentTransaction, failList);
}
}
示例11: parseToken
import java.util.Objects; //导入方法依赖的package包/类
private Authentication parseToken(final String token) {
final Jws<Claims> tokenData = Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
final Authentication jwtAuth = getAuthenticationFromToken(tokenData);
if (Objects.isNull(jwtAuth)) {
return null;
}
return validatePasswordFromToken(tokenData, jwtAuth);
}
示例12: convertDO2BO
import java.util.Objects; //导入方法依赖的package包/类
public static UserBO convertDO2BO(UserDO user) {
if (Objects.isNull(user)) {
return null;
}
UserBO result = new UserBO();
result.setAge(user.getAge());
result.setName(user.getName());
result.setMan(true);
result.setSex(user.getSex());
return result;
}
示例13: convertBean
import java.util.Objects; //导入方法依赖的package包/类
/**
* 单个Bean转换
*
* @throws ConvertException 转换异常
*
* @param source 被转换对象
* @param targetClass 需要转换到的类型
* @param exceptionSupplier 异常操作
* @param <T> 转换前的类型
* @param <U> 转换后的类型
* @param <X> 异常返回类型
* @return 结果
*/
public static <T, U, X extends RuntimeException> U convertBean(T source, Class<U> targetClass,
Supplier<X> exceptionSupplier) {
Objects.requireNonNull(targetClass,"TargetClass can not be null");
if (Objects.isNull(source)) {
return SupplierUtil.ifNonNullThrowOrElse(exceptionSupplier, () -> null);
}
Handler handler = ConverterContext.getActionHandler(source.getClass(), targetClass);
log.info("Call method \"{}\"", handler.getMethod());
try {
return targetClass.cast(handler.getMethod().invoke(handler.getHandler(), source));
} catch (IllegalAccessException | InvocationTargetException e) {
throw ConvertException.of("Call method \"" + handler.getMethod() + "\" failed", e);
}
}
示例14: FullClassName
import java.util.Objects; //导入方法依赖的package包/类
public FullClassName(String completeClassName) {
if(Objects.isNull(completeClassName) || completeClassName.trim().isEmpty())
throw new InvalidClassName();
this.completeClassName = completeClassName.trim().replace(" ","");
}
示例15: isNotEqual
import java.util.Objects; //导入方法依赖的package包/类
public static Predicate isNotEqual(final Object target) {
return (null == target) ? Objects::nonNull : me -> Objects.isNull(me) || !me.equals(target);
}