예제 #1
0
 public String componentModel() {
   if (mapperConfigPrism != null && mapperPrism.values.componentModel() == null) {
     return mapperConfigPrism.componentModel();
   } else {
     return mapperPrism.componentModel();
   }
 }
예제 #2
0
  private Set<TypeElement> getMappers(
      final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnvironment) {
    Set<TypeElement> mapperTypes = new HashSet<TypeElement>();

    for (TypeElement annotation : annotations) {
      // Indicates that the annotation's type isn't on the class path of the compiled
      // project. Let the compiler deal with that and print an appropriate error.
      if (annotation.getKind() != ElementKind.ANNOTATION_TYPE) {
        continue;
      }

      try {
        Set<? extends Element> annotatedMappers =
            roundEnvironment.getElementsAnnotatedWith(annotation);
        for (Element mapperElement : annotatedMappers) {
          TypeElement mapperTypeElement = asTypeElement(mapperElement);

          // on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with
          // annotations unknown to the compiler, even though they are not declared Mappers
          if (mapperTypeElement != null && MapperPrism.getInstanceOn(mapperTypeElement) != null) {
            mapperTypes.add(mapperTypeElement);
          }
        }
      } catch (Throwable t) { // whenever that may happen, but just to stay on the save side
        handleUncaughtError(annotation, t);
        continue;
      }
    }
    return mapperTypes;
  }
예제 #3
0
 public String implementationPackage() {
   if (mapperConfigPrism != null && mapperPrism.values.implementationPackage() == null) {
     return mapperConfigPrism.implementationPackage();
   } else {
     return mapperPrism.implementationPackage();
   }
 }
예제 #4
0
 public CollectionMappingStrategyPrism getCollectionMappingStrategy() {
   if (mapperConfigPrism != null && mapperPrism.values.collectionMappingStrategy() == null) {
     return CollectionMappingStrategyPrism.valueOf(mapperConfigPrism.collectionMappingStrategy());
   } else {
     return CollectionMappingStrategyPrism.valueOf(mapperPrism.collectionMappingStrategy());
   }
 }
예제 #5
0
 public String unmappedTargetPolicy() {
   if (mapperConfigPrism != null && mapperPrism.values.unmappedTargetPolicy() == null) {
     return mapperConfigPrism.unmappedTargetPolicy();
   } else {
     return mapperPrism.unmappedTargetPolicy();
   }
 }
예제 #6
0
 public MappingInheritanceStrategyPrism getMappingInheritanceStrategy() {
   if (mapperConfigPrism != null && mapperPrism.values.mappingInheritanceStrategy() == null) {
     return MappingInheritanceStrategyPrism.valueOf(
         mapperConfigPrism.mappingInheritanceStrategy());
   } else {
     return MappingInheritanceStrategyPrism.valueOf(mapperPrism.mappingInheritanceStrategy());
   }
 }
예제 #7
0
  private boolean isMapToDefaultOnMapperAndMappingConfigLevel() {
    final NullValueMappingStrategyPrism strategy;
    if (mapperConfigPrism != null && mapperPrism.values.nullValueMappingStrategy() == null) {
      strategy =
          NullValueMappingStrategyPrism.valueOf(mapperConfigPrism.nullValueMappingStrategy());
    } else {
      strategy = NullValueMappingStrategyPrism.valueOf(mapperPrism.nullValueMappingStrategy());
    }

    return NullValueMappingStrategyPrism.RETURN_DEFAULT == strategy;
  }
예제 #8
0
  private MapperConfiguration(MapperPrism mapperPrism) {
    this.mapperPrism = mapperPrism;

    if (mapperPrism.values.config() != null) {
      // TODO #737 Only a declared type makes sense here; Validate and raise graceful error;
      // Also validate that @MapperConfig is present
      this.config = (DeclaredType) mapperPrism.config();
      this.mapperConfigPrism = MapperConfigPrism.getInstanceOn(config.asElement());
    } else {
      this.config = null;
      this.mapperConfigPrism = null;
    }
  }
예제 #9
0
  public Set<DeclaredType> uses() {
    Set<DeclaredType> uses = new LinkedHashSet<DeclaredType>();

    for (TypeMirror usedMapperType : mapperPrism.uses()) {
      // TODO #737 Only declared type make sense here; Validate and raise graceful error;
      uses.add((DeclaredType) usedMapperType);
    }

    if (mapperConfigPrism != null) {
      for (TypeMirror usedMapperType : mapperConfigPrism.uses()) {
        // TODO #737 Only declared type make sense here; Validate and raise graceful error;
        uses.add((DeclaredType) usedMapperType);
      }
    }

    return uses;
  }
  private List<MapperReference> initReferencedMappers(
      TypeElement element, MapperConfiguration mapperConfig) {
    List<MapperReference> result = new LinkedList<MapperReference>();
    List<String> variableNames = new LinkedList<String>();

    for (TypeMirror usedMapper : mapperConfig.uses()) {
      DefaultMapperReference mapperReference =
          DefaultMapperReference.getInstance(
              typeFactory.getType(usedMapper),
              MapperPrism.getInstanceOn(typeUtils.asElement(usedMapper)) != null,
              typeFactory,
              variableNames);

      result.add(mapperReference);
      variableNames.add(mapperReference.getVariableName());
    }

    return result;
  }
예제 #11
0
 public static MapperConfiguration getInstanceOn(Element e) {
   return new MapperConfiguration(MapperPrism.getInstanceOn(e));
 }
예제 #12
0
 public List<TypeMirror> imports() {
   return mapperPrism.imports();
 }