code: public static void replaceUnit(/*String group, String unitName, */ Unit newUnit) {
          String group = newUnit.getGroup().getName(), unitName = newUnit.getName();
          readWriteLock.writeLock().lock();
          try {
              //unitMap
              List<Unit> unitList = unitMap.get(group);
              unitList.removeIf(unitToRemove -> Objects.equals(unitToRemove.getName(), unitName));
              unitList.add(newUnit);
  
              //searchUnitByClassMap
              Map<Class<? extends Unit>, Unit> tmp = new HashMap<>();
              for (Map.Entry<Class<? extends Unit>, Unit> classUnitEntry : searchUnitByClass.entrySet()) {
                  Unit unit = classUnitEntry.getValue();
                  if (unit.getGroup().getName().equals(group) && unit.getName().equals(unitName)) {
                      tmp.put(classUnitEntry.getKey(), newUnit);
                      break;
                  }
              }
              searchUnitByClass.putAll(tmp);
  
              //searchUnitMap
              searchUnitMap.put(Unit.fullName(group, unitName), newUnit);
          } finally {
              readWriteLock.writeLock().unlock();
          }
      }
docs: Dynamically change the unit collections. Currently we use this for aop.