org.simpleflatmapper.GetterWithDefaultValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-reflect Show documentation
Show all versions of sfm-reflect Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.simpleflatmapper;
import org.simpleflatmapper.reflect.Getter;
public class GetterWithDefaultValue implements Getter {
private final Getter super T, ? extends P> delegate;
private final P defaultValue;
public GetterWithDefaultValue(Getter super T, ? extends P> delegate, P defaultValue) {
this.delegate = delegate;
this.defaultValue = defaultValue;
}
@Override
public P get(T target) throws Exception {
P p = delegate.get(target);
if (p == null) return defaultValue;
return p;
}
}