org.nakedobjects.metamodel.specloader.internal
Class OneToManyAssociationImpl

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.OneToManyAssociationImpl
All Implemented Interfaces:
FacetHolder, CurrentHolder, NakedObjectAssociation, NakedObjectFeature, NakedObjectMember, OneToManyAssociation, OneToManyFeature, Identified, NamedAndDescribed, Specification, TypedSpecification

public class OneToManyAssociationImpl
extends NakedObjectAssociationAbstract
implements OneToManyAssociation


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
OneToManyAssociationImpl(NakedObjectAssociationPeer association, RuntimeContext runtimeContext)
           
 
Method Summary
 void addElement(NakedObject ownerAdapter, NakedObject referencedAdapter)
          Add the specified element to this collection field in the specified object.
 void clearCollection(NakedObject ownerAdapter)
          Remove all elements from this collection field in the specified object.
 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<?> createValidateAddInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject ownerAdapter, NakedObject proposedToAddAdapter)
          Creates an InteractionContext that represents validation of a candidate object to be added to the collection.
 ValidityContext<?> createValidateRemoveInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject ownerAdapter, NakedObject proposedToRemoveAdapter)
          Creates an InteractionContext that represents validation of a candidate object to be removed from the collection.
 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 nakedObject)
          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.
 boolean isEmpty(NakedObject parentAdapter)
          Returns true if this field on the specified object is deemed to be empty, or has no content.
 Consent isValidToAdd(NakedObject ownerAdapter, NakedObject proposedToAddAdapter)
          TODO: currently this method is hard-coded to assume all interactions are initiated by user.
 Consent isValidToRemove(NakedObject ownerAdapter, NakedObject proposedToRemoveAdapter)
          TODO: currently this method is hard-coded to assume all interactions are initiated by user.
 void removeAllAssociations(NakedObject ownerAdapter)
           
 void removeElement(NakedObject ownerAdapter, NakedObject referencedAdapter)
          Remove the specified element from this collection field in the specified object.
 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

OneToManyAssociationImpl

public OneToManyAssociationImpl(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:

createValidateAddInteractionContext

public ValidityContext<?> createValidateAddInteractionContext(AuthenticationSession session,
                                                              InteractionInvocationMethod invocationMethod,
                                                              NakedObject ownerAdapter,
                                                              NakedObject proposedToAddAdapter)
Description copied from interface: OneToManyAssociation
Creates an InteractionContext that represents validation of a candidate object to be added to the collection.

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

Specified by:
createValidateAddInteractionContext in interface OneToManyAssociation

isValidToAdd

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

Specified by:
isValidToAdd in interface OneToManyAssociation
See Also:
#isValidToAddResult(NakedObject, NakedObject)

createValidateRemoveInteractionContext

public ValidityContext<?> createValidateRemoveInteractionContext(AuthenticationSession session,
                                                                 InteractionInvocationMethod invocationMethod,
                                                                 NakedObject ownerAdapter,
                                                                 NakedObject proposedToRemoveAdapter)
Description copied from interface: OneToManyAssociation
Creates an InteractionContext that represents validation of a candidate object to be removed from the collection.

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

Specified by:
createValidateRemoveInteractionContext in interface OneToManyAssociation

isValidToRemove

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

Specified by:
isValidToRemove in interface OneToManyAssociation
See Also:
OneToManyAssociation.removeElement(NakedObject, NakedObject), #isValidToAddResult(NakedObject, NakedObject)

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

isEmpty

public boolean isEmpty(NakedObject parentAdapter)
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

addElement

public void addElement(NakedObject ownerAdapter,
                       NakedObject referencedAdapter)
Description copied from interface: OneToManyAssociation
Add the specified element to this collection field in the specified object.

Specified by:
addElement in interface OneToManyAssociation

removeElement

public void removeElement(NakedObject ownerAdapter,
                          NakedObject referencedAdapter)
Description copied from interface: OneToManyAssociation
Remove the specified element from this collection field in the specified object.

Specified by:
removeElement in interface OneToManyAssociation

removeAllAssociations

public void removeAllAssociations(NakedObject ownerAdapter)

clearCollection

public void clearCollection(NakedObject ownerAdapter)
Description copied from interface: OneToManyAssociation
Remove all elements from this collection field in the specified object.

Specified by:
clearCollection in interface OneToManyAssociation

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

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

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

getInstance

public Instance getInstance(NakedObject nakedObject)
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.