java契约式设计的问题

Call_Me_CJ 2009-09-21 06:01:48
请问在java中如何实现契约式设计。比如前置条件和后置条件用什么语句可以实现。
我在网上找到得资料如下:
@Invariant( condition="this.capacity > 0 and this.size <= this.capacity" )

public interface Stack {

@Postcondition( condition="return >= 0" )

public int getSize();



@Precondition( bindArgs="arg1=element", condition="!empty element" )

@Postcondition( bindArgs="arg1=element", condition="this.size == old:this.size + 1 and this.top == element" )

public void push( Object elem );



@Postcondition( condition="(this.size > 0) ==> (!empty return)" )

public Object getTop();



public Object pop();

@Precondition(condition="arg1 > 0")

public void setNumber(int number);

}
但是eclipse中总是无法识别@Postconditon之类,是不是要import什么包?
...全文
49 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,549

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