org.nakedobjects.metamodel.specloader.internal
Class OneToOneAssociationImpl

java.lang.Object
  extended by org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
      extended by org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectAssociationAbstract
          extended by org.nakedobjects.metamodel.specloader.internal.OneToOneAssociationImpl
All Implemented Interfaces:
FacetHolder, CurrentHolder, MutableCurrentHolder, NakedObjectAssociation, NakedObjectFeature, NakedObjectMember, OneToOneAssociation, OneToOneFeature, Identified, NamedAndDescribed, Specification, TypedSpecification

public class OneToOneAssociationImpl
extends NakedObjectAssociationAbstract
implements OneToOneAssociation


Nested Class Summary
 
Nested classes/interfaces inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
NakedObjectMemberAbstract.MemberType
 
Field Summary
 
Fields inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
defaultName
 
Constructor Summary
OneToOneAssociationImpl(NakedObjectAssociationPeer association, RuntimeContext runtimeContext)
           
 
Method Summary
 void clearAssociation(NakedObject ownerAdapter)
          Clear this reference field (make it null) in the specified object, and remove any association back-link.
 PropertyAccessContext createAccessInteractionContext(AuthenticationSession session, InteractionInvocationMethod interactionMethod, NakedObject ownerAdapter)
          TODO: currently this method is hard-coded to assume all interactions are initiated by user.
 UsabilityContext<?> createUsableInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject ownerAdapter)
          Create an InteractionContext to represent an attempt to use this member (that is, to check if it is usable or not).
 ValidityContext<?> createValidateInteractionContext(AuthenticationSession session, InteractionInvocationMethod interactionMethod, NakedObject ownerAdapter, NakedObject proposedToReferenceAdapter)
          Creates an InteractionContext that represents validation of a proposed new value for the property.
 VisibilityContext<?> createVisibleInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject ownerAdapter)
          Create an InteractionContext to represent an attempt to view this member (that is, to check if it is visible or not).
 java.lang.String debugData()
           
 NakedObject get(NakedObject ownerAdapter)
          Returns the referenced NakedObject for the owning NakedObject.
 NakedObject[] getChoices(NakedObject ownerAdapter)
          Returns a list of possible references/values for this field, which the user can choose from.
 NakedObject getDefault(NakedObject ownerAdapter)
          Return the default for this property.
 Instance getInstance(NakedObject ownerAdapter)
          Return an Instance of this Specification with respect to the provided NakedObject.
 boolean hasChoices()
          Whether there are any choices provided (eg choicesXxx supporting method) for the association.
 void initAssociation(NakedObject ownerAdapter, NakedObject referencedAdapter)
          Initialise this field in the specified object with the specified reference - this call should only affect the specified object, and not any related objects.
 Consent isAssociationValid(NakedObject ownerAdapter, NakedObject proposedToReferenceAdapter)
          TODO: currently this method is hard-coded to assume all interactions are initiated by user.
 boolean isEmpty(NakedObject ownerAdapter)
          Returns true if this field on the specified object is deemed to be empty, or has no content.
 void set(NakedObject ownerAdapter, NakedObject newReferencedAdapter)
          Updates the referenced NakedObject for the owning NakedObject with the new value provided, or clears the reference if null.
 void setAssociation(NakedObject ownerAdapter, NakedObject newReferencedAdapter)
          Set up the association represented by this field in the specified object with the specified reference - this call sets up the logical state of the object and might affect other objects that share this association (such as back-links or bidirectional association).
 void toDefault(NakedObject ownerAdapter)
          Set the property to it default references/values.
 java.lang.String toString()
           
 
Methods inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectAssociationAbstract
getBusinessKeyName, getSpecification, isMandatory, isNotDerived, isOneToOneAssociation
 
Methods inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
addFacet, addFacet, containsFacet, getAuthenticationSession, getDescription, getFacet, getFacets, getFacetTypes, getHelp, getId, getIdentifier, getName, getRuntimeContext, isAction, isAssociation, isOneToManyAssociation, isUsable, isVisible, removeFacet, removeFacet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.metamodel.spec.feature.NakedObjectAssociation
getBusinessKeyName, isMandatory, isNotDerived
 
Methods inherited from interface org.nakedobjects.metamodel.spec.feature.NakedObjectMember
getHelp, getId, isAction, isAssociation, isOneToManyAssociation, isOneToOneAssociation, isUsable, isVisible
 
Methods inherited from interface org.nakedobjects.metamodel.spec.TypedSpecification
getSpecification
 
Methods inherited from interface org.nakedobjects.metamodel.spec.identifier.Identified
getIdentifier
 
Methods inherited from interface org.nakedobjects.metamodel.facets.FacetHolder
addFacet, addFacet, containsFacet, getFacet, getFacets, getFacetTypes, removeFacet, removeFacet
 
Methods inherited from interface org.nakedobjects.metamodel.spec.NamedAndDescribed
getDescription, getName
 

Constructor Detail

OneToOneAssociationImpl

public OneToOneAssociationImpl(NakedObjectAssociationPeer association,
                               RuntimeContext runtimeContext)
Method Detail

createVisibleInteractionContext

public VisibilityContext<?> createVisibleInteractionContext(AuthenticationSession session,
                                                            InteractionInvocationMethod invocationMethod,
                                                            NakedObject ownerAdapter)
Description copied from interface: NakedObjectMember
Create an InteractionContext to represent an attempt to view this member (that is, to check if it is visible or not).

Typically it is easier to just call NakedObjectMember.isVisible(AuthenticationSession, NakedObject) or #isVisibleResult(AuthenticationSession, NakedObject); this is provided as API for symmetry with interactions (such as AccessContext accesses) have no corresponding vetoing methods.

Specified by:
createVisibleInteractionContext in interface NakedObjectMember
Returns:

createUsableInteractionContext

public UsabilityContext<?> createUsableInteractionContext(AuthenticationSession session,
                                                          InteractionInvocationMethod invocationMethod,
                                                          NakedObject ownerAdapter)
Description copied from interface: NakedObjectMember
Create an InteractionContext to represent an attempt to use this member (that is, to check if it is usable or not).

Typically it is easier to just call NakedObjectMember.isUsable(AuthenticationSession, NakedObject) or #isUsableResult(AuthenticationSession, NakedObject); this is provided as API for symmetry with interactions (such as AccessContext accesses) have no corresponding vetoing methods.

Specified by:
createUsableInteractionContext in interface NakedObjectMember
Returns:

createValidateInteractionContext

public ValidityContext<?> createValidateInteractionContext(AuthenticationSession session,
                                                           InteractionInvocationMethod interactionMethod,
                                                           NakedObject ownerAdapter,
                                                           NakedObject proposedToReferenceAdapter)
Description copied from interface: OneToOneAssociation
Creates an InteractionContext that represents validation of a proposed new value for the property.

Typically it is easier to just call OneToOneAssociation.isAssociationValid(NakedObject, NakedObject) or #isAssociationValidResult(NakedObject, NakedObject); this is provided as API for symmetry with interactions (such as AccessContext accesses) have no corresponding vetoing methods.

Specified by:
createValidateInteractionContext in interface OneToOneAssociation

isAssociationValid

public Consent isAssociationValid(NakedObject ownerAdapter,
                                  NakedObject proposedToReferenceAdapter)
TODO: currently this method is hard-coded to assume all interactions are initiated by user.

Specified by:
isAssociationValid in interface OneToOneAssociation

initAssociation

public void initAssociation(NakedObject ownerAdapter,
                            NakedObject referencedAdapter)
Description copied from interface: OneToOneAssociation
Initialise this field in the specified object with the specified reference - this call should only affect the specified object, and not any related objects. It should also not be distributed. This is strictly for re-initialising the object and not specifying an association, which is only done once.

Specified by:
initAssociation in interface OneToOneAssociation

