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

com.redis.om.spring.tuple.Triple Maven / Gradle / Ivy

package com.redis.om.spring.tuple;

import com.redis.om.spring.tuple.accessor.FirstAccessor;
import com.redis.om.spring.tuple.accessor.SecondAccessor;
import com.redis.om.spring.tuple.accessor.ThirdAccessor;

public interface Triple extends Tuple {

  E1 getFirst();

  E2 getSecond();

  E3 getThird();

  @Override
  default int size() {
    return 3;
  }

  default Object get(int index) {
    switch (index) {
      case 0:
        return getFirst();
      case 1:
        return getSecond();
      case 2:
        return getThird();
      default:
        throw new IndexOutOfBoundsException(
            String.format("Index %d is outside bounds of tuple of degree %s", index, size()));
    }
  }

  static  FirstAccessor, E1> getFirstGetter() {
    return Triple::getFirst;
  }

  static  SecondAccessor, E2> getSecondGetter() {
    return Triple::getSecond;
  }

  static  ThirdAccessor, E3> getThirdGetter() {
    return Triple::getThird;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy