org.mapstruct.ap.internal.conversion.SimpleConversion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mapstruct-processor Show documentation
Show all versions of mapstruct-processor Show documentation
An annotation processor for generating type-safe bean mappers
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.internal.conversion;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.mapstruct.ap.internal.model.TypeConversion;
import org.mapstruct.ap.internal.model.common.Assignment;
import org.mapstruct.ap.internal.model.common.ConversionContext;
import org.mapstruct.ap.internal.model.HelperMethod;
import org.mapstruct.ap.internal.model.common.Type;
/**
* Base class for {@link ConversionProvider}s creating {@link TypeConversion}s which don't declare any exception types.
*
* @author Gunnar Morling
*/
public abstract class SimpleConversion implements ConversionProvider {
@Override
public Assignment to(ConversionContext conversionContext) {
String toExpression = getToExpression( conversionContext );
return new TypeConversion( getToConversionImportTypes( conversionContext ),
getToConversionExceptionTypes( conversionContext ),
toExpression
);
}
@Override
public Assignment from(ConversionContext conversionContext) {
String fromExpression = getFromExpression( conversionContext );
return new TypeConversion( getFromConversionImportTypes( conversionContext ),
getFromConversionExceptionTypes( conversionContext ),
fromExpression
);
}
@Override
public List getRequiredHelperMethods(ConversionContext conversionContext) {
return Collections.emptyList();
}
/**
* Returns the conversion string from source to target. The placeholder {@code