org.gcube.contentmanagement.gcubedocumentlibrary.projections
Class BaseProjection<E extends GCubeElement,P extends Property,SELF extends BaseProjection<E,P,SELF>>

java.lang.Object
  extended by org.gcube.contentmanagement.gcubedocumentlibrary.projections.BaseProjection<E,P,SELF>
Type Parameters:
E - the type of GCubeElement.
P - the of Property.
All Implemented Interfaces:
Projection<E,P>
Direct Known Subclasses:
AlternativeProjection, AnnotationProjection, DocumentProjection, MetadataProjection, PartProjection, PropertyProjection

public abstract class BaseProjection<E extends GCubeElement,P extends Property,SELF extends BaseProjection<E,P,SELF>>
extends java.lang.Object
implements Projection<E,P>

Partial implementation of Projection.

Author:
Fabio Simeoni (University of Strathclyde)

Method Summary
 SELF allexcept(P property, P... properties)
          Behaves like etc(), except for one or more properties of this projection.
 java.util.Map<P,Predicate> constraints()
          Returns all the include and filter constraints of the projection.
 boolean equals(java.lang.Object obj)
          
 SELF etc()
          Adds optional include constraints for all the properties of this projection which are not constrained yet.
 int hashCode()
          
 boolean isConstrained(P p)
          Indicates whether a given property has been constrained (include or filter).
 boolean isExcluded(P p)
          Indicates whether a given property has been excluded from retrieval.
 boolean isFiltered(P p)
          Indicates whether a given property has been filtered from retrieval.
 boolean isIncluded(P p)
          Indicates whether a given property has been included for retrieval.
 boolean isOptional(P p)
          Indicates whether a given property has been set as optional.
 TreePredicate predicate()
          Returns a TreePredicate that characterises elements that match the projection.
 java.lang.String toString()
          
 SELF where(P prop, EdgePredicate ep)
          Adds a filter constraint for a property.
 SELF where(P property, P... properties)
          Adds filter constraints for the existence of one or more properties.
 SELF where(P prop, Predicate pred)
          Adds a filter constraint for a property.
 SELF whereValue(P property, java.lang.Object o)
          Adds an filter equivalence constraint for a property based on the Object.toString() representation of an arbitrary object.
 SELF with(P prop, EdgePredicate ep)
          Adds an include constraint for a property.
 SELF with(P property, P... properties)
          Adds include constraints for the existence of one ore more properties.
 SELF with(P property, Predicate p)
          Adds an include constraint for a property.
 SELF withValue(P property, java.lang.Object o)
          Adds an include equivalence constraint for a property based on the Object.toString() representation of an arbitrary object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gcube.contentmanagement.gcubedocumentlibrary.projections.Projection
documentPredicate
 

Method Detail

with

public SELF with(P property,
                 P... properties)
Adds include constraints for the existence of one ore more properties.

Parameters:
the - first property.
properties - the remaining properties.
Returns:
this projection.

withValue

public SELF withValue(P property,
                      java.lang.Object o)
Adds an include equivalence constraint for a property based on the Object.toString() representation of an arbitrary object.

Parameters:
property - the constrained property.
o - the object the property must be equivalent to.
Returns:
this projection.

with

public SELF with(P property,
                 Predicate p)
Adds an include constraint for a property.

Parameters:
property - the constrained property.
p - the constraint.
Returns:
this projection.

with

public SELF with(P prop,
                 EdgePredicate ep)
                                           throws java.lang.IllegalArgumentException
Adds an include constraint for a property.

Parameters:
property - the constrained property.
p - the constraint, as an EdgePredicate.
Returns:
this projection.
Throws:
java.lang.IllegalStateException - if the label of the EdgePredicate does not match the name of the property.
java.lang.IllegalArgumentException

where

public SELF where(P property,
                  P... properties)
Adds filter constraints for the existence of one or more properties.

Parameters:
the - first property.
properties - the remaining properties.
Returns:
this projection.

whereValue

public SELF whereValue(P property,
                       java.lang.Object o)
Adds an filter equivalence constraint for a property based on the Object.toString() representation of an arbitrary object.

Parameters:
property - the constrained property.
o - the object the property must be equivalent to.
Returns:
this projection.

where

public SELF where(P prop,
                  Predicate pred)
Adds a filter constraint for a property.

Parameters:
property - the constrained property.
p - the constraint.
Returns:
this projection.

where

public SELF where(P prop,
                  EdgePredicate ep)
                                            throws java.lang.IllegalArgumentException
Adds a filter constraint for a property.

Parameters:
property - the constrained property.
p - the constraint, as an EdgePredicate.
Returns:
this projection.
Throws:
java.lang.IllegalStateException - if the label of the EdgePredicate does not match the name of the property.
java.lang.IllegalArgumentException

etc

public SELF etc()
Adds optional include constraints for all the properties of this projection which are not constrained yet.

Returns:
this projection

allexcept

public SELF allexcept(P property,
                      P... properties)
Behaves like etc(), except for one or more properties of this projection. For these, it adds optional filter constraints if and only if they are not constrained yet.

Parameters:
properties - the properties.
Returns:
this projection.

isConstrained

public boolean isConstrained(P p)
Indicates whether a given property has been constrained (include or filter).

Parameters:
p - the property.
Returns:
true if the property has been constrained (include or filter).

isFiltered

public boolean isFiltered(P p)
Indicates whether a given property has been filtered from retrieval.

Parameters:
p - the property.
Returns:
true if the property has been filtered.

isIncluded

public boolean isIncluded(P p)
Indicates whether a given property has been included for retrieval.

Parameters:
p - the property.
Returns:
true if the property has been included.

isOptional

public boolean isOptional(P p)
Indicates whether a given property has been set as optional.

Parameters:
p - the property.
Returns:
true if the property has been set as optional.

isExcluded

public boolean isExcluded(P p)
Indicates whether a given property has been excluded from retrieval.

Parameters:
p - the property.
Returns:
true if the property has been ignored.

constraints

public java.util.Map<P,Predicate> constraints()
Returns all the include and filter constraints of the projection.

Specified by:
constraints in interface Projection<E extends GCubeElement,P extends Property>
Returns:
the properties.

predicate

public TreePredicate predicate()
Returns a TreePredicate that characterises elements that match the projection.

This method behaves like Projection.documentPredicate() if the projection is defined over documents. It differs if it is defined over inner elements.

Specified by:
predicate in interface Projection<E extends GCubeElement,P extends Property>
Returns:
the predicate.

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object