class ParseDefaultACLController {

  public ParseACL get() {
    if (defaultACLUsesCurrentUser && defaultACL != null) {
      ParseUser currentUser = ParseUser.getCurrentUser();
      if (currentUser != null) {
        // If the currentUser has changed, generate a new ACL from the defaultACL.
        ParseUser last = lastCurrentUser != null ? lastCurrentUser.get() : null;
        if (last != currentUser) {
          ParseACL newDefaultACLWithCurrentUser = defaultACL.copy();
          newDefaultACLWithCurrentUser.setShared(true);
          newDefaultACLWithCurrentUser.setReadAccess(currentUser, true);
          newDefaultACLWithCurrentUser.setWriteAccess(currentUser, true);
          defaultACLWithCurrentUser = newDefaultACLWithCurrentUser;
          lastCurrentUser = new WeakReference<>(currentUser);
        }
        return defaultACLWithCurrentUser;
      }
    }
    return defaultACL;
  }

}