1 package org.kuali.common.util.env.adapter; 2 3 import org.kuali.common.util.nullify.NullUtils; 4 5 import com.google.common.base.Optional; 6 7 public final class OptionalStringAdapter implements EnvAdapter<String, Optional<String>> { 8 9 @Override 10 public Class<String> getSourceType() { 11 return String.class; 12 } 13 14 @Override 15 public Optional<String> convert(String s) { 16 String trimmed = NullUtils.trimToNull(s); 17 if (trimmed == null) { 18 return Optional.absent(); 19 } else { 20 return Optional.of(trimmed); 21 } 22 } 23 24 }