Package lombok

Examples of lombok.val


    if (!textStream.markSupported())
      throw new IllegalArgumentException("Peeking is not possible because mark()/reset() are not supported!");

    textStream.mark(1);

    val ch = textStream.read();

    textStream.reset();

    if (ch < 0)
      throw new IOException(String.format(EOF_EXCEPTION_MESSAGE_CHARACTERS, 1));
View Full Code Here


   */
  public static void busySpin(final int value, final TimeUnit unit)
  {
    if (value >= 0)
    {
      val sw = Stopwatch.startNew();
      switch(unit)
      {
        case DAYS:
          while (sw.getElapsedSeconds() < value * 3600 * 24);
          break;
        case HOURS:
          while (sw.getElapsedSeconds() < value * 3600);
          break;
        case MINUTES:
          while (sw.getElapsedSeconds() < value * 60);
          break;
        case SECONDS:
          while (sw.getElapsedSeconds() < value);
          break;
        case MILLISECONDS:
          while (sw.getElapsedMillis() < value);
          break;
        case MICROSECONDS:
          while (sw.getElapsedMicros() < value);
          break;
        case NANOSECONDS:
          while (sw.getElapsedNanos() < value);
          break;
        default:
          throw new IllegalStateException("Unrecognised time unit: " + unit);
      }
    }
View Full Code Here

   */
  public static void yieldWait(final int value, final TimeUnit unit)
  {
    if (value >= 0)
    {
      val sw = Stopwatch.startNew();
      switch(unit)
      {
        case DAYS:
          while (sw.getElapsedSeconds() < value * 3600 * 24)
            Thread.yield();
          break;
        case HOURS:
          while (sw.getElapsedSeconds() < value * 3600)
            Thread.yield();
          break;
        case MINUTES:
          while (sw.getElapsedSeconds() < value * 60)
            Thread.yield();
          break;
        case SECONDS:
          while (sw.getElapsedSeconds() < value)
            Thread.yield();
          break;
        case MILLISECONDS:
          while (sw.getElapsedMillis() < value)
            Thread.yield();
          break;
        case MICROSECONDS:
          while (sw.getElapsedMicros() < value)
            Thread.yield();
          break;
        case NANOSECONDS:
          while (sw.getElapsedNanos() < value)
            Thread.yield();
          break;
        default:
          throw new IllegalStateException("Unrecognised time unit: " + unit);
      }
View Full Code Here

   * @throws IllegalArgumentException When the run-time type of the resulting array cannot be determined.
   */
  @Validate
  public static <TSource, TResult> TResult[] selectMany(@NotNull final TSource[] values, Function1<TSource, ReifiedList<TResult>> selector)
  {
    val result = new ArrayList<TResult>(DEFAULT_LIST_SIZE);
    Class<?> resultClass = null;

    for (TSource item : values)
    {
      ReifiedList<TResult> subItems = selector.apply(item);
      if (subItems != null)
      {
        for (TResult subItem : subItems)
          result.add(subItem);
        if (resultClass == null)
          resultClass = subItems.getGenericTypeParameter();
      }
    }

View Full Code Here

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

    for (T item : values)
    {
      if (skipping)
      {
        if (!predicate.apply(item))
        {
          skipping = false;
          result.add(item);
        }
      } else
        result.add(item);
    }

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

   */
  @Validate
  public static XMLGregorianCalendar toXMLGregorianCalendar(@NotNull final LocalDateTime value)
      throws DatatypeConfigurationException
  {
    val gc = new GregorianCalendar(value.getYear(), value.getMonthOfYear() - 1, value.getDayOfMonth(), value.getHourOfDay(),
        value.getMinuteOfHour(), value.getSecondOfMinute());
    gc.set(Calendar.MILLISECOND, value.getMillisOfSecond());

    return DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
  }
View Full Code Here

   * @throws NullPointerException An argument is null.
   */
  @Validate
  public static String toBinary(@NotNull final byte[] bytes)
  {
    val sb = new StringBuilder(bytes.length * 8);
    for (byte b : bytes)
      sb.append(toBinary(b, true));

    return sb.toString();
  }
View Full Code Here

   * @throws NullPointerException When an argument is null
   */
  @Validate
  public static <T extends Comparable<T>> List<T> sort(@NotNull final Iterable<T> values)
  {
    val result = new ArrayList<T>(DEFAULT_LIST_SIZE);

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

    Collections.sort(result);
    return result;
  }
View Full Code Here

   * @throws NullPointerException When an argument is null
   */
  @Validate
  public static <T extends Comparable<T>> ReifiedList<T> sort(@NotNull final ReifiedIterable<T> values)
  {
    val result = new ReifiedArrayList<T>(values);
    Collections.sort(result);
    return result;
  }
View Full Code Here

   * @throws NullPointerException When an argument is null
   */
  @Validate
  public static <T> List<T> sort(@NotNull final Iterable<T> values, @NotNull final Comparator<? super T> comparator)
  {
    val result = new ArrayList<T>(DEFAULT_LIST_SIZE);
    for (T item : values)
      result.add(item);

    Collections.sort(result, comparator);

    return result;
  }
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.