/**
   * Selects an appropriate endpoint from a list of indexed endpoints.
   *
   * @param endpoints list of indexed endpoints
   * @return appropriate endpoint from a list of indexed endpoints or null
   */
  protected Endpoint selectIndexedEndpoint(List<IndexedEndpoint> endpoints) {
    List<IndexedEndpoint> endpointsCopy = new ArrayList<IndexedEndpoint>(endpoints);
    Iterator<IndexedEndpoint> endpointItr = endpointsCopy.iterator();
    IndexedEndpoint firstNoDefaultEndpoint = null;
    IndexedEndpoint currentEndpoint;
    while (endpointItr.hasNext()) {
      currentEndpoint = endpointItr.next();

      // endpoint is the default endpoint
      if (currentEndpoint.isDefault() != null) {
        if (currentEndpoint.isDefault()) {
          return currentEndpoint;
        }

        if (firstNoDefaultEndpoint == null) {
          firstNoDefaultEndpoint = currentEndpoint;
        }
      }
    }

    if (firstNoDefaultEndpoint != null) {
      // no endpoint was marked as the default, return first unmarked endpoint
      return firstNoDefaultEndpoint;
    } else {
      if (endpointsCopy.size() > 0) {
        // no endpoint had an index so return the first one
        return endpointsCopy.get(0);
      } else {
        // no endpoints made it through the supported binding filter
        return null;
      }
    }
  }
 /**
  * Checks that Index is non-negative.
  *
  * @param indexedEndpoint
  * @throws ValidationException
  */
 protected void validateIndex(IndexedEndpoint indexedEndpoint) throws ValidationException {
   if (indexedEndpoint.getIndex() < 0) {
     throw new ValidationException("Index must be non-negative");
   }
 }