org.apache.jena.atlas.lib.tuple.TupleN Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jena.atlas.lib.tuple;
import java.util.Arrays ;
/** A Tuple of N items */
public class TupleN extends TupleBase {
private final X[] tuple ;
/** Create a TupleN - safely copy the input */
@SafeVarargs
public static TupleN create(X... xs) {
X[] xs2 = Arrays.copyOf(xs, xs.length) ;
return new TupleN<>(xs2) ;
}
// When the array will not be modified.
/*package*/ static TupleN wrap(X[] xs) {
return new TupleN<>(xs) ;
}
/** Put a TupleN wrapper around a X[].
* The array must not be subsequently modified.
* The statics {@link #create} and {@link wrap} determine whether to copy or not.
*/
protected TupleN(X[] xs) {
tuple = xs ;
}
@Override
public final X get(int i) {
return tuple[i] ;
}
@Override
public int len() {
return tuple.length;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy