pl.edu.agh.cast.model.attributes
Class AttributeMergePolicy

java.lang.Object
  extended by pl.edu.agh.cast.model.attributes.AttributeMergePolicy
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AttributeMergePolicy.MergePolicyAlwaysFirst, AttributeMergePolicy.MergePolicyAlwaysSecond, AttributeMergePolicy.MergePolicyLogicalAnd, AttributeMergePolicy.MergePolicyLogicalOr

public abstract class AttributeMergePolicy
extends java.lang.Object
implements java.io.Serializable

This class represents a policy of merging two values of an Attribute into one. It defines a few basic policies, however custom ones may be defined by extending this class.

Author:
tmilos
See Also:
Serialized Form

Nested Class Summary
static class AttributeMergePolicy.MergePolicyAlwaysFirst
           
static class AttributeMergePolicy.MergePolicyAlwaysSecond
           
static class AttributeMergePolicy.MergePolicyLogicalAnd
           
static class AttributeMergePolicy.MergePolicyLogicalOr
           
 
Field Summary
static AttributeMergePolicy MERGE_POLICY_ALWAYS_FIRST
          A merge policy that always returns the first value.
static AttributeMergePolicy MERGE_POLICY_ALWAYS_SECOND
          A merge policy that always returns the second value.
static AttributeMergePolicy MERGE_POLICY_LOGICAL_AND
          A merge policy that always returns the logical conjunction (AND) of given values.
static AttributeMergePolicy MERGE_POLICY_LOGICAL_OR
          A merge policy that always returns the logical alternative (OR) of given values.
 
Constructor Summary
protected AttributeMergePolicy()
           
 
Method Summary
protected  boolean checkIfBoolean(java.lang.Object firstValue, java.lang.Object secondValue)
          Verifies if two values are of type Boolean.
 boolean equals(java.lang.Object obj)
           
abstract  java.lang.String getId()
           
abstract  java.lang.Object mergeValues(Attribute attribute, java.lang.Object firstValue, java.lang.Object secondValue)
          Merges two Attribute values into one.
static AttributeMergePolicy resolve(java.lang.String id)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MERGE_POLICY_ALWAYS_FIRST

public static final AttributeMergePolicy MERGE_POLICY_ALWAYS_FIRST
A merge policy that always returns the first value.


MERGE_POLICY_ALWAYS_SECOND

public static final AttributeMergePolicy MERGE_POLICY_ALWAYS_SECOND
A merge policy that always returns the second value.


MERGE_POLICY_LOGICAL_AND

public static final AttributeMergePolicy MERGE_POLICY_LOGICAL_AND
A merge policy that always returns the logical conjunction (AND) of given values. It is valid only for two values of type Boolean


MERGE_POLICY_LOGICAL_OR

public static final AttributeMergePolicy MERGE_POLICY_LOGICAL_OR
A merge policy that always returns the logical alternative (OR) of given values. It is valid only for two values of type Boolean

Constructor Detail

AttributeMergePolicy

protected AttributeMergePolicy()
Method Detail

checkIfBoolean

protected boolean checkIfBoolean(java.lang.Object firstValue,
                                 java.lang.Object secondValue)
Verifies if two values are of type Boolean. Helper method.

Parameters:
first -
second -
Returns:
true if types of both values are of type Boolean

getId

public abstract java.lang.String getId()

mergeValues

public abstract java.lang.Object mergeValues(Attribute attribute,
                                             java.lang.Object firstValue,
                                             java.lang.Object secondValue)
Merges two Attribute values into one. It is possible that the returned value will be one of the parameters, or a completely new object.

Parameters:
attribute - Attribute to merge
first - first value
second - second value
Returns:
an AttributeValue that is the result of merging given values according to the policy

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

resolve

public static final AttributeMergePolicy resolve(java.lang.String id)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2007-2008 AGH University of Science and Technology. All Rights Reserved.