001 /* 002 * Copyright (c) 2007-2014 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 021 package cascading.tap.partition; 022 023 import java.util.Map; 024 import java.util.Properties; 025 026 import cascading.property.Props; 027 028 /** 029 * Class PartitionTapProps is a fluent helper class to set properties which control the behaviour of the 030 * {@link BasePartitionTap}. 031 */ 032 public class PartitionTapProps extends Props 033 { 034 public static final String FAIL_ON_CLOSE = "cascading.tap.partition.failonclose"; 035 036 /** 037 * Method setFailOnClose(boolean b) controls if the PartitionTap is ignoring all Excpetions, when a TupleEntryCollector 038 * is closed or if it should rethrow the Exception. 039 * 040 * @param properties a Map<Object, Object> 041 * @param failOnClose boolean controlling the close behaviour 042 */ 043 public static void setFailOnClose( Map<Object, Object> properties, boolean failOnClose ) 044 { 045 properties.put( FAIL_ON_CLOSE, Boolean.toString( failOnClose ) ); 046 } 047 048 private boolean failOnClose = false; 049 050 /*** 051 * Constructs a new PartitionTapProps instance. 052 */ 053 public PartitionTapProps() 054 { 055 } 056 057 public static PartitionTapProps partitionTapProps() 058 { 059 return new PartitionTapProps(); 060 } 061 062 @Override 063 protected void addPropertiesTo( Properties properties ) 064 { 065 setFailOnClose( properties, failOnClose ); 066 } 067 068 public boolean isFailOnClose() 069 { 070 return failOnClose; 071 } 072 073 public PartitionTapProps setFailOnClose( boolean failOnClose ) 074 { 075 this.failOnClose = failOnClose; 076 return this; 077 } 078 }