001/* 002 * Copyright (c) 2016-2017 Chris K Wensel <chris@wensel.net>. All Rights Reserved. 003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved. 004 * 005 * Project and contact information: http://www.cascading.org/ 006 * 007 * This file is part of the Cascading project. 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package cascading.operation.aggregator; 023 024import java.beans.ConstructorProperties; 025 026import cascading.operation.Aggregator; 027import cascading.tuple.Fields; 028import cascading.tuple.Tuple; 029import cascading.tuple.TupleEntry; 030 031/** 032 * Class Last is an {@link Aggregator} that returns the last {@link Tuple} encountered. 033 * <p> 034 * By default, it returns the last Tuple of {@link Fields#ARGS} found. 035 */ 036public class Last extends ExtentBase 037 { 038 /** Selects and returns the last argument Tuple encountered. */ 039 public Last() 040 { 041 super( Fields.ARGS ); 042 } 043 044 /** 045 * Selects and returns the last argument Tuple encountered. 046 * 047 * @param fieldDeclaration of type Fields 048 */ 049 @ConstructorProperties({"fieldDeclaration"}) 050 public Last( Fields fieldDeclaration ) 051 { 052 super( fieldDeclaration.size(), fieldDeclaration ); 053 } 054 055 /** 056 * Selects and returns the last argument Tuple encountered, unless the Tuple 057 * is a member of the set ignoreTuples. 058 * 059 * @param fieldDeclaration of type Fields 060 * @param ignoreTuples of type Tuple... 061 */ 062 @ConstructorProperties({"fieldDeclaration", "ignoreTuples"}) 063 public Last( Fields fieldDeclaration, Tuple... ignoreTuples ) 064 { 065 super( fieldDeclaration, ignoreTuples ); 066 } 067 068 protected void performOperation( Tuple[] context, TupleEntry entry ) 069 { 070 context[ 0 ] = entry.getTupleCopy(); 071 } 072 }