private static @Nullable Unbinder parseBindFloat(Object target, Field field, View source) { BindFloat bindInt = field.getAnnotation(BindFloat.class); if (bindInt == null) { return null; } validateMember(field); int id = bindInt.value(); Context context = source.getContext(); Class<?> fieldType = field.getType(); Object value; if (fieldType == float.class) { value = Utils.getFloat(context, id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
private void parseResourceFloat(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is float. if (element.asType().getKind() != TypeKind.FLOAT) { error(element, "@%s field type must be 'float'. (%s.%s)", BindFloat.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindFloat.class, "fields", element); hasError |= isBindingInWrongPackage(BindFloat.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindFloat.class).value(); Id resourceId = elementToId(element, BindFloat.class, id); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource( new FieldResourceBinding(resourceId, name, FieldResourceBinding.Type.FLOAT)); erasedTargetNames.add(enclosingElement); }
private void parseResourceFloat(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is float. if (element.asType().getKind() != TypeKind.FLOAT) { error(element, "@%s field type must be 'float'. (%s.%s)", BindFloat.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindFloat.class, "fields", element); hasError |= isBindingInWrongPackage(BindFloat.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindFloat.class).value(); Id resourceId = elementToId(element, BindFloat.class, id); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource( new FieldResourceBinding(resourceId, name, FieldResourceBinding.Type.FLOAT)); erasedTargetNames.add(enclosingElement); }