Class ProfileFacadeImpl
- java.lang.Object
-
- org.modelversioning.emfprofile.impl.ProfileFacadeImpl
-
- All Implemented Interfaces:
IProfileFacade
public class ProfileFacadeImpl extends Object implements IProfileFacade
Implements theIProfileFacade
.
-
-
Field Summary
-
Fields inherited from interface org.modelversioning.emfprofile.IProfileFacade
EMF_PROFILE_APPLICATION_FACTORY, EMF_PROFILE_APPLICATION_PACKAGE, EMF_PROFILE_FACTORY, EMF_PROFILE_PACKAGE, PROFILE_APPLICATION_ECLASS, STEREOTYPE_APPLICATION_APPLIED_TO_REFERENCE, STEREOTYPE_APPLICATION_ECLASS
-
-
Constructor Summary
Constructors Constructor Description ProfileFacadeImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNestedEObject(EObject container, EReference eReference, EObject eObject)
Adds an instance of nested object to the reference of the container.protected void
addToResource(EObject eObject)
Adds the specifiedeObject
to the currently setprofileApplicationResource
.StereotypeApplication
apply(Stereotype stereotype, EObject eObject)
Applies the specifiedstereotype
to the specifiedeObject
.StereotypeApplication
apply(Stereotype stereotype, EObject eObject, Extension extension)
Applies the specifiedstereotype
to the specifiedeObject
using the specifiedextension
.StereotypeApplication
apply(StereotypeApplicability stereotypeApplicability, EObject eObject)
Applies the specifiedapplicableStereotype
.protected StereotypeApplication
createStereotypeApplication(Stereotype stereotype)
Creates a new instance of of the specifiedStereotype
.ProfileApplication
findOrCreateProfileApplication(Profile profile)
Finds or creates a profile application for the specifiedprofile
.EList<StereotypeApplicability>
getApplicableStereotypes(EClass eClass)
Returns the list of applicable stereotype for the specified type ineClass
.EList<StereotypeApplicability>
getApplicableStereotypes(EObject eObject)
Returns the list of applicable stereotype for the specifiedeObject
.EList<StereotypeApplication>
getAppliedStereotypes(EObject eObject)
Returns all stereotypes currently applied to the specifiedeObject
(list ofStereotypeApplication
s).protected EList<StereotypeApplication>
getAppliedStereotypes(EObject eObject, Stereotype stereotype)
Returns all stereotypes currently applied to the specifiedeObject
(list ofStereotypeApplication
s) that are of the typestereotype
.EList<Profile>
getLoadedProfiles()
Returns the list of currently loadedProfile
s.Resource
getProfileApplicationResource()
EList<ProfileApplication>
getProfileApplications()
When loading profile application resource, this method is used to get a reference toProfileApplication
EList<StereotypeApplication>
getStereotypeApplications()
Returns allStereotypeApplications
handled by this facade.EList<EStructuralFeature>
getStereotypeFeatures(Stereotype stereotype)
Returns the list ofEStructuralFeature
s that can be set for the specifiedstereotype
.Object
getTaggedValue(EObject stereotypeApplication, EStructuralFeature taggedValue)
Returns the value of the giventaggedValue
of the givenstereotypeApplication
.boolean
isApplicable(Stereotype stereotype, EObject eObject)
Specifies whether thestereotype
is applicable toeObject
.boolean
isApplicable(Stereotype stereotype, EObject eObject, Extension extension)
Specifies whether thestereotype
is applicable toeObject
using the specifiedextension
.void
loadProfile(Profile profile)
Loads the specifiedprofile
.void
loadProfiles(EList<Profile> profiles)
Loads the specifiedprofiles
.void
loadProfiles(Resource resource)
Loads allProfile
s contained by the specifiedresource
.void
makeApplicable(Profile profile)
Turns the specifiedprofile
into an applicable profile.void
removeEObject(EObject eObject)
Removes the specifiedEObject
from managedProfileApplication
void
removeStereotypeApplication(StereotypeApplication stereotypeApplication)
Removes the specifiedStereotypeApplication
.void
save()
Saves the currently set profile application resource.void
setProfileApplicationFileAndInitializeResource(IFile profileApplicationFile, ResourceSet resourceSet)
Sets theIFile
containing the profile application and initializes a resource.void
setProfileApplicationResource(Resource resource)
Sets theResource
containing the profile application.void
setTaggedValue(EObject stereotypeApplication, EStructuralFeature taggedValue, Object newValue)
Sets the value of the giventaggedValue
of thestereotypeApplication
to the new value.void
unload()
Unloads this facade.void
unloadProfile(Profile profile)
Unloads the specifiedprofile
.Diagnostic
validateAll(EObject currentlySelectedEObject)
Validates the entire profile application.
-
-
-
Method Detail
-
makeApplicable
public void makeApplicable(Profile profile)
Turns the specified
profile
into an applicable profile.This method can be called without being initialized by loading a
Profile
of an application.- Specified by:
makeApplicable
in interfaceIProfileFacade
- Parameters:
profile
- to turn into an applicable profile.
-
save
public void save() throws IOException
Saves the currently set profile application resource.- Specified by:
save
in interfaceIProfileFacade
- Throws:
IOException
- if writing to file fails.
-
loadProfile
public void loadProfile(Profile profile)
Loads the specifiedprofile
.- Specified by:
loadProfile
in interfaceIProfileFacade
- Parameters:
profile
- theProfile
to load.
-
unloadProfile
public void unloadProfile(Profile profile)
Unloads the specifiedprofile
.- Specified by:
unloadProfile
in interfaceIProfileFacade
- Parameters:
profile
- theProfile
to unload.
-
loadProfiles
public void loadProfiles(Resource resource)
Loads allProfile
s contained by the specifiedresource
.- Specified by:
loadProfiles
in interfaceIProfileFacade
- Parameters:
resource
- containing the profiles to be loaded.
-
loadProfiles
public void loadProfiles(EList<Profile> profiles)
Loads the specifiedprofiles
.- Specified by:
loadProfiles
in interfaceIProfileFacade
- Parameters:
profiles
- theProfile
s to be loaded.
-
getLoadedProfiles
public EList<Profile> getLoadedProfiles()
Returns the list of currently loadedProfile
s.- Specified by:
getLoadedProfiles
in interfaceIProfileFacade
- Returns:
- the list of currently loaded
Profile
s.
-
setProfileApplicationFileAndInitializeResource
public void setProfileApplicationFileAndInitializeResource(IFile profileApplicationFile, ResourceSet resourceSet) throws IOException
Sets theIFile
containing the profile application and initializes a resource.- Specified by:
setProfileApplicationFileAndInitializeResource
in interfaceIProfileFacade
- Throws:
IOException
- if loading to resource fails.
-
setProfileApplicationResource
public void setProfileApplicationResource(Resource resource) throws IOException
Sets theResource
containing the profile application.- Specified by:
setProfileApplicationResource
in interfaceIProfileFacade
- Parameters:
resource
- which contains a profile application- Throws:
IOException
- if loading to resource fails.
-
getApplicableStereotypes
public EList<StereotypeApplicability> getApplicableStereotypes(EClass eClass)
Returns the list of applicable stereotype for the specified type ineClass
.- Specified by:
getApplicableStereotypes
in interfaceIProfileFacade
- Parameters:
eClass
- to get applicable stereotype for.- Returns:
- the list of applicable
Stereotype
s.
-
getApplicableStereotypes
public EList<StereotypeApplicability> getApplicableStereotypes(EObject eObject)
Returns the list of applicable stereotype for the specifiedeObject
.- Specified by:
getApplicableStereotypes
in interfaceIProfileFacade
- Parameters:
eObject
- to get applicable stereotype for.- Returns:
- the list of applicable
Stereotype
s.
-
isApplicable
public boolean isApplicable(Stereotype stereotype, EObject eObject)
Specifies whether thestereotype
is applicable toeObject
.- Specified by:
isApplicable
in interfaceIProfileFacade
- Parameters:
stereotype
- to check.eObject
- to check.- Returns:
true
if applicable, otherwisefalse
.
-
isApplicable
public boolean isApplicable(Stereotype stereotype, EObject eObject, Extension extension)
Specifies whether thestereotype
is applicable toeObject
using the specifiedextension
.- Specified by:
isApplicable
in interfaceIProfileFacade
- Parameters:
stereotype
- to check.eObject
- to check.extension
- the extension to check.- Returns:
true
if applicable, otherwisefalse
.
-
apply
public StereotypeApplication apply(StereotypeApplicability stereotypeApplicability, EObject eObject)
Applies the specifiedapplicableStereotype
.This method is a convenience method for
IProfileFacade.apply(Stereotype, EObject, Extension)
.- Specified by:
apply
in interfaceIProfileFacade
- Parameters:
stereotypeApplicability
- the applicable stereotype to be applied.eObject
- to apply theapplicableStereotype
to.- Returns:
- the created instance of the
Stereotype
.
-
apply
public StereotypeApplication apply(Stereotype stereotype, EObject eObject)
Applies the specifiedstereotype
to the specifiedeObject
.This method creates a new instance of the specified
Stereotype
and adds it to the currently set profile application resource (cf.#setProfileApplicationResourceAndFile(Resource)
). If no resource is currently set, this method throws anIllegalStateException
.- Specified by:
apply
in interfaceIProfileFacade
- Parameters:
stereotype
- to apply.eObject
- to apply thestereotype
to.- Returns:
- the created instance of the
Stereotype
.
-
apply
public StereotypeApplication apply(Stereotype stereotype, EObject eObject, Extension extension)
Applies the specifiedstereotype
to the specifiedeObject
using the specifiedextension
.This method creates a new instance of the specified
Stereotype
and adds it to the currently set profile application resource (cf.#setProfileApplicationResourceAndFile(Resource)
). If no resource is currently set, this method throws anIllegalStateException
.- Specified by:
apply
in interfaceIProfileFacade
- Parameters:
stereotype
- to apply.eObject
- to apply thestereotype
to.extension
- the extension to be used for applying the stereotype.- Returns:
- the created instance of the
Stereotype
.
-
createStereotypeApplication
protected StereotypeApplication createStereotypeApplication(Stereotype stereotype)
Creates a new instance of of the specifiedStereotype
.The created instance is {
#addToResource(StereotypeApplication)
added} to the currently set resource.- Parameters:
stereotype
- to create instance for.- Returns:
- created instance.
-
findOrCreateProfileApplication
public ProfileApplication findOrCreateProfileApplication(Profile profile)
Finds or creates a profile application for the specifiedprofile
.- Specified by:
findOrCreateProfileApplication
in interfaceIProfileFacade
- Parameters:
profile
- to find or createProfileApplication
for.- Returns:
- found or created
ProfileApplication
.
-
addToResource
protected void addToResource(EObject eObject)
Adds the specifiedeObject
to the currently setprofileApplicationResource
.If currently no
profileApplicationResource
is set, this method throws anIllegalArgumentException
.- Parameters:
eObject
- to be added.- Throws:
IllegalArgumentException
- ifprofileApplicationResource
is notset
.
-
getStereotypeApplications
public EList<StereotypeApplication> getStereotypeApplications()
Returns allStereotypeApplications
handled by this facade.- Specified by:
getStereotypeApplications
in interfaceIProfileFacade
- Returns:
- all
StereotypeApplications
-
getAppliedStereotypes
public EList<StereotypeApplication> getAppliedStereotypes(EObject eObject)
Returns all stereotypes currently applied to the specifiedeObject
(list ofStereotypeApplication
s).- Specified by:
getAppliedStereotypes
in interfaceIProfileFacade
- Parameters:
eObject
- to get applied stereotypes for.- Returns:
- the list of
StereotypeApplication
s.
-
getAppliedStereotypes
protected EList<StereotypeApplication> getAppliedStereotypes(EObject eObject, Stereotype stereotype)
Returns all stereotypes currently applied to the specifiedeObject
(list ofStereotypeApplication
s) that are of the typestereotype
.- Parameters:
stereotype
- the stereotype to filter stereotype applications.eObject
- to get applied stereotypes for.- Returns:
- the list of
StereotypeApplication
s.
-
removeStereotypeApplication
public void removeStereotypeApplication(StereotypeApplication stereotypeApplication)
Removes the specifiedStereotypeApplication
.- Specified by:
removeStereotypeApplication
in interfaceIProfileFacade
- Parameters:
stereotypeApplication
- stereotype application to remove.
-
getStereotypeFeatures
public EList<EStructuralFeature> getStereotypeFeatures(Stereotype stereotype)
Returns the list ofEStructuralFeature
s that can be set for the specifiedstereotype
.- Specified by:
getStereotypeFeatures
in interfaceIProfileFacade
- Parameters:
stereotype
- to getEStructuralFeature
s for.- Returns:
- the list of settable
EStructuralFeature
s.
-
getTaggedValue
public Object getTaggedValue(EObject stereotypeApplication, EStructuralFeature taggedValue)
Returns the value of the giventaggedValue
of the givenstereotypeApplication
.If the tagged value is
many-valued
, the result will be anEList
and each object in the list will bean instance of
the feature'stype
; the list's contents are not affected byresolve
argument. Otherwise the result directly will be an instance of the feature's type; if it is aproxy
, it is resolved.- Specified by:
getTaggedValue
in interfaceIProfileFacade
- Parameters:
stereotypeApplication
- to get feature value for.taggedValue
- the tagged value to fetch.- Returns:
- the value of the given tagged value of the object.
-
setTaggedValue
public void setTaggedValue(EObject stereotypeApplication, EStructuralFeature taggedValue, Object newValue)
Sets the value of the giventaggedValue
of thestereotypeApplication
to the new value.If the feature is
many-valued
, the new value must be anEList
and each object in that list must bean instance of
the feature'stype
; the existing contents are cleared and the contents of the new value are added. However, if the new value is the content list itself, or is modified as a side effect of modifying the content list (i.e., if it is a view on the content list), the behavior is undefined and will likely result in simply clearing the list. If the feature is single-valued, the new value directly must be an instance of the feature's type and it becomes the new value of the feature of the object. If the feature isunsettable
, the modeled state becomes set; otherwise, the feature may still not consideredset
if the new value is the same as the default.- Specified by:
setTaggedValue
in interfaceIProfileFacade
- Parameters:
stereotypeApplication
- to set feature value.taggedValue
- the tagged value to set.newValue
- the value to set.
-
unload
public void unload()
Unloads this facade.- Specified by:
unload
in interfaceIProfileFacade
-
validateAll
public Diagnostic validateAll(EObject currentlySelectedEObject)
Validates the entire profile application.- Specified by:
validateAll
in interfaceIProfileFacade
- Parameters:
currentlySelectedEObject
- currently selected object. This is used for obtaining the annotated model in case no stereotype application has been created yet.- Returns:
- the validation result.
-
getProfileApplicationResource
public Resource getProfileApplicationResource()
- Specified by:
getProfileApplicationResource
in interfaceIProfileFacade
-
getProfileApplications
public EList<ProfileApplication> getProfileApplications()
Description copied from interface:IProfileFacade
When loading profile application resource, this method is used to get a reference toProfileApplication
- Specified by:
getProfileApplications
in interfaceIProfileFacade
- Returns:
-
removeEObject
public void removeEObject(EObject eObject)
Description copied from interface:IProfileFacade
Removes the specifiedEObject
from managedProfileApplication
- Specified by:
removeEObject
in interfaceIProfileFacade
-
addNestedEObject
public void addNestedEObject(EObject container, EReference eReference, EObject eObject)
Description copied from interface:IProfileFacade
Adds an instance of nested object to the reference of the container.- Specified by:
addNestedEObject
in interfaceIProfileFacade
-
-