get

public NakedObject get(NakedObject ownerAdapter)
Description copied from interface: CurrentHolder
Returns the referenced NakedObject for the owning NakedObject.

For example, if this is an OneToOneAssociation, then returns the referenced object.

Specified by:
get in interface CurrentHolder
Specified by:
get in class NakedObjectAssociationAbstract

createAccessInteractionContext

public PropertyAccessContext createAccessInteractionContext(AuthenticationSession session,
                                                            InteractionInvocationMethod interactionMethod,
                                                            NakedObject ownerAdapter)
TODO: currently this method is hard-coded to assume all interactions are initiated by user.

Specified by:
createAccessInteractionContext in interface OneToOneAssociation

isEmpty

public boolean isEmpty(NakedObject ownerAdapter)
Description copied from interface: NakedObjectAssociation
Returns true if this field on the specified object is deemed to be empty, or has no content.

Specified by:
isEmpty in interface NakedObjectAssociation
Specified by:
isEmpty in class NakedObjectAssociationAbstract

set

public void set(NakedObject ownerAdapter,
                NakedObject newReferencedAdapter)
Description copied from interface: MutableCurrentHolder
Updates the referenced NakedObject for the owning NakedObject with the new value provided, or clears the reference if null.

For example, if this is a OneToOneAssociation, then updates the object referenced .

Specified by:
set in interface MutableCurrentHolder
newReferencedAdapter - - the new value, or null

setAssociation

public void setAssociation(NakedObject ownerAdapter,
                           NakedObject newReferencedAdapter)
Description copied from interface: OneToOneAssociation
Set up the association represented by this field in the specified object with the specified reference - this call sets up the logical state of the object and might affect other objects that share this association (such as back-links or bidirectional association). To initialise a recreated object to this logical state the initAssociation method should be used on each of the objects.

Specified by:
setAssociation in interface OneToOneAssociation
See Also:
OneToOneAssociation.initAssociation(NakedObject, NakedObject)

clearAssociation

public void clearAssociation(NakedObject ownerAdapter)
Description copied from interface: OneToOneAssociation
Clear this reference field (make it null) in the specified object, and remove any association back-link.

Specified by:
clearAssociation in interface OneToOneAssociation
See Also:
OneToOneAssociation.setAssociation(NakedObject, NakedObject)

getDefault

public NakedObject getDefault(NakedObject ownerAdapter)
Description copied from interface: NakedObjectAssociation
Return the default for this property.

Specified by:
getDefault in interface NakedObjectAssociation

toDefault

public void toDefault(NakedObject ownerAdapter)
Description copied from interface: NakedObjectAssociation
Set the property to it default references/values.

Specified by:
toDefault in interface NakedObjectAssociation

hasChoices

public boolean hasChoices()
Description copied from interface: NakedObjectAssociation
Whether there are any choices provided (eg choicesXxx supporting method) for the association.

Specified by:
hasChoices in interface NakedObjectAssociation
Overrides:
hasChoices in class NakedObjectAssociationAbstract

getChoices

public NakedObject[] getChoices(NakedObject ownerAdapter)
Description copied from interface: NakedObjectAssociation
Returns a list of possible references/values for this field, which the user can choose from.

Specified by:
getChoices in interface NakedObjectAssociation

getInstance

public Instance getInstance(NakedObject ownerAdapter)
Description copied from interface: Specification
Return an Instance of this Specification with respect to the provided NakedObject.

For example, if the Specification is a OneToOneAssociation, then is an Instance implementation representing the { NakedObject/ OneToOneAssociation } tuple.

Implementations are expected to use a double-dispatch back to the provided NakedObject (passing themselves as a parameter), using NakedObjectMM.getInstance(Specification).

Note: this method may throw an UnsupportedOperationException; see NakedObjectMM.getInstance(Specification) for details.

Specified by:
getInstance in interface Specification

debugData

public java.lang.String debugData()
Specified by:
debugData in interface NakedObjectMember

toString

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


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.