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
7b84cb30
Commit
7b84cb30
authored
4 years ago
by
Luca Cristoforetti
Browse files
Options
Downloads
Patches
Plain Diff
Add some small utilities to EntityUtil
parent
70f213d2
No related branches found
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
+58
-0
58 additions, 0 deletions
...hess/contracts/profile/chesscontract/util/EntityUtil.java
with
58 additions
and
0 deletions
plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java
+
58
−
0
View file @
7b84cb30
...
...
@@ -3994,6 +3994,14 @@ public class EntityUtil {
return
null
;
}
/**
* Returns the first operation found with the given name.
* <br>
* This is a very trivial method, no additional checks are done.
* @param operationName the name of the Operation
* @param block the owner class
* @return the Operation
*/
public
Operation
getOperation
(
String
operationName
,
Class
block
)
{
return
block
.
getOwnedOperation
(
operationName
,
null
,
null
);
// logger.debug("getOperationType: " + block + " , " + operationName);
...
...
@@ -4007,6 +4015,18 @@ public class EntityUtil {
// return null;
}
/**
* Returns the first property found with the given name.
* <br>
* This is a very trivial method, no additional checks are done.
* @param propertyName the name of the Property
* @param block the owner class
* @return the Property
*/
public
Property
getProperty
(
String
propertyName
,
Class
block
)
{
return
block
.
getOwnedAttribute
(
propertyName
,
null
);
}
public
boolean
isAttribute
(
String
attributeName
,
Class
blockAsClass
)
{
if
(
blockAsClass
!=
null
)
{
Property
umlProperty
=
blockAsClass
.
getOwnedAttribute
(
attributeName
,
null
);
...
...
@@ -4277,5 +4297,43 @@ public class EntityUtil {
return
result
;
}
/**
* Returns true if the visibility of the given element is private.
* @param e the NamedElement
* @return
* @throws Exception in case no visibility is set
*/
public
boolean
isVisibilityPrivate
(
NamedElement
e
)
throws
Exception
{
if
(
e
.
isSetVisibility
())
{
return
(
e
.
getVisibility
()
==
VisibilityKind
.
PRIVATE_LITERAL
);
}
throw
new
Exception
(
"Element does not have any visibility"
);
}
/**
* Returns true if the visibility of the given element is priprotected.
* @param e the NamedElement
* @return
* @throws Exception in case no visibility is set
*/
public
boolean
isVisibilityProtected
(
NamedElement
e
)
throws
Exception
{
if
(
e
.
isSetVisibility
())
{
return
(
e
.
getVisibility
()
==
VisibilityKind
.
PROTECTED_LITERAL
);
}
throw
new
Exception
(
"Element does not have any visibility"
);
}
/**
* Returns true if the visibility of the given element is public.
* @param e the NamedElement
* @return
* @throws Exception in case no visibility is set
*/
public
boolean
isVisibilityPublic
(
NamedElement
e
)
throws
Exception
{
if
(
e
.
isSetVisibility
())
{
return
(
e
.
getVisibility
()
==
VisibilityKind
.
PUBLIC_LITERAL
);
}
throw
new
Exception
(
"Element does not have any visibility"
);
}
}
\ 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