Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* The MIT License (MIT)
*
* Copyright (c) 2014
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.github.mjeanroy.spring.mappers.objects;
import com.github.mjeanroy.spring.mappers.Mapper;
import com.github.mjeanroy.spring.mappers.factory.ObjectFactory;
/**
* Static factories to object mappers.
*/
public final class ObjectMappers {
// Ensure non instantiation
private ObjectMappers() {
}
/**
* Create new mapper.
* Iterable collection will be an in memory data structure (i.e an instance of Collection).
*
* @param mapper Internal mapper.
* @param klassT Class of objects to map from.
* @param klassU Class of objects to map to.
* @param Type of objects to map from.
* @param Type of objects to map to.
* @return Mapper.
*/
@SuppressWarnings("unchecked")
public static ObjectMapper inMemoryObjectMapper(Mapper mapper, Class klassT, Class klassU) {
return new InMemoryObjectMapper(mapper, klassT, klassU);
}
/**
* Create new mapper.
* Destination objects will be created using custom factory.
* Iterable collection will be an in memory data structure (i.e an instance of Collection).
*
* @param mapper Internal mapper.
* @param klassT Class of objects to map from.
* @param klassU Class of objects to map to.
* @param factory Custom factory for destination objects.
* @param Type of objects to map from.
* @param Type of objects to map to.
* @return Mapper.
*/
@SuppressWarnings("unchecked")
public static ObjectMapper inMemoryObjectMapper(Mapper mapper, Class klassT, Class klassU, ObjectFactory factory) {
return new InMemoryObjectMapper(mapper, klassT, klassU, factory);
}
/**
* Create new mapper.
* Iterable collection will be an a lazy data structure (i.e an instance of Iterable but not
* an instance of Collection).
*
* @param mapper Internal mapper.
* @param klassT Class of objects to map from.
* @param klassU Class of objects to map to.
* @param Type of objects to map from.
* @param Type of objects to map to.
* @return Mapper.
*/
@SuppressWarnings("unchecked")
public static ObjectMapper lazyObjectMapper(Mapper mapper, Class klassT, Class klassU) {
return new LazyObjectMapper(mapper, klassT, klassU);
}
/**
* Create new mapper.
* Destination objects will be created using custom factory.
* Iterable collection will be an a lazy data structure (i.e an instance of Iterable but not
* an instance of Collection).
*
* @param mapper Internal mapper.
* @param klassT Class of objects to map from.
* @param klassU Class of objects to map to.
* @param factory Custom factory for destination objects.
* @param Type of objects to map from.
* @param Type of objects to map to.
* @return Mapper.
*/
@SuppressWarnings("unchecked")
public static ObjectMapper lazyObjectMapper(Mapper mapper, Class klassT, Class klassU, ObjectFactory factory) {
return new LazyObjectMapper(mapper, klassT, klassU, factory);
}
private static class InMemoryObjectMapper extends AbstractInMemoryObjectMapper implements ObjectMapper {
private InMemoryObjectMapper(Mapper mapper, Class klassT, Class klassU) {
super(mapper, klassT, klassU);
}
private InMemoryObjectMapper(Mapper mapper, Class klassT, Class klassU, ObjectFactory factory) {
super(mapper, klassT, klassU, factory);
}
}
private static class LazyObjectMapper extends AbstractLazyObjectMapper implements ObjectMapper {
private LazyObjectMapper(Mapper mapper, Class klassT, Class klassU) {
super(mapper, klassT, klassU);
}
private LazyObjectMapper(Mapper mapper, Class klassT, Class klassU, ObjectFactory factory) {
super(mapper, klassT, klassU, factory);
}
}
}