Best way to handle generation of optional values
Hi,
I've a optional field.
StringProperty is a abstract concept that is extended by StringLiteral and StringExpression.
In generator I want the following:
Currently I use $COPY_SRC$ [ "" ], and "mapped node" is customized as
Is it a proper way to handle missing values?
Are there any short-cuts for if (node.maximum.isNull) { return <"">; } ?
I know of pre-processing scripts. However wonder what are the possibilities.
I've a optional field.
Counter concept
concept Counter ... children: start : IntegerProperty[0..1] ... numberFormat : StringProperty[0..1]
StringProperty is a abstract concept that is extended by StringLiteral and StringExpression.
In generator I want the following:
- if numberFormat is set, then generate the value
- if numberFormat is not set, use "" (empty string)
Currently I use $COPY_SRC$ [ "" ], and "mapped node" is customized as
{
if (node.maximum.isNull) { return <"">; }
node.maximum;
}
Is it a proper way to handle missing values?
Are there any short-cuts for if (node.maximum.isNull) { return <"">; } ?
I know of pre-processing scripts. However wonder what are the possibilities.
Please sign in to leave a comment.
I might try implementing $COPY_SRC_DEF$ [ node ] that will basically be rewritten to $IF node.isNotNull$ then { $COPY_SRC#[node] } else { node }
Well, it does look natural to use "wrapped node as is if "mapped node" turned out to be empty, doesn't it?
That's quite a few of $IF$/else <T T> macros. I wish MPS could use "wrapped" node in case context is empty.