Package lombok

Examples of lombok.val


  @Validate
  public static <T, TKey extends Comparable<TKey>, TValue> AvlHashtable<TKey, TValue>
      toAvlHashtable(@NotNull final Iterable<T> values, @NotNull final Function1<T, TKey> keySelector,
                     @NotNull final Function1<T, TValue> valueSelector)
  {
    val result = new AvlHashtable<TKey, TValue>(keySelector.getReturnType(), valueSelector.getReturnType());
    for (T item : values)
      result.add(keySelector.apply(item), valueSelector.apply(item));

    return result;
  }
View Full Code Here


  @Validate
  public static <T, TKey extends Comparable<TKey>, TValue> AvlHashtable<TKey, TValue>
      toAvlHashtable(@NotNull final T[] values, @NotNull final Function1<T, TKey> keySelector,
                     @NotNull final Function1<T, TValue> valueSelector)
  {
    val result = new AvlHashtable<TKey, TValue>(keySelector.getReturnType(), valueSelector.getReturnType());
    val count = values.length;
    for (int i = 0; i < count; i++)
      result.add(keySelector.apply(values[i]), valueSelector.apply(values[i]));

    return result;
  }
View Full Code Here

   * @throws NullPointerException An argument is null.
   */
  @Validate
  public static <T> List<T> toList(@NotNull final Enumeration<? extends T> enumeration)
  {
    val result = new ArrayList<T>();
    while (enumeration.hasMoreElements())
      result.add(enumeration.nextElement());

    return result;
  }
View Full Code Here

   * @throws NullPointerException An argument is null.
   */
  @Validate
  public static <T> ReifiedList<T> toList(@NotNull final Enumeration<T> enumeration, @NotNull final Class<?> genericTypeParameter)
  {
    val result = new ReifiedArrayList<T>(genericTypeParameter);
    while (enumeration.hasMoreElements())
      result.add(enumeration.nextElement());

    return result;
  }
View Full Code Here

   * @throws NullPointerException The values argument is null.
   */
  @Validate
  public static <T> List<T> toList(@NotNull final Iterable<? extends T> values)
  {
    val result = new ArrayList<T>(DEFAULT_LIST_SIZE);
    for (T item : values)
      result.add(item);

    return result;
  }
View Full Code Here

   */
  @Validate
  public static <T, TResult1, TResult2> Iterable<Pair<TResult1, TResult2>>
      unzip(@NotNull final Iterable<T> values, @NotNull final Function1<? super T, Pair<TResult1, TResult2>> func)
  {
    val result = new ArrayList<Pair<TResult1, TResult2>>(DEFAULT_LIST_SIZE);

    for (T item : values)
      result.add(func.apply(item));

    return result;
  }
View Full Code Here

   */
  @Validate
  public static <T, TResult1, TResult2> Pair<TResult1, TResult2>[] unzip(@NotNull final T[] values,
                                                                         @NotNull final Function1<T, Pair<TResult1, TResult2>> func)
  {
    val result = new ReifiedArrayList<Pair<TResult1, TResult2>>(DEFAULT_LIST_SIZE, Pair.class);

    for (T item : values)
      result.add(func.apply(item));

    return result.toArray();
  }
View Full Code Here

   * @throws NullPointerException When an argument is null
   */
  @Validate
  public static <T> T[] where(@NotNull final T[] values, @NotNull final Predicate1<? super T> predicate)
  {
    val result = new ArrayList<T>(DEFAULT_LIST_SIZE);

    for (T element : values)
      if (predicate.apply(element))
        result.add(element);

    return toArray(result, values.getClass().getComponentType());
  }
View Full Code Here

   */
  @Validate
  public static <TFirst, TSecond, TResult> TResult[] zip(@NotNull final TFirst[] first, @NotNull final TSecond[] second,
                                                         @NotNull final Function2<TFirst, TSecond, TResult> function)
  {
    val result = new ArrayList<TResult>(DEFAULT_LIST_SIZE);

    val count = Math.min(first.length, second.length);

    for (int i = 0; i < count; i++)
      result.add(function.apply(first[i], second[i]));

    return toArray(result, function.getReturnType());
View Full Code Here

   * Casts a sequence of values of a certain type to an array of values of another type, throwing an InvalidCastException if any elements
   * are not cast successfully.
   */
  private static <TSource, TDest> void castThrow(TSource[] values, ReifiedList<TDest> list)
  {
    val destinationClass = list.getGenericTypeParameter();
    for (TSource v : values)
    {
      TDest castVal = (TDest) destinationClass.cast(v);
      list.add(castVal);
    }
  }
View Full Code Here

TOP

Related Classes of lombok.val

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.