org.jboss.dna.connector.federation.merge
Class MergePlan

java.lang.Object
  extended by org.jboss.dna.connector.federation.merge.MergePlan
All Implemented Interfaces:
Serializable, Iterable<Contribution>
Direct Known Subclasses:
FiveContributionMergePlan, FourContributionMergePlan, MultipleContributionMergePlan, OneContributionMergePlan, ThreeContributionMergePlan, TwoContributionMergePlan

@ThreadSafe
public abstract class MergePlan
extends Object
implements Serializable, Iterable<Contribution>

This class represents the details about how information from different sources are merged into a single federated node.

A merge plan basically consists of the individual contribution from each source and the information about how these contributions were merged into the single federated node.

Merge plans are designed to be serializable, as they are persisted on the federated node and deserialized to assist in the management of the federated node.

Author:
Randall Hauch
See Also:
Serialized Form

Method Summary
static MergePlan addContribution(MergePlan plan, Contribution contribution)
           
static MergePlan create(Collection<Contribution> contributions)
           
static MergePlan create(Contribution... contributions)
           
 boolean equals(Object obj)
          
 Property getAnnotation(Name name)
          Get the plan annotation property with the given name.
 int getAnnotationCount()
          Get the number of annotations.
 Set<Name> getAnnotationNames()
          Get the set of annotation names.
 Map<Name,Property> getAnnotations()
          Get a copy of the annotations.
abstract  int getContributionCount()
           
abstract  Contribution getContributionFrom(String sourceName)
          Get the contribution from the source with the supplied name.
 DateTime getExpirationTimeInUtc()
          Get the expiration time (in UTC) that is the earliest time that any of the contributions Contribution.getExpirationTimeInUtc().
 int getRealContributionCount()
          Get the number of contributions that are not placeholders or empty.
 boolean isExpired(DateTime utcTime)
          Determine whether this merge plan has expired given the supplied current time.
abstract  boolean isSource(String sourceName)
          Return whether the named source was consulted for a contribution.
 Property setAnnotation(Property annotation)
          Set the plan annotation property.
 String toString()
          
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

create

public static MergePlan create(Contribution... contributions)

create

public static MergePlan create(Collection<Contribution> contributions)

addContribution

public static MergePlan addContribution(MergePlan plan,
                                        Contribution contribution)

isExpired

public boolean isExpired(DateTime utcTime)
Determine whether this merge plan has expired given the supplied current time. The expiration time is the earliest time that any of the contributions Contribution.getExpirationTimeInUtc().

Parameters:
utcTime - the current time expressed in UTC; may not be null
Returns:
true if at least one contribution has expired, or false otherwise

getExpirationTimeInUtc

public DateTime getExpirationTimeInUtc()
Get the expiration time (in UTC) that is the earliest time that any of the contributions Contribution.getExpirationTimeInUtc().

Returns:
the expiration time in UTC, or null if there is no known expiration time

getContributionFrom

public abstract Contribution getContributionFrom(String sourceName)
Get the contribution from the source with the supplied name. Note that contributions always include sources that contribute information and sources that contribute no information. If a source is not included in this list, its contributions are unknown; that is, it is unknown whether that source does or does not contribute to the node.

Parameters:
sourceName - the name of the source
Returns:
the contribution, or null if the contribution of the source is unknown

isSource

public abstract boolean isSource(String sourceName)
Return whether the named source was consulted for a contribution.

Parameters:
sourceName - the name of the source
Returns:
true if the source has some contribution (even if it is an EmptyContribution)

getContributionCount

public abstract int getContributionCount()

getRealContributionCount

public int getRealContributionCount()
Get the number of contributions that are not placeholders or empty.

Returns:
the number of real contributions

getAnnotation

public Property getAnnotation(Name name)
Get the plan annotation property with the given name. Plan annotations are custom properties that may be set by MergeProcessor implementations to store custom properties on the plan. This method does nothing if the supplied name is null

Parameters:
name - the name of the annotation
Returns:
the existing annotation, or null if there is no annotation with the supplied name
See Also:
setAnnotation(Property)

setAnnotation

public Property setAnnotation(Property annotation)
Set the plan annotation property. This method replaces and returns any existing annotation property with the same name. This method also returns immediately if the supplied annotation is null.

Parameters:
annotation - the new annotation
Returns:
the previous annotation property with the same name, or null if there was no previous annotation property for the name
See Also:
getAnnotation(Name)

getAnnotationCount

public int getAnnotationCount()
Get the number of annotations.

Returns:
the number of annotations

getAnnotationNames

public Set<Name> getAnnotationNames()
Get the set of annotation names.

Returns:
the unmodifiable set of names, or an empty set if there are no annotations

getAnnotations

public Map<Name,Property> getAnnotations()
Get a copy of the annotations.

Returns:
a copy of annotations; never null

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.