public static Resource getResource(EObject object) {
   InsertionAdapter adapter = AdapterUtil.adapt(object, InsertionAdapter.class);
   if (adapter != null) {
     return adapter.getResource();
   }
   if (object != null) return object.eResource();
   return null;
 }
 public Resource getResource() {
   if (resource == null) {
     Resource res = object.eResource();
     if (res != null) return res;
     InsertionAdapter insertionAdapter = AdapterUtil.adapt(object, InsertionAdapter.class);
     if (insertionAdapter != null) return insertionAdapter.getResource();
   }
   return resource;
 }
  public static void executeIfNeeded(EObject value) {
    List<InsertionAdapter> allAdapters = new ArrayList<InsertionAdapter>();

    for (Adapter adapter : value.eAdapters()) {
      if (adapter instanceof InsertionAdapter) {
        allAdapters.add((InsertionAdapter) adapter);
      }
    }
    value.eAdapters().removeAll(allAdapters);
    for (InsertionAdapter adapter : allAdapters) adapter.execute();
  }