All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.common.Tuple5 Maven / Gradle / Ivy

There is a newer version: 1.7.5
Show newest version
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

package io.vlingo.common;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

public class Tuple5 {
  public final A _1;
  public final B _2;
  public final C _3;
  public final D _4;
  public final E _5;

  public static  Tuple5 from(final A a, final B b, final C c, final D d, final E e) {
    return new Tuple5(a, b, c, d, e);
  }

  public static  Tuple5 tuple(final A a, final B b, final C c, final D d, final E e) {
    return new Tuple5(a, b, c, d, e);
  }

  @SuppressWarnings("unchecked")
   void forEach(final Consumer consumer) {
    consumer.accept((T) _1);
    consumer.accept((T) _2);
    consumer.accept((T) _3);
    consumer.accept((T) _4);
    consumer.accept((T) _5);
  }

  @SuppressWarnings("unchecked")
   Collection map(final Function function) {
    final List list = new ArrayList<>(5);

    list.add((TB) function.apply((TA) _1));
    list.add((TB) function.apply((TA) _2));
    list.add((TB) function.apply((TA) _3));
    list.add((TB) function.apply((TA) _4));
    list.add((TB) function.apply((TA) _5));

    return list;
  }

  private Tuple5(final A a, final B b, final C c, final D d, final E e) {
    this._1 = a;
    this._2 = b;
    this._3 = c;
    this._4 = d;
    this._5 = e;
  }

  @Override
  public String toString() {
    return "Tuple5 [_1=" + _1 + ", _2=" + _2 + ", _3=" + _3 + ", _4=" + _4 + ", _5=" + _5 + "]";
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy