Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JavaBeans-style name prefixes #48

Open
DanielHeckrath opened this issue Jul 5, 2016 · 0 comments
Open

Support JavaBeans-style name prefixes #48

DanielHeckrath opened this issue Jul 5, 2016 · 0 comments

Comments

@DanielHeckrath
Copy link

AutoValue strips JavaBeans prefixes (get-, is-) from constructor parameter names if the annotated class uses it consistently (see AutoValue HowTo). AutoParcel ignores this and uses the full property name in the generated constructor.
It would be nice if AutoParcel would use the same naming for it's constructor parameter names.

Sample

User.java

package com.example;

import android.os.Parcelable;

import com.google.auto.value.AutoValue;

@AutoValue
public abstract class User implements Parcelable {
    public abstract String getId();
    public abstract String getName();
}

$AutoValue_User.java (generated by AutoValue)

package com.example;

import javax.annotation.Generated;

@Generated("com.google.auto.value.processor.AutoValueProcessor")
 abstract class $AutoValue_User extends User {

  private final String id;
  private final String name;

  $AutoValue_User(
      String id,
      String name) {
    if (id == null) {
      throw new NullPointerException("Null id");
    }
    this.id = id;
    if (name == null) {
      throw new NullPointerException("Null name");
    }
    this.name = name;
  }

  @Override
  public String getId() {
    return id;
  }

  @Override
  public String getName() {
    return name;
  }

  ...

}

AutoValue_User.java (generated by AutoParcel)

package com.example;

import android.os.Parcel;
import android.os.Parcelable;
import java.lang.ClassLoader;

final class AutoValue_User extends $AutoValue_User {

  private final static ClassLoader CL = AutoValue_User.class.getClassLoader();

  public AutoValue_User (
    java.lang.String getId,
    java.lang.String getName
  ) {
    super(
      getId,
      getName
    );
  }

  ...

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant