Java 类com.bumptech.glide.annotation.GlideModule 实例源码

项目:GitHub    文件:IndexerGenerator.java   
TypeSpec generate(List<TypeElement> types) {
  List<TypeElement> modules =  new ArrayList<>();
  List<TypeElement> extensions = new ArrayList<>();
  for (TypeElement element : types) {
    if (processorUtil.isExtension(element)) {
      extensions.add(element);
    } else if (processorUtil.isLibraryGlideModule(element)) {
      modules.add(element);
    } else {
      throw new IllegalArgumentException("Unrecognized type: " + element);
    }
  }
  if (!modules.isEmpty() && !extensions.isEmpty()) {
    throw new IllegalArgumentException("Given both modules and extensions, expected one or the "
        + "other. Modules: " + modules + " Extensions: " + extensions);
  }
  if (!modules.isEmpty()) {
    return generate(types, GlideModule.class);
  } else {
    return generate(types, GlideExtension.class);
  }
}
项目:GitHub    文件:IndexerGenerator.java   
TypeSpec generate(List<TypeElement> types) {
  List<TypeElement> modules =  new ArrayList<>();
  List<TypeElement> extensions = new ArrayList<>();
  for (TypeElement element : types) {
    if (processorUtil.isExtension(element)) {
      extensions.add(element);
    } else if (processorUtil.isLibraryGlideModule(element)) {
      modules.add(element);
    } else {
      throw new IllegalArgumentException("Unrecognized type: " + element);
    }
  }
  if (!modules.isEmpty() && !extensions.isEmpty()) {
    throw new IllegalArgumentException("Given both modules and extensions, expected one or the "
        + "other. Modules: " + modules + " Extensions: " + extensions);
  }
  if (!modules.isEmpty()) {
    return generate(types, GlideModule.class);
  } else {
    return generate(types, GlideExtension.class);
  }
}
项目:GitHub    文件:LibraryModuleProcessor.java   
boolean processModules(Set<? extends TypeElement> set, RoundEnvironment env) {
   // Order matters here, if we find an Indexer below, we return before writing the root module.
  // If we fail to add to appModules before then, we might accidentally skip a valid RootModule.
  List<TypeElement> libraryGlideModules = new ArrayList<>();
  for (TypeElement element : processorUtil.getElementsFor(GlideModule.class, env)) {
    // Root elements are added separately and must be checked separately because they're sub
    // classes of LibraryGlideModules.
    if (processorUtil.isAppGlideModule(element)) {
      continue;
    } else if (!processorUtil.isLibraryGlideModule(element)) {
      throw new IllegalStateException("@GlideModule can only be applied to LibraryGlideModule"
          + " and AppGlideModule implementations, not: " + element);
    }

    libraryGlideModules.add(element);
  }

  processorUtil.debugLog("got child modules: " + libraryGlideModules);
  if (libraryGlideModules.isEmpty()) {
    return false;
  }

  TypeSpec indexer = indexerGenerator.generate(libraryGlideModules);
  processorUtil.writeIndexer(indexer);
  processorUtil.debugLog("Wrote an Indexer this round, skipping the app module to ensure all "
      + "indexers are found");
   // If I write an Indexer in a round in the target package, then try to find all classes in
  // the target package, my newly written Indexer won't be found. Since we wrote a class with
  // an Annotation handled by this processor, we know we will be called again in the next round
  // and we can safely wait to write our AppGlideModule until then.
  return true;
}
项目:GitHub    文件:AppModuleProcessor.java   
void processModules(Set<? extends TypeElement> set, RoundEnvironment env) {
   for (TypeElement element : processorUtil.getElementsFor(GlideModule.class, env)) {
     if (processorUtil.isAppGlideModule(element)) {
       appGlideModules.add(element);
     }
   }

  processorUtil.debugLog("got app modules: " + appGlideModules);

  if (appGlideModules.size() > 1) {
    throw new IllegalStateException(
        "You cannot have more than one AppGlideModule, found: " + appGlideModules);
  }
}
项目:GitHub    文件:IndexerGenerator.java   
private static String getAnnotationValue(Class<? extends Annotation> annotation) {
  if (annotation == GlideModule.class) {
    return "modules";
  } else if (annotation == GlideExtension.class) {
    return "extensions";
  } else {
    throw new IllegalArgumentException("Unrecognized annotation: " + annotation);
  }
}
项目:GitHub    文件:LibraryModuleProcessor.java   
boolean processModules(RoundEnvironment env) {
   // Order matters here, if we find an Indexer below, we return before writing the root module.
  // If we fail to add to appModules before then, we might accidentally skip a valid RootModule.
  List<TypeElement> libraryGlideModules = new ArrayList<>();
  for (TypeElement element : processorUtil.getElementsFor(GlideModule.class, env)) {
    // Root elements are added separately and must be checked separately because they're sub
    // classes of LibraryGlideModules.
    if (processorUtil.isAppGlideModule(element)) {
      continue;
    } else if (!processorUtil.isLibraryGlideModule(element)) {
      throw new IllegalStateException("@GlideModule can only be applied to LibraryGlideModule"
          + " and AppGlideModule implementations, not: " + element);
    }

    libraryGlideModules.add(element);
  }

  processorUtil.debugLog("got child modules: " + libraryGlideModules);
  if (libraryGlideModules.isEmpty()) {
    return false;
  }

  TypeSpec indexer = indexerGenerator.generate(libraryGlideModules);
  processorUtil.writeIndexer(indexer);
  processorUtil.debugLog("Wrote an Indexer this round, skipping the app module to ensure all "
      + "indexers are found");
   // If I write an Indexer in a round in the target package, then try to find all classes in
  // the target package, my newly written Indexer won't be found. Since we wrote a class with
  // an Annotation handled by this processor, we know we will be called again in the next round
  // and we can safely wait to write our AppGlideModule until then.
  return true;
}
项目:GitHub    文件:AppModuleProcessor.java   
void processModules(Set<? extends TypeElement> set, RoundEnvironment env) {
   for (TypeElement element : processorUtil.getElementsFor(GlideModule.class, env)) {
     if (processorUtil.isAppGlideModule(element)) {
       appGlideModules.add(element);
     }
   }

  processorUtil.debugLog("got app modules: " + appGlideModules);

  if (appGlideModules.size() > 1) {
    throw new IllegalStateException(
        "You cannot have more than one AppGlideModule, found: " + appGlideModules);
  }
}
项目:GitHub    文件:IndexerGenerator.java   
private static String getAnnotationValue(Class<? extends Annotation> annotation) {
  if (annotation == GlideModule.class) {
    return "modules";
  } else if (annotation == GlideExtension.class) {
    return "extensions";
  } else {
    throw new IllegalArgumentException("Unrecognized annotation: " + annotation);
  }
}
项目:GitHub    文件:LibraryModuleProcessor.java   
Set<String> getSupportedAnnotationTypes() {
  return Collections.singleton(GlideModule.class.getName());
}
项目:GitHub    文件:AppModuleProcessor.java   
private String getGlideName(TypeElement appModule) {
  return appModule.getAnnotation(GlideModule.class).glideName();
}
项目:GitHub    文件:LibraryModuleProcessor.java   
Set<String> getSupportedAnnotationTypes() {
  return Collections.singleton(GlideModule.class.getName());
}
项目:GitHub    文件:AppModuleProcessor.java   
private String getGlideName(TypeElement appModule) {
  return appModule.getAnnotation(GlideModule.class).glideName();
}