private Map<String, EndpointGroupDescription> createStaticEndpointGroupDescriptions(
     EndpointDefinitionsProvider provider) {
   Map<String, EndpointGroupDescription> descs = new HashMap<>();
   for (EndpointGroupDefinition definition : provider.getStaticEndpointGroupDefinitions()) {
     descs.put(definition.getName(), new EndpointGroupDescription(definition));
   }
   return descs;
 }
  /** Adds initial endpoints, if there are some declared. */
  public void addInitialDynamicEndpointDescriptions() {

    for (EndpointDefinition definition :
        endpointDefinitionsProvider.getDynamicEndpointDefinitions()) {
      for (InitialDynamicEndpointDefinition initialDefinition :
          definition.getInitialDynamicEndpointDefinitions()) {
        addDynamicEndpointDescription(
            definition.getIdentifier(),
            initialDefinition.getName(),
            initialDefinition.getDataType(),
            new HashMap<String, String>());
      }
    }
  }
  /**
   * Add a dynamic endpoint to the list of dynamic endpoints.
   *
   * @param endpointId identifier of dynamic {@link EndpointDefinition} to chose as the underlying
   *     {@link EndpointDefinition}
   * @param name name to set
   * @param dataType data type to set
   * @param metaData meta data to set
   * @param identifier identifier of the endpoint
   * @param parentGroup name of parent input group, <code>null</code> for using default group or
   *     none
   * @param checkIfDeclared perform check if dynamic endpoint is declared
   * @return {@link EndpointDescription} object created and added or <code>null</code> if the name
   *     already exists
   * @throws IllegalArgumentException if dynamic endpoint description with given name already exists
   *     or new name is invalid
   */
  public EndpointDescription addDynamicEndpointDescription(
      String endpointId,
      String name,
      DataType dataType,
      Map<String, String> metaData,
      String identifier,
      String parentGroup,
      boolean checkIfDeclared)
      throws IllegalArgumentException {

    if (checkIfDeclared
        && (!isDynamicEndpointDefinitionDeclared(endpointId) || !isValidEndpointName(name))) {
      String message;
      if (!isDynamicEndpointDefinitionDeclared(endpointId)) {
        message = StringUtils.format(NO_DYNAMIC_ENDPOINT_DEFINITION_WITH_ID_S_DECLARED, endpointId);
      } else {
        message = MESSAGE_DESIRED_ENDPOINT_NAME_ALREADY_EXISTS + name;
      }
      throw new IllegalArgumentException(message);
    }

    EndpointDescription desc =
        new EndpointDescription(
            endpointDefinitionsProvider.getDynamicEndpointDefinition(endpointId), identifier);

    desc.setName(name);
    desc.setDynamicEndpointIdentifier(endpointId);
    desc.setDataType(dataType);
    for (String key : metaData.keySet()) {
      desc.setMetaDataValue(key, metaData.get(key));
    }
    if (parentGroup != null) { // default (if there is one) should not be used as explicit
      // parent group is given
      desc.setParentGroupName(parentGroup);
    }
    dynamicEndpointDescriptions.put(name, desc);

    firePropertyChange(
        PROPERTY_ENDPOINT, new EndpointChange(EndpointChange.Type.Added, desc, null));

    return desc;
  }
  /**
   * Adds a dynamic {@link EndpointGroupDescription}.
   *
   * @param endpointGroupId identifier of endpoint blueprint
   * @param name name of the {@link EndpointGroupDescription} to create
   * @param checkIfDeclared <code>true</code> if it should be checked that dynamic {@link
   *     EndpointDefinition} exists, otherwise <code>false</code>
   * @return {@link EndpointGroupDescription} added
   */
  public EndpointGroupDescription addDynamicEndpointGroupDescription(
      String endpointGroupId, String name, boolean checkIfDeclared) {

    if (checkIfDeclared
        && (!isDynamicEndpointGroupDefinitionDeclared(endpointGroupId)
            || !isValidEndpointGroupName(name))) {
      String message;
      if (!isDynamicEndpointGroupDefinitionDeclared(endpointGroupId)) {
        message = "No dynamic endpoint group definition with id '" + endpointGroupId + "' declared";
      } else {
        message = "Desired endpoint group name already exists: " + name;
      }
      throw new IllegalArgumentException(message);
    }
    EndpointGroupDescription desc =
        new EndpointGroupDescription(
            endpointDefinitionsProvider.getDynamicEndpointGroupDefinition(endpointGroupId));
    desc.setName(name);
    desc.setDynamicEndpointIdentifier(endpointGroupId);
    dynamicEndpointGroupDescriptions.put(name, desc);
    return desc;
  }
 private boolean isDynamicEndpointDefinitionDeclared(String endpointId) {
   return endpointDefinitionsProvider.getDynamicEndpointDefinition(endpointId) != null;
 }
 /**
  * @param id identifier of {@link EndpointDefinition} to get
  * @return {@link EndpointDefinition} with given id
  */
 public EndpointDefinition getDynamicEndpointDefinition(String id) {
   return endpointDefinitionsProvider.getDynamicEndpointDefinition(id);
 }
 public Set<EndpointDefinition> getDynamicEndpointDefinitions() {
   return Collections.unmodifiableSet(endpointDefinitionsProvider.getDynamicEndpointDefinitions());
 }
 /**
  * @param name name of {@link EndpointDefinition} to get
  * @return {@link EndpointDefinition} with given name
  */
 public EndpointDefinition getStaticEndpointDefinition(String name) {
   return endpointDefinitionsProvider.getStaticEndpointDefinition(name);
 }