com.google.auto.value.AutoValue Java Examples
The following examples show how to use
com.google.auto.value.AutoValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoCodecProcessor.java From bazel with Apache License 2.0 | 6 votes |
private TypeSpec.Builder buildClassWithInstantiatorStrategy( TypeElement encodedType, AutoCodec annotation) throws SerializationProcessingFailedException { ExecutableElement constructor = selectInstantiator(encodedType); List<? extends VariableElement> fields = constructor.getParameters(); TypeSpec.Builder codecClassBuilder = AutoCodecUtil.initializeCodecClassBuilder(encodedType, env); if (encodedType.getAnnotation(AutoValue.class) == null) { initializeUnsafeOffsets(codecClassBuilder, encodedType, fields); codecClassBuilder.addMethod( buildSerializeMethodWithInstantiator(encodedType, fields, annotation)); } else { codecClassBuilder.addMethod( buildSerializeMethodWithInstantiatorForAutoValue(encodedType, fields, annotation)); } MethodSpec.Builder deserializeBuilder = AutoCodecUtil.initializeDeserializeMethodBuilder(encodedType, env); buildDeserializeBody(deserializeBuilder, fields); addReturnNew(deserializeBuilder, encodedType, constructor, /*builderVar=*/ null, env); codecClassBuilder.addMethod(deserializeBuilder.build()); return codecClassBuilder; }
Example #2
Source File: EncodableProcessor.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private Optional<TypeSpec> autoValueSupport( String rootPackageName, String containingClassName, Encoder encoder, MethodSpec.Builder configureMethod) { Element element = types.asElement(encoder.type()); AutoValue autoValue = element.getAnnotation(AutoValue.class); if (autoValue == null) { return Optional.empty(); } String typePackageName = Names.packageName(element); ClassName autoValueClass = ClassName.get( typePackageName, Names.autoValueClassName(types.asElement(types.erasure(encoder.type())))); if (rootPackageName.equals(typePackageName)) { configureMethod.addCode( "cfg.registerEncoder($T.class, $N.INSTANCE);\n", autoValueClass, encoder.code()); return Optional.empty(); } // the generated class has a rather long name but provides uniqueness guarantees. TypeSpec supportClass = TypeSpec.classBuilder( String.format( "Encodable%s%s%sAutoValueSupport", packageNameToCamelCase(rootPackageName), containingClassName, Names.generatedClassName(element))) .addModifiers(Modifier.FINAL, Modifier.PUBLIC) .addField( FieldSpec.builder( ParameterizedTypeName.get( ClassName.get(Class.class), WildcardTypeName.subtypeOf(TypeName.get(encoder.type()))), "TYPE", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("$T.class", autoValueClass) .build()) .build(); configureMethod.addCode( "cfg.registerEncoder($L.$N.TYPE, $N.INSTANCE);\n", typePackageName, supportClass, encoder.code()); return Optional.of(supportClass); }
Example #3
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @NonNull @PrimaryKey @ColumnInfo(name = "id") public abstract String getId();
Example #4
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @NonNull @ColumnInfo(name = "state") public abstract OfflineAreaEntityState getState();
Example #5
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @ColumnInfo(name = "north") public abstract double getNorth();
Example #6
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @ColumnInfo(name = "south") public abstract double getSouth();
Example #7
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @ColumnInfo(name = "east") public abstract double getEast();
Example #8
Source File: OfflineAreaEntity.java From ground-android with Apache License 2.0 | 4 votes |
@AutoValue.CopyAnnotations @ColumnInfo(name = "west") public abstract double getWest();
Example #9
Source File: BazelModuleContext.java From bazel with Apache License 2.0 | 2 votes |
/** * Transitive digest of the .bzl file of the {@link com.google.devtools.build.lib.syntax.Module} * itself and all files it transitively loads. */ @SuppressWarnings({"AutoValueImmutableFields", "mutable"}) @AutoValue.CopyAnnotations public abstract byte[] bzlTransitiveDigest();