butterknife.compiler.Id Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of butterknife-compiler Show documentation
Show all versions of butterknife-compiler Show documentation
Field and method binding for Android views.
package butterknife.compiler;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
/**
* Represents an ID of an Android resource.
*/
final class Id {
private static final ClassName ANDROID_R = ClassName.get("android", "R");
final int value;
final CodeBlock code;
final boolean qualifed;
Id(int value) {
this.value = value;
this.code = CodeBlock.of("$L", value);
this.qualifed = false;
}
Id(int value, ClassName className, String resourceName) {
this.value = value;
this.code = className.topLevelClassName().equals(ANDROID_R)
? CodeBlock.of("$L.$N", className, resourceName)
: CodeBlock.of("$T.$N", className, resourceName);
this.qualifed = true;
}
@Override public boolean equals(Object o) {
return o instanceof Id && value == ((Id) o).value;
}
@Override public int hashCode() {
return value;
}
@Override public String toString() {
throw new UnsupportedOperationException("Please use value or code explicitly");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy