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


Java ObjectUtils.firstNonNull方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.ObjectUtils.firstNonNull方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.firstNonNull方法的具体用法?Java ObjectUtils.firstNonNull怎么用?Java ObjectUtils.firstNonNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.ObjectUtils的用法示例。


在下文中一共展示了ObjectUtils.firstNonNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractDdlReveng

import org.apache.commons.lang3.ObjectUtils; //导入方法依赖的package包/类
public AbstractDdlReveng(DbPlatform platform, MultiLineStringSplitter stringSplitter, ImmutableList<Predicate<String>> skipPredicates, ImmutableList<RevengPattern> revengPatterns, Procedure2<ChangeEntry, String> postProcessChange) {
    this.platform = platform;
    this.stringSplitter = stringSplitter;
    this.skipPredicates = skipPredicates;
    this.revengPatterns = revengPatterns;
    Procedure2<ChangeEntry, String> noOpProcedure = new Procedure2<ChangeEntry, String>() {
        @Override
        public void value(ChangeEntry changeEntry, String s) {

        }
    };
    this.postProcessChange = ObjectUtils.firstNonNull(postProcessChange, noOpProcedure);
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:14,代码来源:AbstractDdlReveng.java

示例2: getProperty

import org.apache.commons.lang3.ObjectUtils; //导入方法依赖的package包/类
public String getProperty(String key, String defaultValue) {
    return ObjectUtils.firstNonNull(getNullableProperty(key), defaultValue);
}
 
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:4,代码来源:PropertyHelper.java

示例3: revengFile

import org.apache.commons.lang3.ObjectUtils; //导入方法依赖的package包/类
private MutableList<ChangeEntry> revengFile(SchemaObjectReplacer schemaObjectReplacer, MutableList<Pair<String, RevengPatternOutput>> snippetPatternMatchPairs, String inputSchema) {
    final MutableList<ChangeEntry> changeEntries = Lists.mutable.empty();

    MutableMap<String, AtomicInteger> countByObject = Maps.mutable.empty();

    int selfOrder = 0;
    String candidateObject = "UNKNOWN";
    ChangeType candidateObjectType = UnclassifiedChangeType.INSTANCE;
    for (Pair<String, RevengPatternOutput> snippetPatternMatchPair : snippetPatternMatchPairs) {
        String sqlSnippet = snippetPatternMatchPair.getOne();
        try {
            sqlSnippet = removeQuotesFromProcxmode(sqlSnippet);  // sybase ASE

            RevengPattern chosenRevengPattern = null;
            String secondaryName = null;
            RevengPatternOutput patternMatch = snippetPatternMatchPair.getTwo();
            if (patternMatch != null) {
                chosenRevengPattern = patternMatch.getRevengPattern();
                candidateObject = patternMatch.getPrimaryName();
                if (patternMatch.getSecondaryName() != null) {
                    secondaryName = patternMatch.getSecondaryName();
                }
                candidateObjectType = platform.getChangeType(patternMatch.getRevengPattern().getChangeType());
            }

            // Ignore other schemas that may have been found in your parsing (came up during HSQLDB use case)

            sqlSnippet = schemaObjectReplacer.replaceSnippet(sqlSnippet);

            AtomicInteger objectOrder2 = countByObject.getIfAbsentPut(candidateObject, new Function0<AtomicInteger>() {
                @Override
                public AtomicInteger value() {
                    return new AtomicInteger(0);
                }
            });

            if (secondaryName == null) {
                secondaryName = "change" + objectOrder2.getAndIncrement();
            }
            RevEngDestination destination = new RevEngDestination(inputSchema, candidateObjectType, candidateObject, false);

            String annotation = chosenRevengPattern != null ? chosenRevengPattern.getAnnotation() : null;
            MutableList<Function<String, LineParseOutput>> postProcessSqls = chosenRevengPattern != null ? chosenRevengPattern.getPostProcessSqls() : Lists.mutable.<Function<String, LineParseOutput>>empty();

            for (Function<String, LineParseOutput> postProcessSql : postProcessSqls) {
                LineParseOutput lineParseOutput = postProcessSql.valueOf(sqlSnippet);
                sqlSnippet = lineParseOutput.getLineOutput();
            }

            Integer suggestedOrder = patternMatch != null ? patternMatch.getRevengPattern().getSuggestedOrder() : null;

            ChangeEntry change = new ChangeEntry(destination, sqlSnippet + "\nGO", secondaryName, annotation, ObjectUtils.firstNonNull(suggestedOrder, selfOrder++));

            postProcessChange.value(change, sqlSnippet);

            changeEntries.add(change);
        } catch (RuntimeException e) {
            throw new RuntimeException("Failed parsing on statement " + sqlSnippet, e);
        }
    }

    return changeEntries;
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:64,代码来源:AbstractDdlReveng.java

示例4: defaultErrorHandler

import org.apache.commons.lang3.ObjectUtils; //导入方法依赖的package包/类
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String,Object>> defaultErrorHandler(Exception e) throws Exception {
    if (e instanceof ServletException) {
        // ServletException will be handled by Spring
        throw e;
    }

    if (e instanceof AccessDeniedException) {
        // will be handled by Spring
        throw e;
    }

    final HttpStatus status;
    final String statusMessage;
    ResponseStatus responseStatus = AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class);
    if (responseStatus != null) {
        status = ObjectUtils.firstNonNull(responseStatus.code(), responseStatus.value());
        statusMessage = responseStatus.reason();
    } else {
        status = HttpStatus.INTERNAL_SERVER_ERROR;
        statusMessage = null;
    }
    final ResponseEntityBuilder reb = ResponseEntities
            .build(status)
            .message(ObjectUtils.firstNonNull(e.getMessage(),statusMessage));

    //DataExceptions can provide structured information about the error that
    //will serialized under the "data" field in the response 
    if(e instanceof DataException<?>){
        Object data = ((DataException<?>)e).getData();
        if(data != null){ //data may be null
            reb.data(data);
        }
    }

    if(writeTrace){
        reb.trace(ExceptionUtils.getStackTrace(e));
    } else {
        log.trace("trace omitted (webservice.errorhandler.writetrace=false)");
    }
    log.warn("ErrorResponse (status: {}, {}: {})", status, e.getClass().getSimpleName(), e.getMessage());
    log.debug("STACKTRACE:", e);
    return reb.build();
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:45,代码来源:GlobalDefaultExceptionHandler.java


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