diff options
author | Éamonn McManus <emcmanus@google.com> | 2021-06-02 14:31:49 -0700 |
---|---|---|
committer | Google Java Core Libraries <java-libraries-firehose+copybara@google.com> | 2021-06-02 14:32:21 -0700 |
commit | 57fdeb9996af4b19466701cac5a69e917abf249e (patch) | |
tree | f3bc7ab585aaf9232c6cd7613d94657063ee1f1d /value/src/main/java/com | |
parent | de4033252036cc8d58bcfa6cf3099cd43da02ea1 (diff) | |
download | auto-57fdeb9996af4b19466701cac5a69e917abf249e.tar.gz |
Reformat all the Auto projects using google-java-format. For now, javadoc reformatting is excluded.
RELNOTES=n/a
PiperOrigin-RevId: 377145832
Diffstat (limited to 'value/src/main/java/com')
10 files changed, 44 insertions, 72 deletions
diff --git a/value/src/main/java/com/google/auto/value/AutoValue.java b/value/src/main/java/com/google/auto/value/AutoValue.java index 45a677c9..d7541f65 100644 --- a/value/src/main/java/com/google/auto/value/AutoValue.java +++ b/value/src/main/java/com/google/auto/value/AutoValue.java @@ -98,7 +98,7 @@ public @interface AutoValue { * <p>If you want to copy annotations from your {@literal @}AutoValue-annotated class's methods to * the generated fields in the AutoValue_... implementation, annotate your method * with {@literal @}AutoValue.CopyAnnotations. For example, if Example.java is:<pre> - + * * {@code @}Immutable * {@code @}AutoValue * abstract class Example { diff --git a/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizeExtension.java b/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizeExtension.java index 2cf0e7ad..acbe1c03 100644 --- a/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizeExtension.java +++ b/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizeExtension.java @@ -597,9 +597,7 @@ public final class MemoizeExtension extends AutoValueExtension { /** Translate a {@link TypeMirror} into a {@link TypeName}, including type annotations. */ private static TypeName annotatedType(TypeMirror type) { List<AnnotationSpec> annotations = - type.getAnnotationMirrors().stream() - .map(AnnotationSpec::get) - .collect(toList()); + type.getAnnotationMirrors().stream().map(AnnotationSpec::get).collect(toList()); return TypeName.get(type).annotated(annotations); } } diff --git a/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizedValidator.java b/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizedValidator.java index 1aa5976c..d250fbc6 100644 --- a/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizedValidator.java +++ b/value/src/main/java/com/google/auto/value/extension/memoized/processor/MemoizedValidator.java @@ -66,9 +66,7 @@ public final class MemoizedValidator extends AbstractProcessor { } private static boolean isAutoValue(Element element) { - return element - .getAnnotationMirrors() - .stream() + return element.getAnnotationMirrors().stream() .map(annotation -> MoreTypes.asTypeElement(annotation.getAnnotationType())) .anyMatch(type -> type.getQualifiedName().contentEquals("com.google.auto.value.AutoValue")); } diff --git a/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java index edfa41ce..3acf9332 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoAnnotationProcessor.java @@ -461,9 +461,7 @@ public class AutoAnnotationProcessor extends AbstractProcessor { } private static boolean isGwtCompatible(TypeElement annotationElement) { - return annotationElement - .getAnnotationMirrors() - .stream() + return annotationElement.getAnnotationMirrors().stream() .map(mirror -> mirror.getAnnotationType().asElement()) .anyMatch(element -> element.getSimpleName().contentEquals("GwtCompatible")); } diff --git a/value/src/main/java/com/google/auto/value/processor/AutoOneOfProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoOneOfProcessor.java index a1daebba..711b138c 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoOneOfProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoOneOfProcessor.java @@ -129,10 +129,8 @@ public class AutoOneOfProcessor extends AutoValueishProcessor { private DeclaredType mirrorForKindType(TypeElement autoOneOfType) { // The annotation is guaranteed to be present by the contract of Processor#process - AnnotationMirror oneOfAnnotation = - getAnnotationMirror(autoOneOfType, AUTO_ONE_OF_NAME).get(); - AnnotationValue kindValue = - AnnotationMirrors.getAnnotationValue(oneOfAnnotation, "value"); + AnnotationMirror oneOfAnnotation = getAnnotationMirror(autoOneOfType, AUTO_ONE_OF_NAME).get(); + AnnotationValue kindValue = AnnotationMirrors.getAnnotationValue(oneOfAnnotation, "value"); Object value = kindValue.getValue(); if (value instanceof TypeMirror) { TypeMirror kindType = (TypeMirror) value; @@ -159,9 +157,7 @@ public class AutoOneOfProcessor extends AutoValueishProcessor { Map<String, String> transformedPropertyNames = propertyNames.stream().collect(toMap(this::transformName, s -> s)); Map<String, Element> transformedEnumConstants = - kindElement - .getEnclosedElements() - .stream() + kindElement.getEnclosedElements().stream() .filter(e -> e.getKind().equals(ElementKind.ENUM_CONSTANT)) .collect(toMap(e -> transformName(e.getSimpleName().toString()), e -> e)); @@ -212,8 +208,7 @@ public class AutoOneOfProcessor extends AutoValueishProcessor { TypeMirror kindMirror, ImmutableSet<ExecutableElement> abstractMethods) { Set<ExecutableElement> kindGetters = - abstractMethods - .stream() + abstractMethods.stream() .filter(e -> sameType(kindMirror, e.getReturnType())) .filter(e -> e.getParameters().isEmpty()) .collect(toSet()); @@ -270,14 +265,15 @@ public class AutoOneOfProcessor extends AutoValueishProcessor { AutoOneOfTemplateVars vars, ImmutableMap<ExecutableElement, TypeMirror> propertyMethodsAndTypes, ExecutableElement kindGetter) { - vars.props = propertySet( - propertyMethodsAndTypes, ImmutableListMultimap.of(), ImmutableListMultimap.of()); + vars.props = + propertySet( + propertyMethodsAndTypes, ImmutableListMultimap.of(), ImmutableListMultimap.of()); vars.kindGetter = kindGetter.getSimpleName().toString(); vars.kindType = TypeEncoder.encode(kindGetter.getReturnType()); TypeElement javaIoSerializable = elementUtils().getTypeElement("java.io.Serializable"); vars.serializable = - javaIoSerializable != null // just in case - && typeUtils().isAssignable(type.asType(), javaIoSerializable.asType()); + javaIoSerializable != null // just in case + && typeUtils().isAssignable(type.asType(), javaIoSerializable.asType()); } @Override diff --git a/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java index acc01981..837fc573 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java @@ -220,8 +220,9 @@ public class AutoValueProcessor extends AutoValueishProcessor { ImmutableMap<String, ExecutableElement> properties = propertyNameToMethodMap(propertyMethodsAndTypes.keySet()); - ExtensionContext context = new ExtensionContext( - processingEnv, type, properties, propertyMethodsAndTypes, abstractMethods); + ExtensionContext context = + new ExtensionContext( + processingEnv, type, properties, propertyMethodsAndTypes, abstractMethods); ImmutableList<AutoValueExtension> applicableExtensions = applicableExtensions(type, context); ImmutableSet<ExecutableElement> consumedMethods = methodsConsumedByExtensions( @@ -234,8 +235,9 @@ public class AutoValueProcessor extends AutoValueishProcessor { propertyMethodsAndTypes = propertyMethodsIn(immutableSetDifference(abstractMethods, toBuilderMethods), type); properties = propertyNameToMethodMap(propertyMethodsAndTypes.keySet()); - context = new ExtensionContext( - processingEnv, type, properties, propertyMethodsAndTypes, allAbstractMethods); + context = + new ExtensionContext( + processingEnv, type, properties, propertyMethodsAndTypes, allAbstractMethods); } ImmutableSet<ExecutableElement> propertyMethods = propertyMethodsAndTypes.keySet(); diff --git a/value/src/main/java/com/google/auto/value/processor/AutoValueishProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoValueishProcessor.java index 1d6f0266..3f949f5b 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoValueishProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoValueishProcessor.java @@ -293,8 +293,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { @Override public boolean equals(Object obj) { - return obj instanceof GetterProperty - && ((GetterProperty) obj).method.equals(method); + return obj instanceof GetterProperty && ((GetterProperty) obj).method.equals(method); } @Override @@ -320,8 +319,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { } simpleAnnotationName = annotationType.getSimpleName().toString(); List<TypeElement> deferredTypes = - deferredTypeNames - .stream() + deferredTypeNames.stream() .map(name -> elementUtils().getTypeElement(name)) .collect(toList()); if (roundEnv.processingOver()) { @@ -444,9 +442,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { /** Defines the template variables that are shared by AutoValue, AutoOneOf, and AutoBuilder. */ final void defineSharedVarsForType( - TypeElement type, - ImmutableSet<ExecutableElement> methods, - AutoValueishTemplateVars vars) { + TypeElement type, ImmutableSet<ExecutableElement> methods, AutoValueishTemplateVars vars) { vars.pkg = TypeSimplifier.packageNameOf(type); vars.origClass = TypeSimplifier.classNameOf(type); vars.simpleClassName = TypeSimplifier.simpleNameOf(vars.origClass); @@ -727,8 +723,8 @@ abstract class AutoValueishProcessor extends AbstractProcessor { ObjectMethod override = objectMethodToOverride(method); boolean canGenerate = method.getModifiers().contains(Modifier.ABSTRACT) - || isJavaLangObject(MoreElements.asType(method.getEnclosingElement())); - if (!override.equals(ObjectMethod.NONE) && canGenerate) { + || isJavaLangObject(MoreElements.asType(method.getEnclosingElement())); + if (!override.equals(ObjectMethod.NONE) && canGenerate) { methodsToGenerate.put(override, method); } } @@ -796,8 +792,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { * {@code toString()}. */ ImmutableMap<ExecutableElement, TypeMirror> propertyMethodsIn( - Set<ExecutableElement> abstractMethods, - TypeElement autoValueOrOneOfType) { + Set<ExecutableElement> abstractMethods, TypeElement autoValueOrOneOfType) { DeclaredType declaredType = MoreTypes.asDeclared(autoValueOrOneOfType.asType()); ImmutableSet.Builder<ExecutableElement> properties = ImmutableSet.builder(); for (ExecutableElement method : abstractMethods) { @@ -823,7 +818,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { TypeMirror type = getter.getReturnType(); if (type.getKind() == TypeKind.ARRAY) { TypeMirror componentType = MoreTypes.asArray(type).getComponentType(); - if (componentType.getKind().isPrimitive()) { + if (componentType.getKind().isPrimitive()) { warnAboutPrimitiveArrays(autoValueClass, getter); } else { errorReporter.reportError( @@ -874,7 +869,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { @Override public Boolean visitArray(List<? extends AnnotationValue> list, Void p) { return list.stream().map(AnnotationValue::getValue).anyMatch("mutable"::equals); - } + } } /** @@ -983,8 +978,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { @SuppressWarnings("unchecked") List<AnnotationValue> excludedClasses = (List<AnnotationValue>) getAnnotationValue(maybeAnnotation.get(), "exclude").getValue(); - return excludedClasses - .stream() + return excludedClasses.stream() .map(annotationValue -> (DeclaredType) annotationValue.getValue()) .collect(toCollection(TypeMirrorSet::new)); } @@ -994,17 +988,14 @@ abstract class AutoValueishProcessor extends AbstractProcessor { * strings that are fully-qualified class names. */ private Set<String> getExcludedAnnotationClassNames(Element element) { - return getExcludedAnnotationTypes(element) - .stream() + return getExcludedAnnotationTypes(element).stream() .map(MoreTypes::asTypeElement) .map(typeElement -> typeElement.getQualifiedName().toString()) .collect(toSet()); } private static Set<String> getAnnotationsMarkedWithInherited(Element element) { - return element - .getAnnotationMirrors() - .stream() + return element.getAnnotationMirrors().stream() .filter(a -> isAnnotationPresent(a.getAnnotationType().asElement(), Inherited.class)) .map(a -> getAnnotationFqName(a)) .collect(toSet()); @@ -1071,9 +1062,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { Set<String> returnTypeAnnotations = getReturnTypeAnnotations(method, this::annotationAppliesToFields); Set<String> nonFieldAnnotations = - method - .getAnnotationMirrors() - .stream() + method.getAnnotationMirrors().stream() .map(a -> a.getAnnotationType().asElement()) .map(MoreElements::asType) .filter(a -> !annotationAppliesToFields(a)) @@ -1091,10 +1080,7 @@ abstract class AutoValueishProcessor extends AbstractProcessor { private Set<String> getReturnTypeAnnotations( ExecutableElement method, Predicate<TypeElement> typeFilter) { - return method - .getReturnType() - .getAnnotationMirrors() - .stream() + return method.getReturnType().getAnnotationMirrors().stream() .map(a -> a.getAnnotationType().asElement()) .map(MoreElements::asType) .filter(typeFilter) diff --git a/value/src/main/java/com/google/auto/value/processor/GwtCompatibility.java b/value/src/main/java/com/google/auto/value/processor/GwtCompatibility.java index 72207541..fae4e092 100644 --- a/value/src/main/java/com/google/auto/value/processor/GwtCompatibility.java +++ b/value/src/main/java/com/google/auto/value/processor/GwtCompatibility.java @@ -62,9 +62,7 @@ class GwtCompatibility { annotationArguments = ""; } else { annotationArguments = - getElementValues(annotation) - .entrySet() - .stream() + getElementValues(annotation).entrySet().stream() .map(e -> e.getKey().getSimpleName() + " = " + e.getValue()) .collect(joining(", ", "(", ")")); } diff --git a/value/src/main/java/com/google/auto/value/processor/GwtSerialization.java b/value/src/main/java/com/google/auto/value/processor/GwtSerialization.java index 8cd79433..30ad0926 100644 --- a/value/src/main/java/com/google/auto/value/processor/GwtSerialization.java +++ b/value/src/main/java/com/google/auto/value/processor/GwtSerialization.java @@ -99,9 +99,7 @@ class GwtSerialization { (vars.pkg.isEmpty() ? "" : vars.pkg + ".") + vars.subclass + "_CustomFieldSerializer"; vars.serializerClass = TypeSimplifier.simpleNameOf(className); vars.props = - autoVars.props.stream() - .map(p -> new Property((GetterProperty) p)) - .collect(toList()); + autoVars.props.stream().map(p -> new Property((GetterProperty) p)).collect(toList()); vars.classHashString = computeClassHash(autoVars.props, vars.pkg); String text = vars.toText(); text = TypeEncoder.decode(text, processingEnv, vars.pkg, type.asType()); @@ -110,11 +108,11 @@ class GwtSerialization { } public static class Property { - private final GetterProperty property; - private final boolean isCastingUnchecked; + private final GetterProperty property; + private final boolean isCastingUnchecked; - Property(GetterProperty property) { - this.property = property; + Property(GetterProperty property) { + this.property = property; this.isCastingUnchecked = TypeSimplifier.isCastingUnchecked(property.getTypeMirror()); } @@ -255,8 +253,8 @@ class GwtSerialization { // Compute a hash that is guaranteed to change if the names, types, or order of the fields // change. We use TypeEncoder so that we can get a defined string for types, since // TypeMirror.toString() isn't guaranteed to remain the same. - private String computeClassHash(Iterable<AutoValueishProcessor.Property> props, String pkg) { - CRC32 crc = new CRC32(); + private String computeClassHash(Iterable<AutoValueishProcessor.Property> props, String pkg) { + CRC32 crc = new CRC32(); String encodedType = TypeEncoder.encode(type.asType()) + ":"; String decodedType = TypeEncoder.decode(encodedType, processingEnv, "", null); if (!decodedType.startsWith(pkg)) { @@ -265,8 +263,8 @@ class GwtSerialization { decodedType = pkg + "." + decodedType; } crc.update(decodedType.getBytes(UTF_8)); - for (AutoValueishProcessor.Property prop : props) { - String encodedProp = prop + ":" + TypeEncoder.encode(prop.getTypeMirror()) + ";"; + for (AutoValueishProcessor.Property prop : props) { + String encodedProp = prop + ":" + TypeEncoder.encode(prop.getTypeMirror()) + ";"; String decodedProp = TypeEncoder.decode(encodedProp, processingEnv, pkg, null); crc.update(decodedProp.getBytes(UTF_8)); } diff --git a/value/src/main/java/com/google/auto/value/processor/TypeSimplifier.java b/value/src/main/java/com/google/auto/value/processor/TypeSimplifier.java index 290e59e0..e7bab774 100644 --- a/value/src/main/java/com/google/auto/value/processor/TypeSimplifier.java +++ b/value/src/main/java/com/google/auto/value/processor/TypeSimplifier.java @@ -140,8 +140,7 @@ final class TypeSimplifier { if (typeParameters.isEmpty()) { return ""; } else { - return typeParameters - .stream() + return typeParameters.stream() .map(e -> e.getSimpleName().toString()) .collect(joining(", ", "<", ">")); } @@ -264,8 +263,7 @@ final class TypeSimplifier { * {@code Map.Entry} everywhere rather than {@code Entry}. */ private static Set<TypeMirror> topLevelTypes(Types typeUtil, Set<TypeMirror> types) { - return types - .stream() + return types.stream() .map(typeMirror -> MoreElements.asType(typeUtil.asElement(typeMirror))) .map(typeElement -> topLevelType(typeElement).asType()) .collect(toCollection(TypeMirrorSet::new)); |