final ConversionDefForClass originalConversionDef,
final Map<ClassInfo, Deque<ClassReplacementDef>> replacementDefByClassMap)
throws ConversionException {
final Deque<ClassReplacementDef> classReplacementDefList = new LinkedList<ClassReplacementDef>();
ConversionDefForClass intermediateConversionDef = originalConversionDef;
final ClassInfo originalClassInfo = originalConversionDef
.getClassInfo();
final Deque<ClassReplacementDef> previousClassReplacementDef = replacementDefByClassMap
.put(originalClassInfo, classReplacementDefList);
do {
final ClassInfo originalClass = intermediateConversionDef
.getClassInfo();
final ClassInfo replacementClass = intermediateConversionDef
.getReplacementClass();
final FieldConversionMap fieldConversionMap = intermediateConversionDef
.getFieldConversionMap();
final FieldConversionMap staticFieldConversionMap = intermediateConversionDef
.getStaticFieldConversionMap();
final ClassInfo converterClass = intermediateConversionDef
.getConverterClass();
final ClassInfo staticConverterClass = intermediateConversionDef
.getStaticConverterClass();
final ClassReplacementDef classReplacementDef = new ClassReplacementDef(
/**/originalClass, replacementClass, converterClass,
staticConverterClass, fieldConversionMap,
staticFieldConversionMap);
final List<FieldInfo> originalFieldList = intermediateConversionDef
.getFieldList();
int originalFieldIndex = 0;
for (FieldInfo originalFieldInfo : originalFieldList) {
final FieldReplacementDef fieldReplacementDef = classReplacementDef
.getReplacementFieldInfo(originalFieldInfo);
if (fieldReplacementDef == null) {
final FieldInfo newFieldInfo = replacementFieldInfo(
intermediateConversionDef.getIdentifier(),
originalFieldInfo);
classReplacementDef.addFieldConversion(originalFieldInfo,
originalFieldIndex, newFieldInfo,
// replacement field index is unknown
-1/* replacementFieldIndex */);
}
originalFieldIndex++;
}
classReplacementDefList.add(classReplacementDef);
final int nextId = intermediateConversionDef.getToIdentifier();
final NavigableMap<Integer, ConversionDefForClass> convDefById =
/**/conversionDefByClassAndIdMap.get(replacementClass);
if (convDefById == null) {
intermediateConversionDef = null;// NOPMD
} else {
final Entry<Integer, ConversionDefForClass> ceiling = convDefById
.ceilingEntry(nextId);
if (ceiling == null) {
intermediateConversionDef = null;// NOPMD
} else {
intermediateConversionDef = ceiling.getValue();
if (intermediateConversionDef.getToIdentifier() > current) {
intermediateConversionDef = null;// NOPMD
}
}
}