Examples of AQualifiedSourceAndTargetType


Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        }

        final AQualifiedType sourceElementType = worker.getHelpers ().elementType (types.source ());
        final AQualifiedType targetElementType = worker.getHelpers ().elementType (types.target ());

        final AQualifiedSourceAndTargetType elTypes = AQualifiedSourceAndTargetType.create (sourceElementType, targetElementType);

        final Map<Object, Object> targetValuesByIdentifier = byIdentifier (worker.getHelpers ().asJuCollection (target, types.target ()),
                worker.getIdentifierExtractor (),
                targetElementType, // this is intentional: extract identifiers for target elements in terms of the target element type
                targetElementType);
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

    //TODO test this
    @Override public void diff (ADiffBuilder diff, Object sourceOld, Object sourceNew, AQualifiedSourceAndTargetType types, AMapperDiffWorker<? extends ACollectionHelper> worker, AMap<String, Object> contextOld, AMap<String, Object> contextNew, APath path, boolean isDerived) throws Exception {
        final AType targetElementType = worker.getHelpers ().elementType (types.target ()).tpe;
        final AType targetTypeAsList = JavaBeanTypes.create (List.class, ((JavaBeanType) targetElementType).cls);
        final AQualifiedSourceAndTargetType typesWithListTarget = AQualifiedSourceAndTargetType.create (types.source (), new AQualifiedType (targetTypeAsList, types.targetQualifier ()));

        worker.diff (path, sourceOld, sourceNew, typesWithListTarget, contextOld, contextNew, isDerived);
    }
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        }

        final ACollectionHelper h = worker.getHelpers();
        final Collection<Object> sourceColl = h.asJuCollection (source, types.source());
        final List<Object> targetColl = (List<Object>) h.asJuCollection (target, types.target());
        final AQualifiedSourceAndTargetType elementTypes = AQualifiedSourceAndTargetType.create (h.elementType (types.source()), h.elementType(types.target()));
        final AIdentifierExtractor identifierExtractor = worker.getIdentifierExtractor();

        if (targetColl.isEmpty()) {
            int index=0;
            // this is an optimization for the common case that the target collection is initially empty
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        final ACollectionHelper h = worker.getHelpers();

        final List<Object> oldColl = (List<Object>) h.asJuCollection(sourceOld, types.source());
        final List<Object> newColl = (List<Object>) h.asJuCollection(sourceNew, types.source());

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

        final AIdentifierExtractor identifierExtractor = worker.getIdentifierExtractor();

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

        LevenshteinDistance<Object, Object> levenshtein = new LevenshteinDistance<> (newColl, oldColl, equalsPredicate);
        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.tpe.AQualifiedSourceAndTargetType

        if(sourceColl == null) {
            return null;
        }

        final Collection<Object> targetColl = target != null ? h.asJuCollection(target, types.target()) : h.createEmptyCollection(types.target());
        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 ()));
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        final ACollectionHelper h = worker.getHelpers();

        final Collection<Object> sourceOldColl = h.asJuCollection(sourceOld, types.source());
        final Collection<Object> sourceNewColl = h.asJuCollection(sourceNew, types.target());

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

        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()) {
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        if(source == null) {
            return null;
        }

        final Collection<Object> targetColl = target != null ? h.asJuCollection(target, types.target()) : h.createEmptyCollection(types.target());
        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));
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        final ACollectionHelper h = worker.getHelpers();

        final Collection<Object> sourceOldColl = h.asJuCollection(sourceOld, types.source());
        final Collection<Object> sourceNewColl = h.asJuCollection(sourceNew, types.target());

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

        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()) {
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        public Equiv(Collection<Object> sourceColl, Collection<Object> targetColl, AQualifiedSourceAndTargetType types, AIdentifierExtractor identifierExtractor) {
            targetWithoutSource.addAll(targetColl);

            // 'types' for calculating target element identifiers in term of the target type
            final AQualifiedSourceAndTargetType targetTypes = new AQualifiedSourceAndTargetType(types.targetType, types.targetQualifier, types.targetType, types.targetQualifier);

            // iterate through all source elements and sort source / target elements according to identifier equality
            for(Object s: sourceColl) {
                final Object sourceIdent = identifierExtractor.uniqueIdentifier(s, types);
                final AOption<Object> equivTarget = findTarget(targetColl, sourceIdent, identifierExtractor, targetTypes);
View Full Code Here

Examples of com.ajjpj.amapper.core.tpe.AQualifiedSourceAndTargetType

        }
        if(source == null) {
            return null;
        }

        final AQualifiedSourceAndTargetType types = AQualifiedSourceAndTargetType.create (JavaBeanTypes.create (source.getClass ()), JavaBeanTypes.create (targetClass));
        for (APreProcessor pre: preProcessors.allEntriesFor (types)) {
            final AOption<?> opt = pre.preProcess (source, types);
            if (opt.isEmpty ()) {
                return null;
            }
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.