If

If

Generates a value based on the output of another generator.

Attributes
Name Description Required Min Max Allowed Values
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
Nodes
Name Description Required Min Max Allowed Values
else Content type: Sub-generator
Contains generator node to execute if <else> formula evaluates to FALSE
yes 1 1
if Content type: Java code
The formula to evaluate. Example: (300 * ( generator[1] + 4 ))/ generator[0]. Any number of sub-generator nodes may be specified after the if and before the then element which can be accessed in the formula. If the formula contains characters of the xml structure (like '<', '>', ...), the formula has to be wrapped into '<![CDATA[ ... ]]'.
yes 1 1
then Content type: Sub-generator
Contains generator node to execute if <then> formula evaluates to TRUE
yes 1 1
staticValue here you can specify static values to be available to use. Example: <staticValue>new int{1,2,3,4,5}</staticValue> no 0 1
gen Value Generator for this field no 0
Sub-Attributes
Parent Name Description Required Min Max Allowed Values
staticValue unlockFullAccess Content type: Boolean
Omits complexity restriction. This allows to enter ';' into the if and staticValue elements to be able to enter multiple commands into one line.
Default: true
no 0 1
  • true
  • false
  • 0
  • 1
if unlockFullAccess Content type: Boolean
Omits complexity restriction. This allows to enter ';' into the if and staticValue elements to be able to enter multiple commands into one line.
Default: true
no 0 1
  • true
  • false
  • 0
  • 1

Example

  1. Random Gender

    Generates 'female' or 'male' based on a random number 0 or 1.

    Schema config for Random Gender
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <table name="IF">
        <!-- if tables should scale with -SF command line argument.
             Specify your scaling formula here: -->
        <size>10 * ${SF}</size>
    
        <!--Random Gender-->
          <!--
            Generates 'female' or 'male' based on a random number 0 or 1.
          -->
          <field name="gender" size="" type="VARCHAR">
            <gen_If>
              <!-- sub-generator -->
              <gen_LongNumber>
                <min>0</min>
                <max>1</max>
              </gen_LongNumber>
              <!-- evaluates to true when sub-generator produces 0, false otherwise -->
              <if><![CDATA[((Number) generator[0]).longValue() == 0]]></if>
              <then>
                <gen_StaticValue>
                  <value>female</value>
                </gen_StaticValue>
              </then>
              <else>
                <gen_StaticValue>
                  <value>male</value>
                </gen_StaticValue>
              </else>
            </gen_If>
          </field>
          </table>
    </schema>
    
    Output for Random Gender
    male
    male
    male
    female
    male
    female
    male
    male
    male
    male
2.7-83fb0 | 2020-04-22