Last active
March 25, 2018 20:32
-
-
Save ChaitanyaPramod/273dc67dc2cb853a01c87e67c8f87b77 to your computer and use it in GitHub Desktop.
Demystifying Butterknife
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void parseBindView(Element element, Map<TypeElement, BindingSet.Builder> builderMap, | |
Set<TypeElement> erasedTargetNames) { | |
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); | |
... | |
// Assemble information on the field. | |
int id = element.getAnnotation(BindView.class).value(); | |
BindingSet.Builder builder = builderMap.get(enclosingElement); | |
QualifiedId qualifiedId = elementToQualifiedId(element, id); | |
if (builder != null) { | |
String existingBindingName = builder.findExistingBindingName(getId(qualifiedId)); | |
... | |
} else { | |
builder = getOrCreateBindingBuilder(builderMap, enclosingElement); | |
} | |
String name = simpleName.toString(); | |
TypeName type = TypeName.get(elementType); | |
boolean required = isFieldRequired(element); | |
builder.addField(getId(qualifiedId), new FieldViewBinding(name, type, required)); | |
// Add the type-erased version to the valid binding targets set. | |
erasedTargetNames.add(enclosingElement); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment