com.googlecode.jmapper.api.IJMapper Maven / Gradle / Ivy
/**
* Copyright (C) 2012 - 2014 Alessandro Vurro.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.googlecode.jmapper.api;
import com.googlecode.jmapper.api.enums.MappingType;
import com.googlecode.jmapper.api.enums.NullPointerControl;
/**
* JMapper takes as input two classes, Destination and Source.
* For Destination, we mean the instance that will be created or enhanced.
* For Source, we mean the instance containing the data.
* To execute the mapping, we must before configure one class beetween Destination and Source.
* for example:
*
* class Destination {
*
* {@code @JMap}
* String id;
*
* {@code @JMap("sourceField")}
* String destinationField;
*
* String other;
*
* // getter and setter
* }
*
* class Source {
*
* String id;
*
* String sourceField;
*
* String other;
*
* // getter and setter
* }
*
* then invoke the method GetDestination.
* For example:
*
* Source source = new Source("id", "sourceField", "other");
* JMapper jmapper = new JMapper(Destination.class, Source.class);
* // new instance
* Destination destination = jmapper.getDestination(source);
* // enrichment
* jmapper.getDestination(destination, source);
* @author Alessandro Vurro
* @param Type of the Destination Class
* @param Type of Source Class
*/
public interface IJMapper {
/**
* This method returns a new instance of Destination Class with this setting:
*
*
* NullPointerControl
SOURCE
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourceALL_FIELDS
*
*
* @param source instance that contains the data
* @return new instance of destination
* @see NullPointerControl
* @see MappingType
*/
D getDestination(final S source);
/**
* This method returns a new instance of Destination Class with this setting:
*
*
* NullPointerControl
NOT_ANY
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourceALL_FIELDS
*
*
* @param source instance that contains the data
* @return new instance of destination
* @see NullPointerControl
* @see MappingType
*/
public D getDestinationWithoutControl(final S source);
/**
* This Method returns the destination given in input enriched with data contained in source given in input
* with this setting:
*
*
* NullPointerControl
ALL
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourceALL_FIELDS
*
*
* @param destination instance to enrich
* @param source instance that contains the data
* @return destination enriched
* @see NullPointerControl
* @see MappingType
*/
public D getDestination(D destination,final S source);
/**
* This Method returns the destination given in input enriched with data contained in source given in input
* with this setting:
*
*
* NullPointerControl
NOT_ANY
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourceALL_FIELDS
*
*
* @param destination instance to enrich
* @param source instance that contains the data
* @return destination enriched
* @see NullPointerControl
* @see MappingType
*/
public D getDestinationWithoutControl(D destination,final S source);
/**
* This method returns a new instance of Destination Class with this setting:
*
*
* NullPointerControl
SOURCE
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourcemtSource
*
*
* @param source instance that contains the data
* @param mtSource type of mapping
* @return new instance of destination
* @see NullPointerControl
* @see MappingType
*/
public D getDestination(final S source,final MappingType mtSource);
/**
* This method returns a new instance of Destination Class with this setting:
*
*
* NullPointerControl
nullPointerControl
*
* MappingType
of DestinationALL_FIELDS
*
* MappingType
of SourcemtSource
*
*
* @param source instance that contains the data
* @param nullPointerControl type of control
* @param mtSource type of mapping
* @return new instance of destination
* @see NullPointerControl
* @see MappingType
*/
public D getDestination(final S source,final NullPointerControl nullPointerControl,final MappingType mtSource);
/**
* This Method returns the destination given in input enriched with data contained in source given in input
* with this setting:
*
*
* NullPointerControl
ALL
*
* MappingType
of DestinationmtDestination
*
* MappingType
of SourcemtSource
*
*
* @param destination instance to enrich
* @param source instance that contains the data
* @param mtDestination type of mapping of destination instance
* @param mtSource type of mapping of source instance
* @return destination enriched
* @see NullPointerControl
* @see MappingType
*/
public D getDestination(D destination,final S source,final MappingType mtDestination,final MappingType mtSource);
/**
* This Method returns the destination given in input enriched with data contained in source given in input
* with this setting:
*
*
* NullPointerControl
nullPointerControl
*
* MappingType
of DestinationmtDestination
*
* MappingType
of SourcemtSource
*
*
* @param destination instance to enrich
* @param source instance that contains the data
* @param nullPointerControl type of control
* @param mtDestination type of mapping of destination instance
* @param mtSource type of mapping of source instance
* @return destination enriched
* @see NullPointerControl
* @see MappingType
*/
public D getDestination(D destination,final S source,final NullPointerControl nullPointerControl,final MappingType mtDestination,final MappingType mtSource);
}