6

I reversed some Java code to get a uml class diagram using Visual Paradigm. The diagram shows some associations with little black circles on one end, which I never saw before.

Image

It's definitely not a composition and not a containment! Can anybody explain to me, what kind of association this is?

Here's the related code:

public class DataAdapter extends RecyclerView.Adapter<DataAdapter.ViewHolder> {
    public static final String TAG = DataAdapter.class.getSimpleName();

    private static Context mContext;
    private ArrayList<DataClass> mData;
    private static OnItemClickListener<DataClass> mListener;

    public static class ViewHolder extends RecyclerView.ViewHolder {}

    public DataAdapter(Context context, ArrayList<DataClass> data) {}

    public void setOnClickListener(OnItemClickListener listener) {}

    @Override
    public int getItemCount() {}

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {}

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {}
}

public interface OnItemClickListener<T> {
    public void onItemClick(T item);
}
Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
Locdoc01
  • 723
  • 1
  • 5
  • 19
  • do you have getter and setter in your class ? For reverse tool it is hard to differentiate simple association from composition. For that it should deduce the life cycle of the associated class : not easy – granier Dec 12 '17 at 19:02
  • could you publish the whole schema and the java code of your class ? – granier Dec 12 '17 at 19:06
  • @granier See my edit. No, there are no getters or setters involved. – Locdoc01 Dec 13 '17 at 14:53
  • I should mention, that I left some details out. Now you can see the whole thing. – Locdoc01 Dec 13 '17 at 14:55
  • You reverse Tools generates correctly, since mListener is static it should be underline and the cross near DataAdapter not used often; this is a non navigability sign. I see it in the specification only. Since you do not get a getter for mListener, the Arrow could be discussed for me. – granier Dec 13 '17 at 15:19

2 Answers2

9

What you are seeing is the ownership indicator, commonly known as the dot
In this case it indicates that the property at right side of the association is owned by the class on the left side.

From the UML specs v2.5:

Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which for brevity we will term a dot. The dot is to be drawn integral to the graphic path of the line, at the point where it meets the Classifier, inserted between the end of the line and the side of the node representing the Classifier. The diameter of the dot shall not exceed half the height of the aggregation diamond, and shall be larger than the width of the line. This avoids visual confusion with the filled diamond notation while ensuring that it can be distinguished from the line. The dot shows that the model includes a Property of the type represented by the Classifier touched by the dot. This Property is owned by the Classifier at the other end. In such a case it is normal to suppress the Property from the attributes compartment of the owning Classifier.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
  • 3
    Your statement "it indicates that the property at left side of the association is owned by the class on the right side" is confusing, because the property under consideration is represented by the association end where the dot is, which is the right side, so the property is on the right side of the association, and it is onwed by the class on the left side. – Gerd Wagner Dec 12 '17 at 17:12
  • @GerdWagner You are entirely correct, I updated my answer, thanks. – Geert Bellekens Dec 13 '17 at 04:49
  • I'd say "the left class owns an attribute typed with the class at the right side". Which now makes me think of the difference between attribute and property: https://www.uml-diagrams.org/property.html – qwerty_so Dec 13 '17 at 07:13
3

To adorn Geert's correct answer: In former UML versions navigability (an open arrow at either side) was (mis-) used for that purpose. So now that you see a dot it also means you can navigate towards it (because it renders an attribute of the class type it's touching). It is still possible to mix both notations. But it does not make much sense. Personally I'd use (if ever) navigational arrows only in a conceptual phase.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86