    001/*
    002 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
    003 *
    004 * Project and contact information: http://www.cascading.org/
    005 *
    006 * This file is part of the Cascading project.
    007 *
    008 * Licensed under the Apache License, Version 2.0 (the "License");
    009 * you may not use this file except in compliance with the License.
    010 * You may obtain a copy of the License at
    011 *
    012 *     http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing, software
    015 * distributed under the License is distributed on an "AS IS" BASIS,
    016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    017 * See the License for the specific language governing permissions and
    018 * limitations under the License.
    019 */
    020
    021package cascading.tuple.util;
    022
    023import cascading.tuple.Fields;
    024import cascading.tuple.Tuple;
    025import cascading.tuple.Tuples;
    026
    027/** This class is experimental and for internal use only. */
    028public class TupleViews
    029  {
    030  public static Tuple createComposite( Tuple... tuples )
    031    {
    032    return Tuples.create( new CompositeTupleList( tuples ) );
    033    }
    034
    035  public static Tuple createComposite( Fields... fields )
    036    {
    037    return Tuples.create( new CompositeTupleList( fields ) );
    038    }
    039
    040  public static Tuple createComposite( Fields[] fields, Tuple[] tuples )
    041    {
    042    return Tuples.create( new CompositeTupleList( fields, tuples ) );
    043    }
    044
    045  public static Tuple createNarrow( int[] basePos )
    046    {
    047    return Tuples.create( new NarrowTupleList( basePos ) );
    048    }
    049
    050  public static Tuple createNarrow( int[] basePos, Tuple tuple )
    051    {
    052    return Tuples.create( new NarrowTupleList( basePos, tuple ) );
    053    }
    054
    055  public static Tuple createOverride( Fields base, Fields override )
    056    {
    057    return Tuples.create( new OverrideTupleList( base, override ) );
    058    }
    059
    060  public static Tuple createOverride( Fields base, Tuple baseTuple, Fields override, Tuple overrideTuple )
    061    {
    062    return Tuples.create( new OverrideTupleList( base, baseTuple, override, overrideTuple ) );
    063    }
    064
    065  public static Tuple createOverride( int[] basePos, Tuple baseTuple, int[] overridePos, Tuple overrideTuple )
    066    {
    067    return Tuples.create( new OverrideTupleList( basePos, baseTuple, overridePos, overrideTuple ) );
    068    }
    069
    070  public static Tuple createObjectArray()
    071    {
    072    return Tuples.create( new ObjectArrayList() );
    073    }
    074
    075  public static Tuple createObjectArray( Object... values )
    076    {
    077    return Tuples.create( new ObjectArrayList( values ) );
    078    }
    079
    080  public static <V> Tuple reset( Tuple tuple, V... values )
    081    {
    082    ( (Resettable<V>) Tuple.elements( tuple ) ).reset( values );
    083
    084    return tuple;
    085    }
    086  }