feroult / yawp

Kotlin/Java API framework for Google Appengine
http://yawp.io
MIT License
131 stars 19 forks source link

Create one "save builder" #111

Open danilodeLuca opened 7 years ago

danilodeLuca commented 7 years ago

Create something like Yawp.builder().after(AfterAction).before(BeforeAction).execute();

Why do I need it? I have several logics in my Hook and I don't need to validate all then in some places, but I need to do some validations before and/or after I save it.

class SaveBuilder<T> {

  public void after();
  public void before();
   public void execute(Object object) {
          before()
          Yawp.save(object)
          after()
   }
}
abstract class  BuilderAction<T> {

    public abstract void action(T object);
}

class AfterAction extends BuilderAction<MyClass> {
   @Override
   public void action(MyClass Object) {}
}

class BeforeAction extends BuilderAction<MyClass> {
   @Override
   public void action(MyClass Object) {}
}