Exemplo n.º 1
0
  private static Map<String, GraphNode<?>> makeSafeGraphNodeMapCopy(
      Map<String, GraphNode<?>> graphNodeMap) {
    if (graphNodeMap == null) {
      return null;
    }

    final HashMap<String, GraphNode<?>> copy =
        new HashMap<String, GraphNode<?>>(CollectionHelper.determineProperSizing(graphNodeMap));
    for (Map.Entry<String, GraphNode<?>> attributeNodeEntry : graphNodeMap.entrySet()) {
      copy.put(attributeNodeEntry.getKey(), attributeNodeEntry.getValue().makeImmutableCopy());
    }
    return copy;
  }
Exemplo n.º 2
0
  /**
   * Package-protected method to centralize checking of criteria query multi-selects as defined by
   * the {@link CriteriaQuery#multiselect(List)} method.
   *
   * @param selections The selection varargs to check
   * @throws IllegalArgumentException If the selection items are not valid per {@link
   *     CriteriaQuery#multiselect} documentation. <i>&quot;An argument to the multiselect method
   *     must not be a tuple- or array-valued compound selection item.&quot;</i>
   */
  void checkMultiselect(List<Selection<?>> selections) {
    final HashSet<String> aliases =
        new HashSet<String>(CollectionHelper.determineProperSizing(selections.size()));

    for (Selection<?> selection : selections) {
      if (selection.isCompoundSelection()) {
        if (selection.getJavaType().isArray()) {
          throw new IllegalArgumentException(
              "Selection items in a multi-select cannot contain compound array-valued elements");
        }
        if (Tuple.class.isAssignableFrom(selection.getJavaType())) {
          throw new IllegalArgumentException(
              "Selection items in a multi-select cannot contain compound tuple-valued elements");
        }
      }
      if (StringHelper.isNotEmpty(selection.getAlias())) {
        boolean added = aliases.add(selection.getAlias());
        if (!added) {
          throw new IllegalArgumentException(
              "Multi-select expressions defined duplicate alias : " + selection.getAlias());
        }
      }
    }
  }