com.kobylynskyi.graphql.codegen.model.GeneratedInformation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-codegen Show documentation
Show all versions of graphql-java-codegen Show documentation
Java Code Generator based on GraphQL schema
The newest version!
package com.kobylynskyi.graphql.codegen.model;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.function.Supplier;
public class GeneratedInformation {
public static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
private Supplier dateTimeSupplier;
private final String generatedType;
public GeneratedInformation() {
this(ZonedDateTime::now);
}
public GeneratedInformation(Supplier dateTimeSupplier) {
this.dateTimeSupplier = dateTimeSupplier;
this.generatedType = initGeneratedType();
}
public void setDateTimeSupplier(Supplier dateTimeSupplier) {
this.dateTimeSupplier = dateTimeSupplier;
}
public String getGeneratedType() {
return generatedType;
}
public String getDateTime() {
return DATE_TIME_FORMAT.format(dateTimeSupplier.get());
}
private static String initGeneratedType() {
try {
return Class.forName("javax.annotation.processing.Generated").getCanonicalName();
} catch (ClassNotFoundException ignored1) {
try {
return Class.forName("javax.annotation.Generated").getCanonicalName();
} catch (ClassNotFoundException ignored2) {
// class is not available
}
}
return null;
}
}