我想要创建一个扩展idempiere产品模型的类,以创建来自其他字段的代码,但是我不知道应该导入哪个类,也不知道应该重写什么方法。
org.compiere.model.MProduct:
public MProduct (X_I_Product impP)
{
this (impP.getCtx(), 0, impP.get_TrxName());
setClientOrg(impP);
setUpdatedBy(impP.getUpdatedBy());
// Value field:
setValue(impP.getValue());
setName(impP.getName());
setDescription(impP.getDescription());
setDocumentNote(impP.getDocumentNote());
setHelp(impP.getHelp());
setUPC(impP.getUPC());
setSKU(impP.getSKU());
setC_UOM_ID(impP.getC_UOM_ID());
setM_Product_Category_ID(impP.getM_Product_Category_ID());
setProductType(impP.getProductType());
setImageURL(impP.getImageURL());
setDescriptionURL(impP.getDescriptionURL());
setVolume(impP.getVolume());
setWeight(impP.getWeight());
} // MProduct发布于 2022-06-18 20:19:30
在其中一个注释中,您澄清了您的意图是“扩展MProduct类并覆盖保存”值“列的方法”。
要回答这个问题,首先让我们定义一个MProduct类的简单版本,其中包含几个编辑:
impP.getValue())
setValue()方法,因为这是与您的问题相关的唯一部分( MProduct上的其他方法与setValue()的输入参数更改为int,而原始类型在您的示例中(无论返回类型来自于以下是MProduct的一个简单版本
class MProduct {
void setValue(int value) {
System.out.println("setValue() on MProduct");
}
}下面是一个简单的类,它通过重写MProduct方法来扩展setValue():
class CustomProduct extends MProduct {
@Override
void setValue(int value) {
System.out.println("setValue() on CustomProduct");
// custom code goes here
}
}最后,下面是一个简单的示例,展示了上述两个类( MProduct和CustomProduct)的用法:
public static void main(String[] args) {
new CustomProduct().setValue(123);
new MProduct().setValue(123);
}下面是运行该示例的输出:
setValue() on CustomProduct
setValue() on MProducthttps://stackoverflow.com/questions/70174661
复制相似问题