private Optional<Element> parentPkg(PackageElement elt) { int lastDot = elt.getQualifiedName().toString().lastIndexOf('.'); return (lastDot == -1) ? Optional.empty() : unNull(Elts.getPackageElement(elt.getQualifiedName().subSequence(0, lastDot))); }
private Optional<Element> parentPkg(PackageElement elt) { int lastDot = elt.getQualifiedName().toString().lastIndexOf('.'); return (lastDot == -1) ? Optional.empty() : unNull(Elts.getPackageElement(elt.getQualifiedName().subSequence(0, lastDot))); }
private String stripPrefixFromMethod(ExecutableElement element) { Name name = element.getSimpleName(); CharSequence propertyName; if (isGetter(element) || isSetter(element)) { propertyName = name.subSequence(3, name.length()); } else if (isBooleanGetter(element)) { propertyName = name.subSequence(2, name.length()); } else { L.e("@Bindable associated with method must follow JavaBeans convention %s", element); return null; } char firstChar = propertyName.charAt(0); return "" + Character.toLowerCase(firstChar) + propertyName.subSequence(1, propertyName.length()); }
private static String stripPrefixFromField(VariableElement element) { Name name = element.getSimpleName(); if (name.length() >= 2) { char firstChar = name.charAt(0); char secondChar = name.charAt(1); if (name.length() > 2 && firstChar == 'm' && secondChar == '_') { char thirdChar = name.charAt(2); if (Character.isJavaIdentifierStart(thirdChar)) { return "" + Character.toLowerCase(thirdChar) + name.subSequence(3, name.length()); } } else if ((firstChar == 'm' && Character.isUpperCase(secondChar)) || (firstChar == '_' && Character.isJavaIdentifierStart(secondChar))) { return "" + Character.toLowerCase(secondChar) + name.subSequence(2, name.length()); } } return name.toString(); }
final Name methodName = el.getSimpleName(); String propertyName = null; if (methodName.length() > 3 && "get".contentEquals(methodName.subSequence(0, 3))) { final StringBuilder sb = new StringBuilder(methodName.length() - 3); sb.append(Character.toLowerCase(methodName.charAt(3))); sb.append(methodName.subSequence(4, methodName.length())); propertyName = sb.toString(); else if (methodName.length() > 2 && "is".contentEquals(methodName.subSequence(0, 2))) { final StringBuilder sb = new StringBuilder(methodName.length() - 2); sb.append(Character.toLowerCase(methodName.charAt(2))); sb.append(methodName.subSequence(3, methodName.length())); propertyName = sb.toString(); else if (methodName.length() > 3 && "set".contentEquals(methodName.subSequence(0, 2))) { final StringBuilder sb = new StringBuilder(methodName.length() - 3); sb.append(Character.toLowerCase(methodName.charAt(3))); sb.append(methodName.subSequence(4, methodName.length())); propertyName = sb.toString();
private void addTagAttributesFromParent(Tag tag, TypeElement type) { for (ExecutableElement method : ElementFilter.methodsIn(processingEnv.getElementUtils().getAllMembers(type))) { AnnotationMirror annotation = getAnnotation(method, TAG_ATTRIBUTE); if (method.getModifiers().contains(Modifier.PUBLIC) && annotation != null) { String name = String.valueOf(Character.toLowerCase(method.getSimpleName() .charAt(3))) + method.getSimpleName().subSequence(4, method.getSimpleName().length()); if (!tag.getSkipAttributes().contains(name)) { Map<String, Object> values = new HashMap<>(); for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : processingEnv.getElementUtils().getElementValuesWithDefaults(annotation).entrySet()) { values.put(entry.getKey().getSimpleName().toString(), entry.getValue().getValue()); } TagAttribute attribute = new TagAttribute(); populateTagAttributes(attribute, values); attribute.setName(name); tag.addTagAttribute(attribute); } } } }