Skip to content

Commit

Permalink
Release the SerializableAutoValue extension.
Browse files Browse the repository at this point in the history
RELNOTES=Release the SerializableAutoValue extension.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=304211473
  • Loading branch information
alvinlao authored and cpovirk committed Apr 10, 2020
1 parent e4ab0e7 commit f91d2fe
Show file tree
Hide file tree
Showing 28 changed files with 2,296 additions and 3 deletions.
1 change: 1 addition & 0 deletions value/annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<includes>
<include>com/google/auto/value/*</include>
<include>com/google/auto/value/extension/memoized/*</include>
<include>com/google/auto/value/extension/serializable/*</include>
</includes>
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion value/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
Expand Down
8 changes: 8 additions & 0 deletions value/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
<artifactId>compile-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -141,6 +147,8 @@
<includes>
<include>com/google/auto/value/processor/**/*.java</include>
<include>com/google/auto/value/extension/memoized/processor/**/*.java</include>
<include>com/google/auto/value/extension/serializable/processor/**/*.java</include>
<include>com/google/auto/value/extension/serializable/serializer/**/*.java</include>
</includes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.auto.value.extension.serializable;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotates {@link com.google.auto.value.AutoValue @AutoValue} classes that implement {@link
* java.io.Serializable}. A serializable subclass is generated for classes with normally
* un-serializable fields like {@link java.util.Optional}.
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface SerializableAutoValue {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.auto.value.extension.serializable.processor;

/** Names of classes that are referenced in /processor. */
final class ClassNames {
static final String SERIALIZABLE_AUTO_VALUE_NAME =
"com.google.auto.value.extension.serializable.SerializableAutoValue";

private ClassNames() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.auto.value.extension.serializable.processor;

import javax.lang.model.type.TypeMirror;

/**
* A POJO containing information about an AutoValue's property.
*
* <p>For example, given this AutoValue property: <code>abstract T getX();</code>
*
* <ol>
* <li>The type would be T.
* <li>The name would be x.
* <li>The method would be getX.
*/
final class PropertyMirror {

private final TypeMirror type;
private final String name;
private final String method;

PropertyMirror(TypeMirror type, String name, String method) {
this.type = type;
this.name = name;
this.method = method;
}

/** Gets the AutoValue property's type. */
TypeMirror getType() {
return type;
}

/** Gets the AutoValue property's name. */
String getName() {
return name;
}

/** Gets the AutoValue property accessor method. */
String getMethod() {
return method;
}
}
Loading

0 comments on commit f91d2fe

Please sign in to comment.