Hi there,

I am going through some Swift API feedback and many of the model objects in 
jclouds use a toString() pattern like this:


   @Override

   public String toString() {

      return string().toString();

   }


   protected ToStringHelper string() {

      return toStringHelper(this)

            .add("name", getName())

            .add("uri", getUri())

            .add("etag", getEtag())

            .add("lastModified", getLastModified())

            .add("metadata", getMetadata());

   }


Why do we need another protected method to create the ToStringHelper? Forgive 
my ignorance, but can someone please explain to me why we can’t write the above 
code as:


   @Override

   public String toString() {

      return toStringHelper(this)

            .add("name", getName())

            .add("objectCount", getObjectCount())

            .add("bytesUsed", getBytesUsed())

            .add("anybodyRead", getAnybodyRead().orNull())

            .add("metadata", getMetadata()).toString();

   }


Is it the case of “its always been done that way”? Insight appreciated, thanks! 
;)


/jd

Reply via email to