code: public void setAttribute(String id, Object obj, boolean save) {
          if (save) {
              String historyAttribute = id + "history";
              Queue<Object> history = (Queue<Object>) getAttribute(historyAttribute);
              if (history == null) {
                  history = new LinkedList<>();
                  setAttribute(historyAttribute, history);
              }
              if (this.getAttribute(id) != null) {
                  history.add(getAttribute(id));
              }
          }
          setAttribute(id, obj);
      }
docs: Set attribute and save previous attribute value
  
  @param id
  attribute name
  @param obj
  value
  @param save
  save previous attribute value to restore later