Skip to content

Commit

Permalink
Remove date from @Generated annotation and use the same name everyw…
Browse files Browse the repository at this point in the history
…here
  • Loading branch information
jwharm committed Feb 24, 2024
1 parent 71db85b commit 841a1b5
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public AliasGenerator(Alias alias) {

public TypeSpec generate() {
TypeSpec.Builder builder = TypeSpec.classBuilder(alias.typeName());
builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
builder.addAnnotation(GeneratedAnnotationBuilder.generate());

// Alias for an alias for a primitive type
if (target instanceof Alias other && other.type().isPrimitive())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public BitfieldGenerator(Bitfield bf) {
super(bf);
this.bf = bf;
this.builder = TypeSpec.classBuilder(bf.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ClassGenerator(Class cls) {
super(cls);
this.cls = cls;
this.builder = TypeSpec.classBuilder(cls.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TypeSpec generateFunctionalInterface() {
builder.addAnnotation(Deprecated.class);

if (closure instanceof Callback cb && cb.parent() instanceof Namespace)
builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
builder.addAnnotation(GeneratedAnnotationBuilder.generate());

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public EnumerationGenerator(Enumeration en) {
super(en);
this.en = en;
this.builder = TypeSpec.enumBuilder(en.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public InterfaceGenerator(Interface inf) {
super(inf);
this.inf = inf;
this.builder = TypeSpec.interfaceBuilder(inf.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class NamespaceGenerator {
public NamespaceGenerator(Namespace ns) {
this.ns = ns;
this.builder = TypeSpec.classBuilder(ns.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generateGlobalsClass() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RecordGenerator(Record rec) {
this.builder = TypeSpec.classBuilder(rec.typeName());

if (outerClass == null)
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public UnionGenerator(Union union) {
super(union);
this.union = union;
this.builder = TypeSpec.classBuilder(union.typeName());
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate(getClass()));
this.builder.addAnnotation(GeneratedAnnotationBuilder.generate());
}

public TypeSpec generate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@
import com.squareup.javapoet.AnnotationSpec;

import javax.annotation.processing.Generated;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class GeneratedAnnotationBuilder {

public static AnnotationSpec generate(Class<?> generator) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));

public static AnnotationSpec generate() {
var generatedAnnotation = AnnotationSpec.builder(Generated.class)
.addMember("value", "$S", generator.getName());
// .addMember("date", "$S", df.format(new Date()));
.addMember("value", "$S", "io.github.jwharm.JavaGI");

return generatedAnnotation.build();
}
Expand Down

0 comments on commit 841a1b5

Please sign in to comment.