Can "import org.parceler.Generated" be removed savely?

51 views Asked by At

I mean, imports generally don't effect code unless you use something that is unknown in the current file without giving the full qualified identifier, but this one seems weird to me. It's in a few files and is generally unused.

Can "import org.parceler.Generated" be removed savely? Is there any reason to keep it?

The part that stumps me is the word "Generated" here. It seems like this has to be or atleast should be kept, but I don't know why.

I suppose it's autoincluded when using some autogeneration tool, potentially even build into android-studio. But why is the "import org.parceler.Generated" line generated if the import is unused ?

1

There are 1 answers

0
John Ericksen On BEST ANSWER

If you're using Parceler, then it should be generating classes that look like the following:

@Generated(value = "org.parceler.ParcelAnnotationProcessor", date = "2016-09-03T09:53-0600")
@SuppressWarnings({
    "unchecked",
    "deprecation"
})
public class ParcelerTestModel$$Parcelable
    implements Parcelable, ParcelWrapper<org.parceler.test.ParcelerTestModel>
{
...

Notice the @Generated annotation. This requires the import you mentioned if the generated class it outside of the org.parceler package.

The @Generated annotation doesn't do much here. The intention behind this annotation is to demarcate generated code from user written code, following the JSR269 standard.

If you're taking the generated code out of the purview of the annotation processor and managing it yourself then you're free to remove this annotation. I wouldn't recommend this approach, however, as it's simply more boilerplate to manage which defeats the purpose of using a boilerplate-reducing solution like Parceler.