com.davidbracewell.tuple.NTuple Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mango Show documentation
Show all versions of mango Show documentation
A set of utilities and tools to speed up and ease programming in Java.
package com.davidbracewell.tuple;
import com.davidbracewell.conversion.Cast;
import com.google.common.base.Joiner;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* The type N tuple.
*
* @author David B. Bracewell
*/
@Getter
@Setter
public class NTuple extends Tuple {
private static final long serialVersionUID = 1L;
private final Object[] array;
/**
* Instantiates a new N tuple.
*
* @param other the other
*/
public NTuple(@NonNull Object[] other) {
array = new Object[other.length];
System.arraycopy(other, 0, array, 0, other.length);
}
/**
* Of n tuple.
*
* @param the type parameter
* @param items the items
* @return the n tuple
*/
@SafeVarargs
public static NTuple of(@NonNull T... items) {
return new NTuple(items);
}
/**
* Of n tuple.
*
* @param the type parameter
* @param items the items
* @return the n tuple
*/
public static NTuple of(@NonNull List items) {
return new NTuple(items.toArray());
}
@Override
public NTuple copy() {
return new NTuple(array);
}
@Override
public T get(int i) {
return Cast.as(array[i]);
}
@Override
public Iterator © 2015 - 2025 Weber Informatics LLC | Privacy Policy