    001/*
    002 * Copyright (c) 2007-2016 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
    021package cascading.flow.planner.iso.expression;
    022
    023import cascading.flow.planner.Scope;
    024
    025/**
    026 * If ScopeExpression is the only edge, the {@link ScopeExpression.Applies} enum will apply,
    027 * otherwise the number of edges on the target graph must match the number of edges in the expression.
    028 */
    029public abstract class ScopeExpression implements Expression<Scope>
    030  {
    031  /**
    032   * Where this expression applies between ANY edge between two nodes.
    033   */
    034  public static final PathScopeExpression ANY = new PathScopeExpression( Applies.Any );
    035  /**
    036   * Where this expression applies between ALL edges between two nodes.
    037   */
    038  public static final PathScopeExpression ALL = new PathScopeExpression( Applies.All );
    039  public static final PathScopeExpression EACH = new PathScopeExpression( Applies.Each ); // unsupported
    040
    041  public enum Applies
    042    {
    043      Any, All, Each
    044    }
    045
    046  protected Applies applies = Applies.Any;
    047
    048  protected ScopeExpression()
    049    {
    050    }
    051
    052  protected ScopeExpression( Applies applies )
    053    {
    054    this.applies = applies;
    055    }
    056
    057  public boolean appliesToAllPaths()
    058    {
    059    return applies == Applies.All;
    060    }
    061
    062  public boolean appliesToAnyPath()
    063    {
    064    return applies == Applies.Any;
    065    }
    066
    067  public boolean appliesToEachPath()
    068    {
    069    return applies == Applies.Each;
    070    }
    071
    072  public boolean acceptsAll()
    073    {
    074    return appliesToAllPaths();
    075    }
    076
    077  public Applies getApplies()
    078    {
    079    return applies;
    080    }
    081  }