platform_dsl_mapping.functions_EnumerationMapping.pure Maven / Gradle / Ivy
// Copyright 2022 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import meta::pure::mapping::*;
import meta::pure::store::*;
function meta::pure::mapping::toDomainValue(_this:meta::pure::mapping::EnumerationMapping[1], sourceValue: Any[1]):Any[1]
{
let enumValueMapping = $_this.enumValueMappings->filter( m | $m.sourceValues->contains($sourceValue) );
assertEquals(1, $enumValueMapping->size(), 'The system can\'t find an enum value from the enum: \''+$_this.enumeration->enumName()+'\' in the enumMapping \''+$_this.name+'\' for the value \''+$sourceValue->toString()+'\'');
$enumValueMapping->toOne().enum;
}
function meta::pure::mapping::toSourceValues(_this:meta::pure::mapping::EnumerationMapping[1], domainValue: Any[1]):Any[*]
{
let enumValueMapping = $_this.enumValueMappings->filter( m | $m.enum == $domainValue );
assertEquals(1, $enumValueMapping->size(), 'The system can\'t find source values in the enumMapping \''+$_this.name+'\' for the enum \''+$_this.enumeration->enumName()+ '.' +$domainValue->toString()+'\'');
$enumValueMapping->toOne().sourceValues;
}