StringUtils.defaultIfEmpty()的相应方法是什么,但对于LocalDate?

时间:2015-04-25 13:48:15

标签: java

private ClientIdentifier(final Client client, final CodeValue documentType, 
                         final String documentKey, final LocalDate validity, 
                         final String description) {
    this.client = client;
    this.documentType = documentType;
    this.documentKey = StringUtils.defaultIfEmpty(documentKey, null);
    this.validity = LocaleUtils.defaultIfEmpty(validity,null); // I am confused in this part
    this.description = StringUtils.defaultIfEmpty(description, null);
}

我正在通过LocalDate,但不知道用于检查defualtIfEmpty的实用程序

1 个答案:

答案 0 :(得分:0)

要为任何类型提供默认值,您可以使用例如来自Apache Commons的ObjectUtils.firstNonNull(T...)或来自Guava的MoreObjects.firstNonNull(T,T)