如何使用抽象类中的值保存对象?

问题描述

我上课

@Data
public class ScreenshotInput extends InputModel implements Serializable {
  private static final long serialVersionUID = 1L;

  private final byte[] image;
  private final Timestamp timeCreated;

  public ScreenshotInput(byte[] image,String taskName,Timestamp timestamp) {
    super(taskName);
    this.image = image;
    this.timeCreated = timestamp;
  }
}

和我的抽象InputModel类:

@Data
public abstract class InputModel {
  private String taskName;
  private String userName;

  public InputModel(String taskName) {
    this.taskName = taskName;
    this.userName = Preferences.userRoot().get("username","username");
  }
}

当我想保存创建的对象ScreenshotInput时,只有ScreenshotInput类中定义的值保存到我的对象中:图像和时间戳。值taskname和username是可用的(例如,当我想在将对象保存到桩之前将其打印),但是它们不在桩上的对象中。 认情况下,如何将InputModel中的变量写入对象?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)