This example demonstrates how ModelMapper automatically maps properties from Order to OrderDTO.
978246
static void mapAutomatically() {
    Order order = createOrder();
    ModelMapper modelMapper = new ModelMapper();
    OrderDTO orderDTO = modelMapper.map(order, OrderDTO.class);
    assertOrdersEqual(order, orderDTO);
  }
541357
function mapRelation(rel, modelName, relName) {
    let acceptingParams = Object.assign({}, {
        filter: {
            generated: false,
            type: 'JSON'
        }
    }, connectionArgs);
    types[modelName].meta.fields[relName] = {
        generated: true,
        meta: {
            relation: true,
            connection: true,
            relationType: rel.type,
            isMany: isManyRelation(rel.type),
            embed: rel.embed,
            type: rel.modelTo.modelName,
            args: acceptingParams,
        },
        resolve: (obj, args, context, info) => {

            const ctxOptions = { accessToken: context.req.accessToken }
            const modelId = args && args.id;

            const method = rel.modelTo.sharedClass.findMethodByName('find');
            // TODO: ...
            return new Promise((resolve, reject) => { resolve(true) }).then(() => {
                let params = {};

                _.forEach(acceptingParams, (param, name) => {
                    if (typeof args[name] !== 'undefined' && Object.keys(args[name]).length > 0) {
                        _.merge(params, _.cloneDeep(args[name]));
                    }
                });

                if (isManyRelation(rel.type) === true) {
                    return connectionFromPromisedArray(findRelatedMany(rel, obj, params, context), args, rel.modelTo);
                } else {
                    return findRelatedOne(rel, obj, params, context);
                }

                // let wrap = promisify(model[method.name](...params, ctxOptions));

                // if (typeObj.list) {
                //     return connectionFromPromisedArray(wrap, args, model);
                // } else {
                //     return wrap;
                // }


            }).catch((err) => {
                throw err;
            });
        }
    };
}
917030
def get_first_mapping(cls):
    """"""
    from .models import Indexable

    if issubclass(cls, Indexable) and hasattr(cls, "Mapping"):
        return cls.Mapping
    for base in cls.__bases__:
        mapping = get_first_mapping(base)
        if mapping:
            return mapping
    return None
790826
protected Map<Character, List<Pair<FeaturePattern, FeatureReplacement>>> initMapping() {
		final Map<Character, List<Pair<FeaturePattern, FeatureReplacement>>> map = new TreeMap<>();
		if (!this.ruleReader.initializeConversions(map, this.context) && this.initializer != null) {
			this.initializer.initializeConversions((simpleName, source, target) -> {
				final char c = getKey(simpleName);
				if (c == FeaturePattern.ALL_PATTERN_CHAR) {
					for (int i = 'a'; i <= 'z'; ++i) {
						createMappingEntry(map, (char) i, source, target);
					}
				} else {
					createMappingEntry(map, c, source, target);
				}
			});
		}
		return map;
	}
972909
public static SortedMap<String, Object> asMap(Object bean) {
        if (bean == null) {
            throw new IllegalArgumentException();
        }
        BeanPropertyMapFactory factory = forClass(bean.getClass());
        return factory.createMap(bean);
    }
192952
function dig_dot_layout_orderMap(g, layer) {
  var order = {};
  for (var i = 0; i < layer.length; ++i) {
    order[layer[i]] = i;
  }
  return order;
}
828128
def map_to(klass, **opts)
      with(opts.merge(auto_map: false, auto_struct: true, meta: { model: klass }))
    end
