-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c319f9
commit f784d3a
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...u.kit.ipd.sdq.metamodels.persons/src/edu/kit/ipd/sdq/metamodels/persons/PersonsUtil.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package edu.kit.ipd.sdq.metamodels.persons | ||
|
||
import edu.kit.ipd.sdq.activextendannotations.Utility | ||
|
||
@Utility | ||
class PersonsUtil { | ||
/** Returns the {@linkplain PersonRegister} in which the person is contained. | ||
* | ||
* @param person the person to obtain the {@linkplain PersonRegister} from, must not be <code>null</code> | ||
* @return <code>person.eContainer</code> as PersonRegister, if it actually is one | ||
* @throws UnsupportedOperationException if the container is not a {@linkplain PersonRegister} | ||
*/ | ||
def static PersonRegister getPersonRegister(Person person) { | ||
val container = person.eContainer | ||
|
||
if (container instanceof PersonRegister) { | ||
return container | ||
} | ||
throw new UnsupportedOperationException( | ||
"Cannot retrieve register of a person if it is not its direct container") | ||
} | ||
|
||
} |