objectHasMetaData (metadataKey, metadataValue)
Category |
metadata functions |
Signature |
objectHasMetaData(String metadataKey, String metadataValue) : boolean |
Description |
checks if an object has a certain metadata key with a certain metadata value |
Arguments |
|
Returns |
|
Exceptions |
Error This function raises a No model object in context exception when the context does not contain a model object |
Example |
The following example shows parts of a code instruction that generates a Java class for each object that has metadata createSpecialService with value true. Given the input shown in the input section below CodeComposer will generate this class only for object ExampleObject3 as shown in the output section below. Input 1<java_package xmlns="https://metafactory.io/xsd/v1/java-codeinstruction"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="https://metafactory.io/xsd/v1/java-codeinstruction https://metafactory.io/xsd/v1/java-codeinstruction.xsd"
4 name="${pattern.property.java.package.base}.services.special"
5 path="${pattern.property.java.main.directory}"
6 package="domain_model">
7 <class name="${createSpecialServiceClassName(${object.name})}"
8 foreach="object"
9 condition="${objectHasMetaData(createSpecialService,true)}">
10 </class>
11</java_package>
1<?xml version="1.0" encoding="UTF-8"?>
2<model xmlns="https://metafactory.io/xsd/v1/model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://metafactory.io/xsd/v1/model https://metafactory.io/xsd/v1/model.xsd">
3 <package name="domain_model">
4 <object name="ExampleObject1">
5 <metadata>
6 <createSpecialService></createSpecialService>
7 </metadata>
8 </object>
9 <object name="ExampleObject2">
10 <metadata>
11 <createSpecialService>false</createSpecialService>
12 </metadata>
13 </object>
14 <object name="ExampleObject3">
15 <metadata>
16 <createSpecialService>true</createSpecialService>
17 </metadata>
18 </object>
19 </package>
20</model>
Output 1package io.metafactory.codecomposer_reference.services.special;
2
3public class ExampleObject3SpecialService {
4
5}
|