net.sf.brunneng.jom.converters.PropertyConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-object-merger Show documentation
Show all versions of java-object-merger Show documentation
Tool for merging objects of possible different type but similar structure
package net.sf.brunneng.jom.converters;
import net.sf.brunneng.jom.info.OperationContextInfo;
import java.util.List;
/**
* Provide conversion between corresponding properties. Conversion occurs during creation of diff, to make possible
* to compare corresponding properties. Then, converted values can be used to insert into properties during applying
* of diff. Class of converter should be specified by
* {@link net.sf.brunneng.jom.annotations.Converter @Converter} annotation.
*/
public interface PropertyConverter extends MarkersUser {
/**
* This method is called to convert from source property to destination if annotation is present in destination
* side, and vise versa - if it's on source side of association.
* @param otherPropertiesObjects list of object taken from properties on other side of association. In case
* of {@link net.sf.brunneng.jom.annotations.MapFromMany @MapFromMany} it will
* contain several values, otherwise - one value.
* @param contextInfo information about {@link net.sf.brunneng.jom.info.OperationContextInfo context}
* in which values are converted. Using of this context is not necessary but it can be useful
* in some situation to help to create result object correctly.
* @return converted object. Also you can return marker object
* MarkersUser.EQUAL_TO_DESTINATION_MARKER, which will be treated by mapper as equal equal to destination
* object. And as result - protect destination object from being changed.
*/
Object convertFrom(List