    001/*
    002 * Copyright (c) 2007-2017 Xplenty, 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.flow.planner.graph;
    022
    023import java.util.Collection;
    024import java.util.Collections;
    025import java.util.IdentityHashMap;
    026import java.util.List;
    027import java.util.Set;
    028
    029import cascading.flow.FlowElement;
    030import cascading.flow.planner.Scope;
    031import cascading.util.Util;
    032
    033/**
    034 *
    035 */
    036public class DecoratedElementGraph implements ElementGraph
    037  {
    038  ElementGraph decorated;
    039
    040  public DecoratedElementGraph( ElementGraph decorated )
    041    {
    042    this.decorated = decorated;
    043    }
    044
    045  public ElementGraph getDecorated()
    046    {
    047    return decorated;
    048    }
    049
    050  @Override
    051  public ElementGraph copyElementGraph()
    052    {
    053    return decorated.copyElementGraph();
    054    }
    055
    056  @Override
    057  public ElementGraph bindExtents()
    058    {
    059    return decorated.bindExtents();
    060    }
    061
    062  @Override
    063  public void writeDOT( String filename )
    064    {
    065    boolean success = ElementGraphs.printElementGraph( filename, this, null );
    066
    067    if( success )
    068      Util.writePDF( filename );
    069    }
    070
    071  @Override
    072  public int inDegreeOf( FlowElement vertex )
    073    {
    074    return decorated.inDegreeOf( vertex );
    075    }
    076
    077  @Override
    078  public Set<Scope> incomingEdgesOf( FlowElement vertex )
    079    {
    080    return decorated.incomingEdgesOf( vertex );
    081    }
    082
    083  @Override
    084  public int outDegreeOf( FlowElement vertex )
    085    {
    086    return decorated.outDegreeOf( vertex );
    087    }
    088
    089  @Override
    090  public Set<Scope> outgoingEdgesOf( FlowElement vertex )
    091    {
    092    return decorated.outgoingEdgesOf( vertex );
    093    }
    094
    095  @Override
    096  public List<FlowElement> predecessorListOf( FlowElement flowElement )
    097    {
    098    return decorated.predecessorListOf( flowElement );
    099    }
    100
    101  @Override
    102  public List<FlowElement> successorListOf( FlowElement flowElement )
    103    {
    104    return decorated.successorListOf( flowElement );
    105    }
    106
    107  @Override
    108  public Set<Scope> getAllEdges( FlowElement sourceVertex, FlowElement targetVertex )
    109    {
    110    return decorated.getAllEdges( sourceVertex, targetVertex );
    111    }
    112
    113  @Override
    114  public Scope getEdge( FlowElement sourceVertex, FlowElement targetVertex )
    115    {
    116    return decorated.getEdge( sourceVertex, targetVertex );
    117    }
    118
    119  @Override
    120  public Scope addEdge( FlowElement sourceVertex, FlowElement targetVertex )
    121    {
    122    return decorated.addEdge( sourceVertex, targetVertex );
    123    }
    124
    125  @Override
    126  public boolean addEdge( FlowElement sourceVertex, FlowElement targetVertex, Scope scope )
    127    {
    128    return decorated.addEdge( sourceVertex, targetVertex, scope );
    129    }
    130
    131  @Override
    132  public boolean addHeadVertex( FlowElement flowElement )
    133    {
    134    return decorated.addHeadVertex( flowElement );
    135    }
    136
    137  @Override
    138  public boolean addTailVertex( FlowElement flowElement )
    139    {
    140    return decorated.addTailVertex( flowElement );
    141    }
    142
    143  @Override
    144  public boolean addVertex( FlowElement flowElement )
    145    {
    146    return decorated.addVertex( flowElement );
    147    }
    148
    149  @Override
    150  public boolean containsEdge( FlowElement sourceVertex, FlowElement targetVertex )
    151    {
    152    return decorated.containsEdge( sourceVertex, targetVertex );
    153    }
    154
    155  @Override
    156  public boolean containsEdge( Scope scope )
    157    {
    158    return decorated.containsEdge( scope );
    159    }
    160
    161  @Override
    162  public boolean containsVertex( FlowElement flowElement )
    163    {
    164    return decorated.containsVertex( flowElement );
    165    }
    166
    167  @Override
    168  public Set<Scope> edgeSet()
    169    {
    170    return decorated.edgeSet();
    171    }
    172
    173  @Override
    174  public Set<Scope> edgesOf( FlowElement vertex )
    175    {
    176    return decorated.edgesOf( vertex );
    177    }
    178
    179  @Override
    180  public boolean removeAllEdges( Collection<? extends Scope> edges )
    181    {
    182    return decorated.removeAllEdges( edges );
    183    }
    184
    185  @Override
    186  public Set<Scope> removeAllEdges( FlowElement sourceVertex, FlowElement targetVertex )
    187    {
    188    return decorated.removeAllEdges( sourceVertex, targetVertex );
    189    }
    190
    191  @Override
    192  public boolean removeAllVertices( Collection<? extends FlowElement> vertices )
    193    {
    194    return decorated.removeAllVertices( vertices );
    195    }
    196
    197  @Override
    198  public Scope removeEdge( FlowElement sourceVertex, FlowElement targetVertex )
    199    {
    200    return decorated.removeEdge( sourceVertex, targetVertex );
    201    }
    202
    203  @Override
    204  public boolean removeEdge( Scope scope )
    205    {
    206    return decorated.removeEdge( scope );
    207    }
    208
    209  @Override
    210  public boolean removeVertex( FlowElement flowElement )
    211    {
    212    return decorated.removeVertex( flowElement );
    213    }
    214
    215  @Override
    216  public Set<FlowElement> vertexSet()
    217    {
    218    return decorated.vertexSet();
    219    }
    220
    221  @Override
    222  public Set<FlowElement> vertexSetCopy()
    223    {
    224    Set<FlowElement> result = Collections.newSetFromMap( new IdentityHashMap<FlowElement, Boolean>() );
    225
    226    result.addAll( vertexSet() );
    227
    228    return result;
    229    }
    230
    231  @Override
    232  public FlowElement getEdgeSource( Scope scope )
    233    {
    234    return decorated.getEdgeSource( scope );
    235    }
    236
    237  @Override
    238  public FlowElement getEdgeTarget( Scope scope )
    239    {
    240    return decorated.getEdgeTarget( scope );
    241    }
    242
    243  @Override
    244  public boolean equals( Object object )
    245    {
    246    return ElementGraphs.equals( this, (ElementGraph) object );
    247    }
    248
    249  @Override
    250  public int hashCode()
    251    {
    252    int result = decorated.hashCode();
    253    result = 31 * result; // parity with AnnotatedGraph types
    254    return result;
    255    }
    256  }