665579
public void addCustomMappings(BuilderContext builderContext) {
        DefinitionRepository definitionRepository = builderContext.getDefinitionRepository();

        List<ClassRef> refs = new ArrayList<ClassRef>();
        for (TypeDef typeDef : builderContext.getDefinitionRepository().getDefinitions()) {
            refs.add(typeDef.toInternalReference());
        }

        //It's best to have predictable order, so that we can generate uniform code.
        Collections.sort(refs, new Comparator<ClassRef>() {
            @Override
            public int compare(ClassRef o1, ClassRef o2) {
                return o1.getFullyQualifiedName().compareTo(o2.getFullyQualifiedName());
            }
        });

        for (ClassRef ref : refs) {
            String key = ref.getName();

            if (BuilderUtils.isBuildable(ref)) {

                //Add the builder
                String builderKey = key + "Builder";
                if (!definitionRepository.customMappingExists(builderKey)) {
                    definitionRepository.putCustomMapping(builderKey, ref.getDefinition().getFullyQualifiedName() + "Builder");
                }

                //Add the editable
                String editableKey = "Editable" + key;
                if (!definitionRepository.customMappingExists(editableKey)) {
                    definitionRepository.putCustomMapping(editableKey, "Editable" + ref.getDefinition().getFullyQualifiedName());
                }

                //Add the builder
                String fluentKey = key + "Fluent";
                if (!definitionRepository.customMappingExists(fluentKey)) {
                    definitionRepository.putCustomMapping(fluentKey, ref.getDefinition().getFullyQualifiedName() + "Fluent");
                }

                //Add the builder
                String fluentImplKey = key + "FluentImpl";
                if (!definitionRepository.customMappingExists(fluentImplKey)) {
                    definitionRepository.putCustomMapping(fluentImplKey, ref.getDefinition().getFullyQualifiedName() + "FluentImpl");
                }
            }
        }
    }
855975
private static JClassType findFirstTypeToApplyPropertyAnnotation( List<JMapperType> mapperTypeList ) {
        if ( mapperTypeList.isEmpty() ) {
            return null;
        }

        List<JMapperType> subLevel = new ArrayList<JMapperType>();
        for ( JMapperType mapperType : mapperTypeList ) {
            if ( mapperType.isBeanMapper() ) {
                return mapperType.getType().isClass();
            } else if ( mapperType.getParameters().size() > 0 ) {
                subLevel.addAll( mapperType.getParameters() );
            }
        }

        return findFirstTypeToApplyPropertyAnnotation( subLevel );
    }
396983
public static Map<String, String> computeModelColumnMappings(Class<?> modelType) {
        return MODEL_COLUMN_MAPPINGS.computeIfAbsent(modelType, model -> {
            List<Field> fields = computeModelFields(model);
            return fields.stream()
                    .collect(toMap(AnimaCache::getColumnName, Field::getName));
        });
    }
1328904
private void init(){
	
		if(!Annotation.isInheritedMapped(configuredClass))
			Error.classNotMapped(configuredClass);
		
		for (Class<?> classe :getClasses()){
			relationalManyToOneMapper.put(classe.getName(), new JMapper(configuredClass, classe,ChooseConfig.DESTINATION));
			relationalOneToManyMapper.put(classe.getName(), new JMapper(classe, configuredClass,ChooseConfig.SOURCE));
		}
	}
551207
public OrderBy buildOrderBy(IAssetType assetType,
                                IAttributeDefinition defaultOrderBy) {
        OrderBy order = new OrderBy();

        if (orderBy.size() > 0) {

            for (String s : orderBy) {
                order.minorSort(assetType
                        .getAttributeDefinition(resolvePropertyName(s)),
                        OrderBy.Order.Ascending);
            }
        } else {
            if (defaultOrderBy != null)
                order.minorSort(defaultOrderBy, OrderBy.Order.Ascending);
        }
        return order;
    }
235025
private static Map<String, ModelDescription> assigneModelsToViews(Map<ModelDescription, 
            XLinkConnectorView[]> modelsToViews) {
        HashMap<String, ModelDescription> viewsToModels = new HashMap<String, ModelDescription>();
        for (ModelDescription modelInfo : modelsToViews.keySet()) {
            List<XLinkConnectorView> currentViewList = Arrays.asList(modelsToViews.get(modelInfo));
            for (XLinkConnectorView view : currentViewList) {
                if (!viewsToModels.containsKey(view.getViewId())) {
                    viewsToModels.put(view.getViewId(), modelInfo);
                }
            }
        }
        return viewsToModels;
    }
