[英]UML Representing an anonymous class in class diagram?
如何在UML类图中表示Java匿名类?
Inner (nested) classes are represented in UML with an association adorned with a crossed circle.
内部(嵌套)类以UML表示,其中一个关联装饰有交叉圆。
There are two really anonymous classes in Java First is the non-named inner class. Java中有两个真正的匿名类首先是非命名的内部类。 Such as:
如:
class BGThread<T>{...}
...
class TitleEditDlg{
new BGThread<Props>(cont, true) {
@Override
public Props run() {
...
}
}
}
A citation from UML standard 2.5 (p.149): 来自UML标准2.5的引用(第149页):
The standard notation for an anonymous InstanceSpecification of an unnamed Classifier is an underlined colon (':').
匿名分类器的匿名InstanceSpecification的标准表示法是带下划线的冒号(':')。
So, as for anonymous java class, you should create a class block with only :
as name and connect the container class to it twice - by container relationship and by one-direction arrow without a dot. 因此,对于匿名java类,您应该创建一个仅使用
:
作为名称的类块,并将容器类连接到它两次 - 通过容器关系和单向箭头而不是点。 From the other side, the :
block should connect to the parent class. 另一方面,
:
block应该连接到父类。
According to the same source, an Anonymous Bound Class
, that is the second anonymous class we meet in Java, but often do not notice it, when you use a template/generic class, as in 根据相同的源代码,
Anonymous Bound Class
,即我们在Java中遇到的第二个匿名类,但在使用模板/泛型类时通常不会注意到它,如
class BGThread<T>{...}
...
class TitleEditDlg{
BGThread<String> newThread= new BGThread<String>();
}
can be shown by two ways: 可以通过两种方式显示:
bind
dependency, with substitution on it. bind
依赖,使用替换。 I was looking for a way to represent a JavaScript object literal in a class diagram (I know it doesn't make much sense...)and I found this post. 我正在寻找一种在类图中表示JavaScript对象文字的方法(我知道它没有多大意义......)我找到了这篇文章。
I'd contribute with this link and image. 我会贡献这个链接和图像。 Ciao.
再见。
http://www.uml-diagrams.org/class-diagrams.html http://www.uml-diagrams.org/class-diagrams.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.