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.tap; 023 024import java.io.IOException; 025 026import cascading.flow.FlowProcess; 027import cascading.scheme.Scheme; 028import cascading.tuple.Fields; 029import cascading.tuple.TupleEntryIterator; 030 031/** 032 * Class SinkTap is an optional base class for sink only Taps. 033 * <p> 034 * Some {@link cascading.tap.Tap} instances may only be sinks (as opposed 035 * to being a source). These types may subclass SinkTap for convenience or 036 * set {@link #isSource()} to {@code false} in a custom Tap sub-class. 037 */ 038public abstract class SinkTap<Config, Output> extends Tap<Config, Void, Output> 039 { 040 protected SinkTap() 041 { 042 } 043 044 protected SinkTap( Scheme<Config, ?, Output, ?, ?> scheme ) 045 { 046 super( (Scheme<Config, Void, Output, ?, ?>) scheme ); 047 } 048 049 protected SinkTap( Scheme<Config, ?, Output, ?, ?> scheme, SinkMode sinkMode ) 050 { 051 super( (Scheme<Config, Void, Output, ?, ?>) scheme, sinkMode ); 052 } 053 054 @Override 055 public Fields getSourceFields() 056 { 057 throw new UnsupportedOperationException( "unable to source tuple streams via a SinkTap instance" ); 058 } 059 060 @Override 061 public boolean prepareResourceForRead( Config conf ) throws IOException 062 { 063 throw new UnsupportedOperationException( "unable to prepare resource for read via a SinkTap instance" ); 064 } 065 066 @Override 067 public boolean isSource() 068 { 069 return false; 070 } 071 072 @Override 073 public void sourceConfInit( FlowProcess<? extends Config> flowProcess, Config conf ) 074 { 075 throw new UnsupportedOperationException( "unable to source tuple streams via a SinkTap instance" ); 076 } 077 078 @Override 079 public TupleEntryIterator openForRead( FlowProcess<? extends Config> flowProcess, Void input ) throws IOException 080 { 081 throw new UnsupportedOperationException( "unable to open for read via a SinkTap instance" ); 082 } 083 }