1279419
function propertySort(itemsKey, sortPropertiesKey) {
    var cp = new _emberMetalComputed.ComputedProperty(function (key) {
      var _this5 = this;

      var itemsKeyIsAtThis = itemsKey === '@this';
      var sortProperties = _emberMetalProperty_get.get(this, sortPropertiesKey);

      _emberMetalDebug.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) {
        return typeof s === 'string';
      }));

      var normalizedSortProperties = normalizeSortProperties(sortProperties);

      // Add/remove property observers as required.
      var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetalWeak_map.default());
      var activeObservers = activeObserversMap.get(this);

      if (activeObservers) {
        activeObservers.forEach(function (args) {
          _emberMetalObserver.removeObserver.apply(null, args);
        });
      }

      function sortPropertyDidChange() {
        this.notifyPropertyChange(key);
      }

      activeObservers = normalizedSortProperties.map(function (_ref) {
        var prop = _ref[0];

        var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop;
        var args = [_this5, path, sortPropertyDidChange];
        _emberMetalObserver.addObserver.apply(null, args);
        return args;
      });

      activeObserversMap.set(this, activeObservers);

      // Sort and return the array.
      var items = itemsKeyIsAtThis ? this : _emberMetalProperty_get.get(this, itemsKey);

      if (_emberRuntimeUtils.isArray(items)) {
        return sortByNormalizedSortProperties(items, normalizedSortProperties);
      } else {
        return _emberRuntimeSystemNative_array.A();
      }
    });

    cp._activeObserverMap = undefined;

    return cp.property(sortPropertiesKey + '.[]').readOnly();
  }
774344
function mapProperty(model, property, modelName, propertyName, isInputType = false) {

    // If property is deprecated, ignore it.
    if (property.deprecated) {
        return;
    }

    // Bootstrap basic property object
    types[modelName].meta.fields[propertyName] = {
        generated: false,
        meta: {
            required: property.required,
            hidden: model.definition.settings.hidden && model.definition.settings.hidden.indexOf(propertyName) !== -1
        }
    };
    const currentProperty = types[modelName].meta.fields[propertyName];

    const typeName = `${modelName}_${propertyName}`;
    let propertyType = property.type;

    // Add resolver
    currentProperty.resolve = (obj, args, context) => (_.isNil(obj[propertyName]) ? null : obj[propertyName]);

    // If it's an Array type, map it to JSON Scalar
    if (propertyType.name === 'Array') { // JSON Array
        currentProperty.meta.list = true;
        currentProperty.meta.type = 'JSON';
        currentProperty.meta.scalar = true;
        return;
    }

    // If it's an Array type, map it to JSON Scalar
    if (propertyType.name === 'GeoPoint') { // JSON Array
        currentProperty.meta.type = (isInputType) ? 'GeoPointInput' : 'GeoPoint';
        return;
    }

    // If property.type is an array, its a list type.
    if (_.isArray(property.type)) {
        currentProperty.meta.list = true;
        propertyType = property.type[0];
    }

    // See if this property is a scalar.
    let scalar = getScalar(propertyType.name);

    if (property.defaultFn) {
        scalar = getScalar(property.defaultFn);
    }

    if (scalar) {
        currentProperty.meta.scalar = true;
        currentProperty.meta.type = scalar;

        if (property.enum) { // enum has a dedicated type but no input type is required
            types[typeName] = {
                generated: false,
                name: typeName,
                values: property.enum,
                meta: {
                    category: 'ENUM'
                }
            };
            currentProperty.type = typeName;
        }
    }

    // If this property is another Model
    if (propertyType.name === 'ModelConstructor' && property.defaultFn !== 'now') {
        currentProperty.meta.type = (!isInputType) ? propertyType.modelName : `${propertyType.modelName}Input`;
        const union = propertyType.modelName.split('|');

        // type is a union
        if (union.length > 1) { // union type
            types[typeName] = { // creating a new union type
                generated: false,
                name: typeName,
                meta: {
                    category: 'UNION'
                },
                values: toTypes(union)
            };
        } else if (propertyType.settings && propertyType.settings.anonymous && propertyType.definition) {
            currentProperty.meta.type = typeName;
            types[typeName] = {
                generated: false,
                name: typeName,
                meta: {
                    category: 'TYPE',
                    input: isInputType,
                    fields: {}
                }
            }; // creating a new type
            _.forEach(propertyType.definition.properties, (p, key) => {
                mapProperty(propertyType, p, typeName, key, isInputType);
            });
        }
    }
}
1088529
public static List<AnnotationDto> transformToDto(List<Annotation> annotations) {
        if (annotations == null) {
            throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
        }

        List<AnnotationDto> result = new ArrayList<>();

        for (Annotation annotation : annotations) {
            result.add(transformToDto(annotation));
        }
        return result;
    }
589092
SortPropertyOrder convert2SortPropertyOrder(final SortOrder order) {
		switch (order) {
		case ASCENDING:
			return SortPropertyOrder.ASCENDING;
		case DESCENDING:
			return SortPropertyOrder.DESCENDING;
		default:
			throw new IllegalArgumentException("Unknown SortOrder: " + order);
		}
	}