我有一个类PlanItemEditor。
我需要 E 项的复制构造函数。如何使用方法引用传递它?
public void initValues(ObservableList<E> srcList, E toEdit) {
indexToSet = srcList.indexOf(toEdit);
editing = new E(toEdit);
this.srcList = srcList;
}
我正在考虑包含一个一元函数作为参数,并从 E 类中传入一个方法,该方法正是一个复制构造函数,但具有不同的名称签名。然而,这有点骇人听闻。
有没有更好的方法来做到这一点?