Class MappingContext
java.lang.Object
software.coley.sourcesolver.mapping.MappingContext
Centralized mapping control.
- Author:
- Matt Coley
-
Constructor Details
-
MappingContext
- Parameters:
table- Table to lookup tree positions within.source- Original source code being parsed.
-
-
Method Details
-
getSource
- Returns:
- Original source code being parsed.
-
getTable
@Nonnull public com.sun.tools.javac.tree.EndPosTable getTable()- Returns:
- Table to lookup tree positions within.
-
setMapper
public <T extends Mapper<?,?>> void setMapper(@Nonnull Class<T> mapperType, @Nonnull T mapperImplementation) - Type Parameters:
T- Mapper type.- Parameters:
mapperType- Mapper class.mapperImplementation- Implementation of the class.
-
setMapperSupplier
public <T extends Mapper<?,?>> void setMapperSupplier(@Nonnull Class<T> mapperType, @Nonnull Supplier<T> mapperSupplier) - Type Parameters:
T- Mapper type.- Parameters:
mapperType- Mapper class.mapperSupplier- Supplier to provide an implementation of the class.
-
getMapper
- Type Parameters:
T- Mapper type.- Parameters:
mapperType- Mapper class.- Returns:
- Implementation of the mapper class.
- Throws:
IllegalStateException- When no such implementation exists for the given mapper type.
-
map
@Nonnull public <M extends Model,T extends Tree, M mapX extends Mapper<M, T>> (@Nonnull Class<X> mapperType, @Nonnull T tree) - Type Parameters:
M- Model type to output.T- Tree type to convert.X- Mapper type to handle conversion.- Parameters:
mapperType- Mapper class.tree- Tree to map.- Returns:
- Model representation of the tree.
-
mapOr
@Nonnull public <M extends Model,T extends Tree, M mapOrX extends Mapper<M, T>> (@Nonnull Class<X> mapperType, @Nullable T tree, @Nonnull Supplier<M> defaultValueSupplier) - Type Parameters:
M- Model type to output.T- Tree type to convert.X- Mapper type to handle conversion.- Parameters:
mapperType- Mapper class.tree- Tree to map.defaultValueSupplier- Supplier to provide a fallback model.- Returns:
- Model representation of the tree.
-