Skip to content

Commit

Permalink
Add utilities for persons
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoKlare committed Jun 3, 2022
1 parent 3c319f9 commit f784d3a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bundles/edu.kit.ipd.sdq.metamodels.persons/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
Expand Down
6 changes: 6 additions & 0 deletions bundles/edu.kit.ipd.sdq.metamodels.persons/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
Expand All @@ -25,5 +30,6 @@
<nature>org.eclipse.sirius.nature.modelingproject</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Export-Package: edu.kit.ipd.sdq.metamodels.persons,
edu.kit.ipd.sdq.metamodels.persons.impl,
edu.kit.ipd.sdq.metamodels.persons.util
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport
org.eclipse.emf.ecore;visibility:=reexport,
edu.kit.ipd.sdq.activextendannotations,
com.google.guava,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: edu.kit.ipd.sdq.metamodels.persons
4 changes: 3 additions & 1 deletion bundles/edu.kit.ipd.sdq.metamodels.persons/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ bin.includes = .,\
plugin.xml,\
plugin.properties
jars.compile.order = .
source.. = src-gen/
source.. = src-gen/,\
src/,\
xtend-gen/
output.. = target/classes/
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")
}

}

0 comments on commit f784d3a

Please sign in to comment.