Examples of MappingStrategy


Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    public <S, Dk, Dv> Map<Dk, Dv> mapAsMap(S[] source, Type<S> sourceType, Type<? extends Map<Dk, Dv>> destinationType,
            MappingContext context) {
       
        Map<Dk, Dv> destination = new HashMap<Dk, Dv>();
        Type<MapEntry<Dk, Dv>> entryType = MapEntry.concreteEntryType(destinationType);
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
       
        for (S element : source) {
            if (strategy == null || !element.getClass().equals(entryClass)) {
                strategy = resolveMappingStrategy(element, sourceType, entryType, false, context);
                entryClass = element.getClass();
            }
           
            MapEntry<Dk, Dv> entry = context.getMappedObject(element, entryType);
            if (entry == null) {
                entry = (MapEntry<Dk, Dv>) strategy.map(element, null, context);
            }
            destination.put(entry.getKey(), entry.getValue());
        }
       
        return destination;
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(float[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Float) strategy.map(s, null, mappingContext);
        }
       
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(double[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Double) strategy.map(s, null, mappingContext);
        }
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

            this.mapperFacade = mapperFacade;
            this.inPlace = inPlace;
        }
       
        public MappingStrategy getStrategy(Object sourceObject, MappingContext context) {
            MappingStrategy strategy = null;
            if (defaultStrategy != null && sourceObject.getClass().equals(idClass)) {
                strategy = defaultStrategy;
            } else if (defaultStrategy == null) {
                synchronized(this) {
                    if (defaultStrategy == null) {
                        defaultStrategy = mapperFacade.resolveMappingStrategy(sourceObject, aType, bType, inPlace, context);
                        idClass = sourceObject.getClass();
                    }
                }
                strategy = defaultStrategy;
            } else {
                strategy = strategies.get(sourceObject.getClass());
                if (strategy == null) {
                    strategy = mapperFacade.resolveMappingStrategy(sourceObject, aType, bType, inPlace, context);
                    strategies.put(sourceObject.getClass(), strategy);
                }
            }
           
            /*
             * Set the resolved types on the current mapping context; this can be used
             * by downstream Mappers to determine the originally resolved types
             */
            context.setResolvedSourceType(strategy.getSoureType());
            context.setResolvedDestinationType(strategy.getDestinationType());
           
            return strategy;
        }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(byte[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Byte) strategy.map(s, null, mappingContext);
        }
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(boolean[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Boolean) strategy.map(s, null, mappingContext);
        }
       
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(char[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Character) strategy.map(s, null, mappingContext);
        }
       
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(short[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Short) strategy.map(s, null, mappingContext);
        }
       
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(int[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Integer) strategy.map(s, null, mappingContext);
        }
       
    }
View Full Code Here

Examples of ma.glasnost.orika.impl.mapping.strategy.MappingStrategy

    protected void mapArray(long[] destination, List<Object> source, Class<?> clazz, MappingContext mappingContext) {
        if (source == null) {
            return;
        }
       
        MappingStrategy strategy = null;
        Class<?> entryClass = null;
        int i = 0;
        for (final Object s : source) {
            if (strategy == null || !s.getClass().equals(entryClass)) {
                strategy = mapperFacade.resolveMappingStrategy(s, null, clazz, false, mappingContext);
                entryClass = s.getClass();
            }
            destination[i++] = (Long) strategy.map(s, null, mappingContext);
        }
       
    }
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.