-1

A GeneralPath object contains Shapes and is itself a Shape.

Would this be an example of a class that uses the Composite Pattern?

I am confused by the Composite Pattern condition: "Clients treat a composite object as a primitive object."

Is this use of primitive different from a primitive data type (i.e. int) ?

Jason C
  • 38,729
  • 14
  • 126
  • 182
user3000731
  • 93
  • 2
  • 11

1 Answers1

0

Yes this is an example of that "pattern" (I hate the term "pattern" for more reasons than I can possibly get into in this post).

I presume you're reading from Horstmann. You are confused because "primitive" in that context means something different than "primitive" in the Java context you are comparing it to.

Clients treat a composite object as a primitive object.

In the above context, "primitive" means the root object itself, i.e., in your case, a Shape.

[Java] primitive data type (i.e. int)

In the above context, "primitive" refers to, of course, a Java primitive data type, e.g. int or boolean.

Same word, different context, different meanings.

Jason C
  • 38,729
  • 14
  • 126
  • 182