001/* 002 * Copyright (c) 2007-2015 Concurrent, 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.operation.aggregator; 022 023import java.beans.ConstructorProperties; 024 025import cascading.operation.Aggregator; 026import cascading.tuple.Fields; 027import cascading.tuple.Tuple; 028import cascading.tuple.TupleEntry; 029 030/** 031 * Class Last is an {@link Aggregator} that returns the last {@link Tuple} encountered. 032 * <p/> 033 * By default, it returns the last Tuple of {@link Fields#ARGS} found. 034 */ 035public class Last extends ExtentBase 036 { 037 /** Selects and returns the last argument Tuple encountered. */ 038 public Last() 039 { 040 super( Fields.ARGS ); 041 } 042 043 /** 044 * Selects and returns the last argument Tuple encountered. 045 * 046 * @param fieldDeclaration of type Fields 047 */ 048 @ConstructorProperties({"fieldDeclaration"}) 049 public Last( Fields fieldDeclaration ) 050 { 051 super( fieldDeclaration.size(), fieldDeclaration ); 052 } 053 054 /** 055 * Selects and returns the last argument Tuple encountered, unless the Tuple 056 * is a member of the set ignoreTuples. 057 * 058 * @param fieldDeclaration of type Fields 059 * @param ignoreTuples of type Tuple... 060 */ 061 @ConstructorProperties({"fieldDeclaration", "ignoreTuples"}) 062 public Last( Fields fieldDeclaration, Tuple... ignoreTuples ) 063 { 064 super( fieldDeclaration, ignoreTuples ); 065 } 066 067 protected void performOperation( Tuple[] context, TupleEntry entry ) 068 { 069 context[ 0 ] = entry.getTupleCopy(); 070 } 071 }