diff --git a/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java b/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java index 15b236da367f188740e9d9d4f204b91d4ae6db0f..4e7414dcab61221a43bb2b5216fbc24b16e985af 100644 --- a/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java +++ b/plugins/contracts/org.polarsys.chess.contracts.profile/src/org/polarsys/chess/contracts/profile/chesscontract/util/EntityUtil.java @@ -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