mardi 21 avril 2015

How to avoid writing many wrappers for identical library methods that do not implement a common interface?

I am working with the AWS SDK for Java, which has a large number of classes that contain common methods, however the common methods do not implement a common interface (or extend from a common base class, etc.)

For instance, I have to write this pattern very frequently:

while(true) {
  InformationResult result = client.getInformation(new InformationRequest());
  CustomData data = result.getData(); 
  // do stuff
  if ! result.isTruncated() {
   break;
  }
}

I would like to only write this pattern once, however there are many CustomData and InformationResult classes with no polymorphic relation.

Ideas? I'd like not to wrap all the classes myself.




Aucun commentaire:

Enregistrer un commentaire