Skip to content

lugeek/ExtClassMapper

Repository files navigation

ExtClassMapper

Annotate class with group and target, generate the index Map<String, Map<String,Class<?>> in building progress , then the class can indexed by group and target.

Maven Central

Configuration

  1. dependencies
dependencies {
  implementation 'com.lugeek:extclassmapper:{latest-version}'
  annotationProcessor 'com.lugeek:extclassmapper-compiler:{latest-version}'
}
  1. Init
  ECMapper.init(this);
  1. Usage
defaultConfig {
    ...
    javaCompileOptions {
        annotationProcessorOptions {
            arguments = [moduleName: project.getName()]
        }
    }
}
  • ☝︎ Specify moduleName in build.gradle file to resolve multi module conflict while generate file in building progress.
@ExtClassMapper(value = {"test","test2"}, group = "testGroup")
public class Test {
}
  • annotate the target with value for class
  • annotate the group with group for class
  • duplicated target for same group is not allowed
  • default group name is default if not assigned
// get all targets with classes in group
ECMapper.getsInstance().getGroup(group);
// get class for target in 'default' group
ECMapper.getsInstance().getClz(target);
// get class in specific group and target
ECMapper.getsInstance().getClz(group, target);

About

Generate mapping file <String, Class> in Android build progress by annotations.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages