Skip to content
Snippets Groups Projects
Commit 7b84cb30 authored by Luca Cristoforetti's avatar Luca Cristoforetti
Browse files

Add some small utilities to EntityUtil

parent 70f213d2
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment