Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chess
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felicien IHIRWE
chess
Commits
4a888833
Commit
4a888833
authored
5 years ago
by
Luca Cristoforetti
Browse files
Options
Downloads
Patches
Plain Diff
Add a new method to retrieve classes from package
parent
792a4890
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java
+34
-0
34 additions, 0 deletions
...hess/contracts/profile/chesscontract/util/EntityUtil.java
with
34 additions
and
0 deletions
plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java
+
34
−
0
View file @
4a888833
...
...
@@ -4182,6 +4182,7 @@ public class EntityUtil {
return
null
;
}
@SuppressWarnings
(
"unchecked"
)
public
Collection
<
Enumeration
>
getAllEnumeratives
(
Package
packageElement
)
throws
Exception
{
return
(
Collection
<
Enumeration
>)
EObjectUtil
.
getAllElements
(
UMLPackage
.
eINSTANCE
.
getEnumeration
(),
packageElement
);
...
...
@@ -4197,6 +4198,13 @@ public class EntityUtil {
throw
new
Exception
(
"Element does not exist."
);
}
/**
* Returns all the classes in the model.
* <p> BEWARE: all the classes, not only the classes in the given package
* @param packageElement
* @return
* @throws Exception
*/
public
Collection
<
Class
>
getAllClasses
(
Package
packageElement
)
throws
Exception
{
Collection
<
Class
>
classElements
=
null
;
if
(
packageElement
!=
null
)
{
...
...
@@ -4220,4 +4228,30 @@ public class EntityUtil {
}
return
result
;
}
/**
* Returns the Class elements directly contained in a package.
* @param pkg the Package
* @return the Class children
*/
public
Collection
<
Class
>
getPackageClasses
(
Package
pkg
)
throws
Exception
{
Collection
<
Class
>
classElements
=
null
;
if
(
pkg
!=
null
)
{
Collection
<
Element
>
ownedElements
=
pkg
.
getOwnedElements
();
if
(
ownedElements
!=
null
)
{
classElements
=
getClasses
(
ownedElements
);
}
return
classElements
;
}
throw
new
Exception
(
"Package does not exist."
);
}
private
Collection
<
Class
>
getClasses
(
Collection
<
Element
>
elements
)
{
Collection
<
Class
>
result
=
new
ArrayList
<
Class
>();
for
(
Element
element
:
elements
)
{
if
(
isBlock
(
element
))
result
.
add
((
Class
)
element
);
}
return
result
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment