code: private static void checkName(final String name, Class<?> type, final Map<String, ?> previousEntries)
              throws IllegalStateException {
          if (StringUtils.isNullOrEmpty(name)) {
              throw new IllegalStateException(type.getSimpleName() + " name cannot be null");
          }
          if (previousEntries.containsKey(name)) {
              throw new IllegalStateException(type.getSimpleName() + " name is not unique: " + name);
          }
      }
docs: Checks if a string is a valid name of a component.
  
  @param name
  the name to be validated
  @param type
  the type of component (used for error messages)
  @param previousEntries
  the previous entries of that component type (for uniqueness
  check)
  @throws IllegalStateException
  if the name is invalid