Convenience class to extend when decorating a class that extends LoadFunc and implements LoadMetadata.
| 25 | * implements LoadMetadata. |
| 26 | */ |
| 27 | public class LoadFuncMetadataWrapper extends LoadFuncWrapper implements LoadMetadata { |
| 28 | |
| 29 | private LoadMetadata loadMetadata; |
| 30 | |
| 31 | protected LoadFuncMetadataWrapper() { |
| 32 | super(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * The wrapped LoadMetadata object must be set before method calls are made on this object. |
| 37 | * Typically, this is done with via constructor, but often times the wrapped object can |
| 38 | * not be properly initialized until later in the lifecycle of the wrapper object. |
| 39 | * @param loadFunc |
| 40 | */ |
| 41 | protected void setLoadFunc(LoadMetadata loadFunc) { |
| 42 | super.setLoadFunc((LoadFunc)loadFunc); |
| 43 | this.loadMetadata = loadFunc; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public ResourceSchema getSchema(String location, Job job) throws IOException { |
| 48 | return loadMetadata().getSchema(location, job); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public ResourceStatistics getStatistics(String location, Job job) throws IOException { |
| 53 | return loadMetadata().getStatistics(location, job); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public String[] getPartitionKeys(String location, Job job) throws IOException { |
| 58 | return loadMetadata().getPartitionKeys(location, job); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public void setPartitionFilter(Expression partitionFilter) throws IOException { |
| 63 | loadMetadata().setPartitionFilter(partitionFilter); |
| 64 | } |
| 65 | |
| 66 | private LoadMetadata loadMetadata() { |
| 67 | if (this.loadMetadata == null) { |
| 68 | throw new IllegalArgumentException("Method calls can not be made on the " + |
| 69 | "LoadFuncMetadataWrapper object before the wrapped LoadMetadata object has been " |
| 70 | + "set. Failed on method call " + getMethodName(1)); |
| 71 | } |
| 72 | return loadMetadata; |
| 73 | } |
| 74 | |
| 75 | } |
nothing calls this directly
no outgoing calls
no test coverage detected