001package net.bramp.ffmpeg.modelmapper; 002 003import com.google.common.base.Defaults; 004import com.google.common.base.Objects; 005import com.google.errorprone.annotations.Immutable; 006import org.modelmapper.Condition; 007import org.modelmapper.spi.MappingContext; 008 009/** 010 * Only maps properties which are not their type's default value. 011 * 012 * @param <S> source type 013 * @param <D> destination type 014 * @author bramp 015 */ 016@Immutable 017public class NotDefaultCondition<S, D> implements Condition<S, D> { 018 019 public static final NotDefaultCondition<Object, Object> notDefault = new NotDefaultCondition<>(); 020 021 @Override 022 public boolean applies(MappingContext<S, D> context) { 023 return !Objects.equal(context.getSource(), Defaults.defaultValue(context.getSourceType())); 024 } 025}