///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CodelistMapCore"/> class.
        /// </summary>
        /// <param name="codelistMapType">
        /// The codelist map type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException"> Throws SdmxSemmanticException.
        /// </exception>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public CodelistMapCore(CodelistMapType codelistMapType, IStructureSetObject parent)
            : base(codelistMapType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeListMap), parent)
        {
            try
            {
                var source = codelistMapType.GetTypedSource<CodelistReferenceType>();
                this.SourceRef = RefUtil.CreateReference(this, source);
                var target = codelistMapType.GetTypedTarget<CodelistReferenceType>();
                this.TargetRef = RefUtil.CreateReference(this, target);

                foreach (CodeMap codeMap in codelistMapType.ItemAssociation)
                {
                    IItemMap item = new ItemMapCore(codeMap.GetTypedSource<LocalCodeReferenceType>().GetTypedRef<LocalCodeRefType>().id, codeMap.GetTypedTarget<LocalCodeReferenceType>().GetTypedRef<LocalCodeRefType>().id, this);
                    this.AddInternalItem(item);
                }
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The process codelist map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessCodelistMap(StructureSetType structureSetType, IItemSchemeMapObject buildFrom)
        {
            var codelistMap = new CodelistMapType();
            structureSetType.CodelistMap = codelistMap;

            string str0 = buildFrom.Id;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                codelistMap.id = buildFrom.Id;
            }

            IList<ITextTypeWrapper> names = buildFrom.Names;
            if (ObjectUtil.ValidCollection(names))
            {
                codelistMap.Name = this.GetTextType(names);
            }

            IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions;
            if (ObjectUtil.ValidCollection(descriptions))
            {
                codelistMap.Description = this.GetTextType(descriptions);
            }

            if (buildFrom.SourceRef != null)
            {
                if (buildFrom.SourceRef.TargetReference.EnumType == SdmxStructureEnumType.CodeList)
                {
                    var refType = new CodelistRefType();
                    codelistMap.CodelistRef = refType;
                    SetCodelistRefAttributes(refType, buildFrom.SourceRef);
                }
                else if (buildFrom.SourceRef.TargetReference.EnumType == SdmxStructureEnumType.HierarchicalCodelist)
                {
                    var refType0 = new HierarchicalCodelistRefType();
                    codelistMap.HierarchicalCodelistRef = refType0;
                    SetHclRefAttributes(refType0, buildFrom.SourceRef);
                }
            }

            if (buildFrom.TargetRef != null)
            {
                if (buildFrom.TargetRef.TargetReference.EnumType == SdmxStructureEnumType.CodeList)
                {
                    var refType1 = new CodelistRefType();
                    codelistMap.TargetCodelistRef = refType1;
                    SetCodelistRefAttributes(refType1, buildFrom.TargetRef);
                }
                else if (buildFrom.TargetRef.TargetReference.EnumType == SdmxStructureEnumType.HierarchicalCodelist)
                {
                    var refType2 = new HierarchicalCodelistRefType();
                    codelistMap.TargetHierarchicalCodelistRef = refType2;
                    SetHclRefAttributes(refType2, buildFrom.TargetRef);
                }
            }

            IList<IItemMap> itemMapBeans = buildFrom.Items;
            if (ObjectUtil.ValidCollection(itemMapBeans))
            {
                /* foreach */
                foreach (IItemMap itemMapBean in itemMapBeans)
                {
                    var codeMaptype = new CodeMapType();
                    codelistMap.CodeMap.Add(codeMaptype);
                    string value1 = itemMapBean.SourceId;
                    if (!string.IsNullOrWhiteSpace(value1))
                    {
                        codeMaptype.MapCodeRef = itemMapBean.SourceId;
                    }

                    string value = itemMapBean.TargetId;
                    if (!string.IsNullOrWhiteSpace(value))
                    {
                        codeMaptype.MapTargetCodeRef = itemMapBean.TargetId;
                    }
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                codelistMap.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }