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.
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen;
import com.google.common.base.Preconditions;
import io.permazen.annotation.PermazenType;
import io.permazen.core.ObjId;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Function;
/**
* Context for importing plain (POJO) objects into a {@link PermazenTransaction}.
*
*
* Plain objects (POJO's) can be imported into a {@link PermazenTransaction} to the extent that the POJO class and
* the corresponding Permazen model class share the same properties. The simplest example of this is when
* the POJO class is also the Permazen model class (implying a non-abstract class; see also
* {@link PermazenType#autogenNonAbstract @PermazenType.autogenNonAbstract()}). Also possible are POJO
* classes and model classes that implement common Java interfaces.
*
*
* The {@link ObjId} for the corresponding imported Permazen object is determined by the configured {@code objectIdMapper}.
* If {@code objectIdMapper} returns null, the POJO is not imported, and nulls replace any copied references to it; otherwise,
* the returned object must exist in the transaction. If {@code objectIdMapper} is itself null, the default behavior is
* to create a new Permazen object using {@link PermazenTransaction#create(Class)}, providing the POJO's class as the model class.
*
*
* Instances ensure that an already-imported POJO will be recognized and not imported twice.
* Note this determination is based on object identity, not {@link Object#equals Object.equals()}.
* The {@code objectIdMapper} is invoked at most once for any POJO.
*
*
* Once the target object for a POJO has been identified, common properties are copied, overwriting any previous values.
* POJO properties that are not Permzen properties are ignored; conversely, properties that exist in the Permazen model
* object type but are missing in the POJO are left unmodified.
*
*
* Permazen reference fields are automatically imported as POJO's, recursively. In other words, the entire transitive closure
* of POJO's reachable from an imported object is imported. Cycles in the graph of references are handled properly.
*
*
Conversion Details
*
* {@link Counter} fields import from any {@link Number} property.
*
* @see ExportContext
*/
public class ImportContext {
private final PermazenTransaction ptx;
private final Function