org.gcube.contentmanagement.contentmanager.stubs.model.predicates
Class Opt

java.lang.Object
  extended by org.gcube.contentmanagement.contentmanager.stubs.model.predicates.EdgePredicate
      extended by org.gcube.contentmanagement.contentmanager.stubs.model.predicates.Opt
All Implemented Interfaces:
java.io.Serializable

public class Opt
extends EdgePredicate

Asserts the existence of at most one edge that has a given label and targets a node that satisfies a given predicate.

Nodes that have more than one edge with the given label or that have a single edge that does not satisfy the predicate fail the assertion.

Author:
Fabio Simeoni (University of Strathclyde)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.contentmanagement.contentmanager.stubs.model.predicates.EdgePredicate
EdgePredicate.Range
 
Constructor Summary
Opt(javax.xml.namespace.QName l, Predicate p)
          Creates an instance for a given label and predicate.
 
Method Summary
 boolean matches(java.util.List<Edge> edges)
          Indicates whether the predicate matches some of the edges in a given list.
 java.util.List<Edge> prune(java.util.List<Edge> edges)
          Returns the edges from a given list which match the predicate.
 EdgePredicate.Range range()
          
 
Methods inherited from class org.gcube.contentmanagement.contentmanager.stubs.model.predicates.EdgePredicate
equals, hashCode, isCondition, label, predicate, setAsCondition, setPredicate, toString, unsetAsCondition
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Opt

public Opt(javax.xml.namespace.QName l,
           Predicate p)
Creates an instance for a given label and predicate.

Parameters:
l - the label.
p - the predicate.
Method Detail

matches

public boolean matches(java.util.List<Edge> edges)
Indicates whether the predicate matches some of the edges in a given list.

Parameters:
edges - the list.
Returns:
true if it does, false otherwise.

prune

public java.util.List<Edge> prune(java.util.List<Edge> edges)
                           throws java.lang.Exception
Returns the edges from a given list which match the predicate.

Parameters:
edges - the list.
Returns:
the matching edges.
Throws:
java.lang.Exception - if an attempt to match an edge fails with an error.

range

public EdgePredicate.Range range()

Specified by:
range in class EdgePredicate