orika-mapper/orika

Mapping multiple fields into single field

Earthstar opened this issue · 1 comments

I want to map two objects that look like:

public class FirstObject {
  private long field;
  private boolean isSetField;
  
  public void setField(long field) {
    this.field = field;
    setFieldIsSet(true);
  }

  private void setFieldIsSet (boolean value) {
    this.isSetField = value;
 }

  public long getField() {
    return this.field;
  }
  public getIsSetField() {
    return this.isSetField;
  }
}

public class SecondObject {
  private Long field;

  public long getField() {
    return this.field;
  }

  public void setField(String field) {
    this.field = field;
  }
}

I want to convert field from FirstObject to SecondObject only if isSetField is true. I do NOT want to set secondObject.field = 0 if firstObject.field == 0 and firstObject.isSetField == false. How do you set up a converter like so?

我基于三元表达式做了一个扩展,支持传入三元表达式,将计算结果传入目标值。有疑问的话,联系:bawfnje@foxmail.com