当前位置: 首页>>代码示例>>Java>>正文


Java Objects.isNull方法代码示例

本文整理汇总了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;
}
 
开发者ID:wu05281,项目名称:admin-shiro,代码行数:12,代码来源:DaoSupport.java

示例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();
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:25,代码来源:NodeServiceImpl.java

示例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;
}
 
开发者ID:lovejj1994,项目名称:Simplify-Core,代码行数:24,代码来源:SerializationUtil.java

示例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();
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:22,代码来源:ReflectionProUtils.java

示例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;
    }

}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:30,代码来源:RedisCompensationServiceImpl.java

示例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;
        }


    }
}
 
开发者ID:yu199195,项目名称:myth,代码行数:28,代码来源:MythFeignHandler.java

示例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();
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:30,代码来源:NodeServiceImpl.java

示例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;
    }
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:9,代码来源:SolrFilterSerializer.java

示例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);
    }



}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:44,代码来源:TccTransactionManager.java

示例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);
}
 
开发者ID:akraskovski,项目名称:product-management-system,代码行数:11,代码来源:JwtService.java

示例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;
}
 
开发者ID:liaochong,项目名称:spring-boot-starter-converter,代码行数:12,代码来源:UserConverter.java

示例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);
    }
}
 
开发者ID:liaochong,项目名称:spring-boot-starter-converter,代码行数:28,代码来源:BeanConvertStrategy.java

示例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(" ","");
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:6,代码来源:FullClassName.java

示例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);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:4,代码来源:MPredicateHelper.java


注:本文中的java.util.Objects.isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。