@Override
  public SettingsModel createAndAddSettingsModel(final ModuleItem<?> moduleItem) {
    SettingsModel sm = getSafeSettingsModelsMap().get(moduleItem.getName());
    if (sm != null) {
      // already exists, do not overwrite.
      return sm;
    }

    sm = createSettingsModel(moduleItem);
    addSettingsModel(moduleItem.getName(), sm);
    return sm;
  }
  @Override
  public SettingsModel createSettingsModel(final ModuleItem<?> moduleItem) {
    SettingsModel sm = getSafeSettingsModelsMap().get(moduleItem.getName());

    final SettingsModelType t = m_typeService.getSettingsModelTypeFor(moduleItem.getType());
    if (t == null) {
      return null;
    }

    sm = t.create(moduleItem.getName(), moduleItem.getMinimumValue());

    return sm;
  }
  @Override
  public Collection<SettingsModel> createAndAddSettingsModels(
      final Iterable<ModuleItem<?>> moduleItems) {
    if (m_settingsModels.get() == null) {
      return createSettingsModels(moduleItems);
    }

    final ArrayList<SettingsModel> settingsModels = new ArrayList<SettingsModel>();

    for (final ModuleItem i : moduleItems) {
      final SettingsModel sm = createAndAddSettingsModel(i);
      m_settingsModels.get().put(i.getName(), sm);
    }

    return settingsModels;
  }
  @SuppressWarnings("unchecked")
  @Override
  public void setValue(final ModuleItem<?> moduleItem, final Object value) {
    final SettingsModel sm = getSafeSettingsModelsMap().get(moduleItem.getName());
    if (sm == null) {
      return;
    }

    final SettingsModelType t = m_typeService.getSettingsModelTypeFor(sm);

    t.setValue(sm, value);
  }
  @Override
  public Object getValue(final ModuleItem<?> moduleItem) {
    final SettingsModel sm = getSafeSettingsModelsMap().get(moduleItem.getName());
    if (sm == null) {
      return null;
    }

    final SettingsModelType t = m_typeService.getSettingsModelTypeFor(sm);
    if (t != null) {
      return t.getValue(sm);
    }

    return null;
  }