Java annotations export

Java annotations, take 2!

Sorry again for that oversight on my end. I was so focused on going through the annotation properties (class properties) that I totally forgot about the rest! :blush:

But better late than never, I now have a template which checks the class annotations and then those for the operations and attributes. And even though I’m still a bit unsure about the layout I think it turned out decent enough:

Some important details:

The headers will always show, even if no annotations were found:

image

I did this for consistency. The class annotations are merely a property and you could easily check that beforehand. But the attributes and operations need to be checked individually and you can’t apply programming logic while using a loop. That is: you can check the individual aspects, but not the entire collection.

So to keep the template persistent all headers are printed no matter what.

This was quite an educational experience I must say…

So here is the full template:

<?xml version="1.0" encoding="UTF-8"?>
<ElementBaseInitiationBlock>

	<Text style="@heading+">Overview of Java annotations</Text>
	<ParagraphBreak/>
	<Text style="@heading+">Class annotations</Text>
	<ParagraphBreak/>

	<HasValueChecker property="javaDetail">
		<ModelElementProperty property="javaDetail">
			<HasValueChecker property="annotations">
				<ParagraphBreak/>
				<ForEach property="annotations">
					<Text>@</Text>
					<Property property="name"/>
					<ParagraphBreak/>
					<HasValueChecker property="properties">
						<Text style="@heading+">Definitions:</Text>
						<TableBlock tableStyle="Summaries" tableWidth="80%">
							<TableRow>
								<TableCell>
									<Text>Name</Text>
								</TableCell>
								<TableCell>
									<Text>Value</Text>
								</TableCell>
							</TableRow>
								<ForEach property="properties">
									<TableRow>
										<TableCell>
											<Property property="name"/>		
										</TableCell>
										<TableCell>
											<Property property="value"/>		
										</TableCell>
									</TableRow>
								</ForEach>
						</TableBlock>
						<ParagraphBreak/>
					</HasValueChecker>
				</ForEach>
			</HasValueChecker>
		</ModelElementProperty>
	</HasValueChecker>

	<Text style="@heading+">Attribute annotations</Text>
	<ParagraphBreak />
	
	<HasChildElementChecker modelType="Attribute">
		<IterationBlock modelType="Attribute">
			<ConditionsChecker>
				<Conditions type="and">
					<HasValueChecker property="name"/>
					<ModelElementPropertyConditionChecker property="javaDetail">
						<HasValueChecker property="name"/>
					</ModelElementPropertyConditionChecker>
				</Conditions>
				<Property style="@heading+" property="name"/>
				<ParagraphBreak/>
				<ModelElementProperty property="javaDetail">
					<ForEach property="annotations">
						<Text>@</Text>
						<Property property="name"/>
						<ParagraphBreak/>
						<HasValueChecker property="properties">
							<Text style="@heading+">Definitions:</Text>
							<TableBlock tableStyle="Summaries" tableWidth="80%">
								<TableRow>
									<TableCell>
										<Text>Name</Text>
									</TableCell>
									<TableCell>
										<Text>Value</Text>
									</TableCell>
								</TableRow>
									<ForEach property="properties">
										<TableRow>
											<TableCell>
												<Property property="name"/>		
											</TableCell>
											<TableCell>
												<Property property="value"/>		
											</TableCell>
										</TableRow>
									</ForEach>
							</TableBlock>
							<ParagraphBreak/>
						</HasValueChecker>
					</ForEach>
				</ModelElementProperty>
			</ConditionsChecker>
		</IterationBlock>
	</HasChildElementChecker>

	<Text style="@heading">Operation annotations</Text>
	<ParagraphBreak />

	<HasChildElementChecker modelType="Operation">
		<IterationBlock modelType="Operation">
			<ConditionsChecker>
				<Conditions type="and">
					<HasValueChecker property="name"/>
					<ModelElementPropertyConditionChecker property="javaDetail">
						<HasValueChecker property="name"/>
					</ModelElementPropertyConditionChecker>
				</Conditions>
				<Property style="@heading+" property="name"/>
				<ParagraphBreak/>
				<ModelElementProperty property="javaDetail">
					<ForEach property="annotations">
						<Text>@</Text>
						<Property property="name"/>
						<ParagraphBreak/>
						<HasValueChecker property="properties">
							<Text style="@heading+">Definitions:</Text>
							<TableBlock tableStyle="Summaries" tableWidth="80%">
								<TableRow>
									<TableCell>
										<Text>Name</Text>
									</TableCell>
									<TableCell>
										<Text>Value</Text>
									</TableCell>
								</TableRow>
									<ForEach property="properties">
										<TableRow>
											<TableCell>
												<Property property="name"/>		
											</TableCell>
											<TableCell>
												<Property property="value"/>		
											</TableCell>
										</TableRow>
									</ForEach>
							</TableBlock>
							<ParagraphBreak/>
						</HasValueChecker>
					</ForEach>
				</ModelElementProperty>
			</ConditionsChecker>
		</IterationBlock>
	</HasChildElementChecker>
</ElementBaseInitiationBlock>

Hope this can be more useful than the previous versions :slight_smile: