Skip to content

Commit

Permalink
changed generate method name
Browse files Browse the repository at this point in the history
  • Loading branch information
nnjun committed Feb 19, 2022
1 parent 2e1c5e5 commit 67ee128
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/top/niunaijun/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "============================");

// checkField
Field field = BRTestReflection.get()._checkfakeField();
Field field = BRTestReflection.get()._check_fakeField();
Log.d(TAG, "checkField: " + field);

Log.d(TAG, "============================");

// setContextField
BRTestReflection.get(testReflection)._setmContextValue(contextValue + " changed");
BRTestReflection.get(testReflection)._set_mContextValue(contextValue + " changed");
Log.d(TAG, "mContextValue: " + BRTestReflection.get(testReflection).mContextValue());

Log.d(TAG, "============================");

// setStaticField
BRTestReflection.get()._setsStaticValue(staticValue + " changed");
BRTestReflection.get()._set_sStaticValue(staticValue + " changed");
Log.d(TAG, "sStaticValue: " + BRTestReflection.get().sStaticValue());

Log.d(TAG, "============================");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ public JavaFile generateInterfaceCode() {
}

private MethodSpec generateFieldSet(BlackReflectionInterfaceInfo reflection) {
MethodSpec.Builder method = MethodSpec.methodBuilder("_set" + reflection.getExecutableElement().getSimpleName().toString())
MethodSpec.Builder method = MethodSpec.methodBuilder("_set_" + reflection.getExecutableElement().getSimpleName().toString())
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.addParameter(ClassName.get("java.lang", "Object"), "value", Modifier.FINAL)
.addAnnotation(AnnotationSpec.builder(BFieldSetNotProcess.class).build());
return method.build();
}

private MethodSpec generateFieldCheck(BlackReflectionInterfaceInfo reflection) {
MethodSpec.Builder method = MethodSpec.methodBuilder("_check" + reflection.getExecutableElement().getSimpleName().toString())
MethodSpec.Builder method = MethodSpec.methodBuilder("_check_" + reflection.getExecutableElement().getSimpleName().toString())
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.addAnnotation(AnnotationSpec.builder(BFieldCheckNotProcess.class).build())
.returns(Field.class);
return method.build();
}

private MethodSpec generateMethodCheck(BlackReflectionInterfaceInfo reflection, List<ParameterSpec> parameterSpecs) {
MethodSpec.Builder method = MethodSpec.methodBuilder("_check" + reflection.getExecutableElement().getSimpleName().toString())
MethodSpec.Builder method = MethodSpec.methodBuilder("_check_" + reflection.getExecutableElement().getSimpleName().toString())
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.addAnnotation(AnnotationSpec.builder(BMethodCheckNotProcess.class).build())
.returns(Method.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
// void
BFieldSetNotProcess bFieldSetNotProcess = method.getAnnotation(BFieldSetNotProcess.class);
if (bFieldSetNotProcess != null) {
// startsWith "_set"
name = name.substring("_set".length());
// startsWith "_set_"
name = name.substring("_set_".length());
Reflector on = Reflector.on(aClass).field(name);
if (isStatic) {
on.set(args[0]);
Expand All @@ -113,8 +113,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
// check field
BFieldCheckNotProcess bFieldCheckNotProcess = method.getAnnotation(BFieldCheckNotProcess.class);
if (bFieldCheckNotProcess != null) {
// startsWith "check"
name = name.substring("_check".length());
// startsWith "_check_"
name = name.substring("_check_".length());
Reflector on = Reflector.on(aClass).field(name);
return on.getField();
}
Expand All @@ -124,8 +124,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
// check method
BMethodCheckNotProcess bMethodCheckNotProcess = method.getAnnotation(BMethodCheckNotProcess.class);
if (bMethodCheckNotProcess != null) {
// startsWith "_check"
name = name.substring("_check".length());
// startsWith "_check_"
name = name.substring("_check_".length());
Reflector on = Reflector.on(aClass).method(name, paramClass);
return on.getMethod();
}
Expand Down

0 comments on commit 67ee128

Please sign in to comment.