'@Data annotion not working to set the value in Java

I have this POJO class:

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import java.io.Serializable;

@Data
@XmlAccessorType(XmlAccessType.FIELD )
public class FulfillmentOrder implements Serializable {

    private static final long serialVersionUID = 1L;

    @XmlElement(name="orderNbr")
    Integer orderNbr;

    public Integer setOrderNumbr(Integer orderNbr) {
        this.orderNbr=orderNbr;
        return orderNbr;
    }
}

I am trying to set the value of orderNbr from a different class.

FulfillmentOrder fo= new FulfillmentOrder();
Integer orderNum = 
  fo.setOrderNumbr(89898989);

I am trying to update the value of orderNbr in my XML output to 89898 and I want to do it using @Data.

But when I am doing fo.setOrderNbr(89898989)I am getting a compile time error as Error:(56, 132) java: incompatible types: void cannot be converted to java.lang.Integer, since lombok returns void.

Any way of `fo.setOrderNbr(89898989) to update the value?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source