【发布时间】:2010-11-02 09:45:51
【问题描述】:
我通过如下注释的 Java 代码使用 EMF
/**
* Adds the given type to this filter. Has no effect if the given type
* already belongs to this filter.
*
* @param type
* the type to add
* @model
*/
public void addEntityType(String type);
/**
* Returns the list of types belonging to this filter. Types are identified
* by there name.
*
* @return the list of types for this entity type filter
*
* @model
*/
public List<String> getEntityTypes();
/**
* Removes the given type from this filter. Has no effect if the given type
* doesn't belong to this filter.
*
* @param type
* the type to remove
* @model
*/
public void removeEntityType(String type);
从这个带注释的接口创建ecore和genmodel文件后,生成代码后,getEntityTypes方法修改如下:
public EList<String> getEntityTypes();
出于封装的目的,我希望这个 EList 是不可修改的,因此接口客户端的代码只能通过 add 和 remove 方法修改列表。
是否有任何干净的方法可以做到这一点,即修改 Java 注释或 genmodel 文件以告诉生成器生成返回不可修改列表的代码? (谷歌搜索后我找不到...)
你如何处理这种情况?
提前致谢
手动
【问题讨论】:
标签: java eclipse-emf