Examples of APath


Examples of com.ajjpj.amapper.core.path.APath

        final List<Object> mappedTargetList = new ArrayList<> ();
        for (Object sourceEl: worker.getHelpers ().asJuCollection (source, types.source ())) {
            final Object sourceIdent = worker.getIdentifierExtractor ().uniqueIdentifier (sourceEl, sourceElementType, targetElementType);

            final APath elPath = path.withElementChild (sourceIdent);
            final AOption<Object> mappedOpt = worker.map (elPath, sourceEl, targetValuesByIdentifier.get (sourceIdent), elTypes, context);
            if (mappedOpt.isDefined ()) {
                mappedTargetList.add (mappedOpt.get ());
            }
        }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final AQualifiedSourceAndTargetType elementTypes = AQualifiedSourceAndTargetType.create (h.elementType (types.source()), h.elementType(types.target()));

        if(targetColl.isEmpty()) {
            // this is an optimization for the common case that the target collection is initially empty
            for(Object s: sourceColl) {
                final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (s, types.source (), types.target ()));

                final AOption<Object> optT = worker.map(elPath, s, null, elementTypes, context);
                if(optT.isDefined()) {
                    targetColl.add(optT.get());
                }
            }
            return h.fromJuCollection(targetColl, types.target());
        }

        final Equiv equiv = new Equiv(sourceColl, targetColl, types, worker.getIdentifierExtractor());

        // now apply the changes to the target collection
        targetColl.removeAll(equiv.targetWithoutSource);
        for (Object s: equiv.sourceWithoutTarget) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (s, types.source (), types.target ()));
            final AOption<Object> tc = worker.map(elPath, s, null, elementTypes, context);
            if(tc.isDefined()) {
                targetColl.add(tc.get());
            }
        }
        for (Map.Entry<Object, Object> e: equiv.equiv.entrySet()) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (e.getKey(), types.source (), types.target ()));
            final AOption<Object> tc = worker.map(elPath, e.getKey(), e.getValue(), elementTypes, context);

            if(tc.isEmpty()) {
                targetColl.remove(e.getValue());
            }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final Equiv equiv = new Equiv(sourceOldColl, sourceNewColl, sourceTypes, worker.getIdentifierExtractor());

        // elements present in both old and new collection: no difference as far as the collection is concerned, recursive diff
        for(Map.Entry<Object,Object> e: equiv.equiv.entrySet()) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier(e.getKey(), elementTypes.source (), elementTypes.target ()));
            worker.diff(elPath, e.getKey(), e.getValue(), elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the new collection: 'added' diff element + recursive diff with 'derived' = true
        for(Object newEl: equiv.targetWithoutSource) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (newEl, elementTypes.target (), elementTypes.target ()));
            worker.diff(elPath, null, newEl, elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the old collection: 'removed' diff element + recursive diff with 'derived' = true
        for(Object oldEl: equiv.sourceWithoutTarget) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier(oldEl, elementTypes.source (), elementTypes.target ()));
            worker.diff(elPath, oldEl, null, elementTypes, contextOld, contextNew, isDerived);
        }
    }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final Equiv equiv = new Equiv(sourceOldColl, sourceNewColl, sourceTypes, worker.getIdentifierExtractor());

        // elements present in both old and new collection: no difference as far as the collection is concerned, recursive diff
        for(Map.Entry<Object,Object> e: equiv.equiv.entrySet()) {
            final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(e.getKey(), elementTypes));
            worker.diff(elPath, e.getKey(), e.getValue(), elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the new collection: 'added' diff element + recursive diff with 'derived' = true
        for(Object newEl: equiv.targetWithoutSource) {
            final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(newEl, elementTypes));
            worker.diff(elPath, null, newEl, elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the old collection: 'removed' diff element + recursive diff with 'derived' = true
        for(Object oldEl: equiv.sourceWithoutTarget) {
            final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(oldEl, elementTypes));
            worker.diff(elPath, oldEl, null, elementTypes, contextOld, contextNew, isDerived);
        }
    }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final AQualifiedSourceAndTargetType elementTypes = new AQualifiedSourceAndTargetType(h.elementType(types.sourceType), types.sourceQualifier, h.elementType(types.targetType), types.targetQualifier);

        if(targetColl.isEmpty()) {
            // this is an optimization for the common case that the target collection is initially empty
            for(Object s: sourceColl) {
                final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(s, types));

                final AOption<Object> optT = worker.map(elPath, s, null, elementTypes, context);
                if(optT.isDefined()) {
                    targetColl.add(optT.get());
                }
            }
            return h.fromJuCollection(targetColl, types.target());
        }

        final Equiv equiv = new Equiv(sourceColl, targetColl, types, worker.getIdentifierExtractor());

        // now apply the changes to the target collection
        targetColl.removeAll(equiv.targetWithoutSource);
        for (Object s: equiv.sourceWithoutTarget) {
            final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(s, types));
            final AOption<Object> tc = worker.map(elPath, s, null, elementTypes, context);
            if(tc.isDefined()) {
                targetColl.add(tc.get());
            }
        }
        for (Map.Entry<Object, Object> e: equiv.equiv.entrySet()) {
            final APath elPath = ACollectionMappingTools.elementPath(path, worker.getIdentifierExtractor().uniqueIdentifier(e.getKey(), types));
            final AOption<Object> tc = worker.map(elPath, e.getKey(), e.getValue(), elementTypes, context);

            if(tc.isEmpty()) {
                targetColl.remove(e.getValue());
            }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        int index = 0;
        final List<Object> mappedTargetList = new ArrayList<> ();
        for (Object sourceEl: worker.getHelpers ().asJuCollection (source, types.source ())) {
            final Object sourceIdent = worker.getIdentifierExtractor ().uniqueIdentifier (sourceEl, sourceElementType, targetElementType);

            final APath elPath = path.withElementChild (index++, sourceIdent);
            final AOption<Object> mappedOpt = worker.map (elPath, sourceEl, targetValuesByIdentifier.get (sourceIdent), elTypes, context);
            if (mappedOpt.isDefined ()) {
                mappedTargetList.add (mappedOpt.get ());
            }
        }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        if (targetColl.isEmpty()) {
            int index=0;
            // this is an optimization for the common case that the target collection is initially empty
            for (Object s: sourceColl) {
                final APath elPath = path.withElementChild (index++, identifierExtractor.uniqueIdentifier (s, types.source (), types.target ()));
                final AOption<Object> optT = worker.map (elPath, s, null, elementTypes, context);
                if (optT.isDefined()) {
                    targetColl.add(optT.get());
                }
            }
            return h.fromJuCollection(targetColl, types.target());
        }

        final APredicate2NoThrow<Object, Object> eqPredicate = new APredicate2NoThrow<Object, Object> () {
            @Override public boolean apply (Object param1, Object param2) {
                final Object sourceIdent = identifierExtractor.uniqueIdentifier (param1, types.source (), types.target ());
                final Object targetIdent = identifierExtractor.uniqueIdentifier (param2, types.target (), types.target ());
                return Objects.equals (sourceIdent, targetIdent);
            }
        };

        final AObjectHolder<Integer> index = new AObjectHolder<> (0);
        final AFunction2NoThrow <Object, Object, AOption<Object>> mapFunction = new AFunction2NoThrow<Object, Object, AOption<Object>> () {
            @Override public AOption<Object> apply (Object s, Object t) {
                final APath elPath = path.withElementChild (index.value++, identifierExtractor.uniqueIdentifier (s, types.source (), types.target ()));
                return worker.map (elPath, s, t, elementTypes, context);
            }
        };

        LevenshteinDistance<Object, Object> levenshteinDistance = new LevenshteinDistance<> (sourceColl, targetColl, eqPredicate);
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        List<LevenshteinDistance.EditChoice> editPath = levenshtein.getEditPath();

        int i=0;
        int j=0;
        for (LevenshteinDistance.EditChoice c: editPath) {
            final APath elPath = path.withElementChild (j, worker.getIdentifierExtractor().uniqueIdentifier (oldColl.get (j), elementTypes.source (), elementTypes.target ()));
            switch (c) {
                case replace:
                case noOp: {
                    worker.diff (elPath, oldColl.get (j), newColl.get (i), elementTypes, contextOld, contextNew, isDerived);
                    i++;
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final AQualifiedSourceAndTargetType elementTypes = AQualifiedSourceAndTargetType.create (h.elementType (types.source()), h.elementType(types.target()));

        if(targetColl.isEmpty()) {
            // this is an optimization for the common case that the target collection is initially empty
            for(Object s: sourceColl) {
                final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (s, types.source (), types.target ()));

                final AOption<Object> optT = worker.map(elPath, s, null, elementTypes, context);
                if(optT.isDefined()) {
                    targetColl.add(optT.get());
                }
            }
            return h.fromJuCollection(targetColl, types.target());
        }

        final Equiv equiv = new Equiv(sourceColl, targetColl, types, worker.getIdentifierExtractor());

        // now apply the changes to the target collection
        targetColl.removeAll(equiv.targetWithoutSource);
        for (Object s: equiv.sourceWithoutTarget) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (s, types.source (), types.target ()));
            final AOption<Object> tc = worker.map(elPath, s, null, elementTypes, context);
            if(tc.isDefined()) {
                targetColl.add(tc.get());
            }
        }
        for (Map.Entry<Object, Object> e: equiv.equiv.entrySet()) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (e.getKey(), types.source (), types.target ()));
            final AOption<Object> tc = worker.map(elPath, e.getKey(), e.getValue(), elementTypes, context);

            if(tc.isEmpty()) {
                targetColl.remove(e.getValue());
            }
View Full Code Here

Examples of com.ajjpj.amapper.core.path.APath

        final Equiv equiv = new Equiv(sourceOldColl, sourceNewColl, sourceTypes, worker.getIdentifierExtractor());

        // elements present in both old and new collection: no difference as far as the collection is concerned, recursive diff
        for(Map.Entry<Object,Object> e: equiv.equiv.entrySet()) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier(e.getKey(), elementTypes.source (), elementTypes.target ()));
            worker.diff(elPath, e.getKey(), e.getValue(), elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the new collection: 'added' diff element + recursive diff with 'derived' = true
        for(Object newEl: equiv.targetWithoutSource) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier (newEl, elementTypes.target (), elementTypes.target ()));
            worker.diff(elPath, null, newEl, elementTypes, contextOld, contextNew, isDerived);
        }

        // elements only in the old collection: 'removed' diff element + recursive diff with 'derived' = true
        for(Object oldEl: equiv.sourceWithoutTarget) {
            final APath elPath = path.withElementChild (worker.getIdentifierExtractor().uniqueIdentifier(oldEl, elementTypes.source (), elementTypes.target ()));
            worker.diff(elPath, oldEl, null, elementTypes, contextOld, contextNew, isDerived);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.