Collection 和 Stream 是什么关系
What is the relationship between Collection and Stream
在Java8中有Stream
,可以从Collection
中检索出来,即public default stream<E> Collection.stream()
。所以想用UML来表达Stream
和Collection
之间的关系进行练习。
我认为正确的关系是依赖关系。但我不确定。所以我想知道在UML方面Collection
和Stream
之间的正确关系是什么?如果是这样依赖的原则是什么?
E
的Collection
是一个集合,它提供了stream()
的方法returnsStream
的E
,它使用集合 as source。
所以关系比较复杂:有一个<<create>>
dependency from Collection
to Stream
. But at the same time, there is a potentially navigable association from the Stream
to the Collection
, although this is not visible for the outside world. By the way, you could represent both with a templateable element。
所以理论上你可以有这样的东西:
但是请注意,实际上您应该忽略流和集合之间的关联,因为它对外界不可用。这只有在您对 Java class 库的内部设计感兴趣时才有意义。您最好对 <<create>>
约束发表评论,以通俗易懂的语言解释一个作为另一个的来源。
在Java8中有Stream
,可以从Collection
中检索出来,即public default stream<E> Collection.stream()
。所以想用UML来表达Stream
和Collection
之间的关系进行练习。
我认为正确的关系是依赖关系。但我不确定。所以我想知道在UML方面Collection
和Stream
之间的正确关系是什么?如果是这样依赖的原则是什么?
E
的Collection
是一个集合,它提供了stream()
的方法returnsStream
的E
,它使用集合 as source。
所以关系比较复杂:有一个<<create>>
dependency from Collection
to Stream
. But at the same time, there is a potentially navigable association from the Stream
to the Collection
, although this is not visible for the outside world. By the way, you could represent both with a templateable element。
所以理论上你可以有这样的东西:
但是请注意,实际上您应该忽略流和集合之间的关联,因为它对外界不可用。这只有在您对 Java class 库的内部设计感兴趣时才有意义。您最好对 <<create>>
约束发表评论,以通俗易懂的语言解释一个作为另一个的来源。