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

[Improvement] Remove warnings when compiling Gravitino #4470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/src/main/java/org/apache/gravitino/dto/AuditDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private Builder() {}
* @param creator The creator of the audit.
* @return The builder instance.
*/
@SuppressWarnings("unchecked")
public S withCreator(String creator) {
this.creator = creator;
return (S) this;
Expand All @@ -123,6 +124,7 @@ public S withCreator(String creator) {
* @param createTime The create time of the audit.
* @return The builder instance.
*/
@SuppressWarnings("unchecked")
public S withCreateTime(Instant createTime) {
this.createTime = createTime;
return (S) this;
Expand All @@ -134,6 +136,7 @@ public S withCreateTime(Instant createTime) {
* @param lastModifier The last modifier of the audit.
* @return The builder instance.
*/
@SuppressWarnings("unchecked")
public S withLastModifier(String lastModifier) {
this.lastModifier = lastModifier;
return (S) this;
Expand All @@ -145,6 +148,7 @@ public S withLastModifier(String lastModifier) {
* @param lastModifiedTime The last modified time of the audit.
* @return The builder instance.
*/
@SuppressWarnings("unchecked")
public S withLastModifiedTime(Instant lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
return (S) this;
Expand Down
106 changes: 10 additions & 96 deletions common/src/main/java/org/apache/gravitino/dto/CatalogDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,61 +81,31 @@ protected CatalogDTO(
this.audit = audit;
}

/**
* Get the name of the catalog.
*
* @return The name of the catalog.
*/
@Override
public String name() {
return name;
}

/**
* Get the type of the catalog.
*
* @return The type of the catalog.
*/
@Override
public Type type() {
return type;
}

/**
* Get the provider of the catalog.
*
* @return The provider of the catalog.
*/
@Override
public String provider() {
return provider;
}

/**
* Get the comment of the catalog.
*
* @return The comment of the catalog.
*/
@Override
public String comment() {
return comment;
}

/**
* Get the properties of the catalog.
*
* @return The properties of the catalog.
*/
@Override
public Map<String, String> properties() {
return properties;
}

/**
* Get the audit information of the catalog.
*
* @return The audit information of the catalog.
*/
@Override
public Audit auditInfo() {
return audit;
Expand All @@ -146,114 +116,58 @@ public Audit auditInfo() {
*
* @param <S> The type of the builder instance.
*/
public static class Builder<S extends Builder> {

/** The name of the catalog. */
protected String name;

/** The type of the catalog. */
protected Type type;

/** The provider of the catalog. */
protected String provider;

/** The comment of the catalog. */
protected String comment;

/** The properties of the catalog. */
protected Map<String, String> properties;
public static class Builder<S extends Builder<S>> {

/** The audit information of the catalog. */
protected AuditDTO audit;
private String name;
private Type type;
private String provider;
private String comment;
private Map<String, String> properties;
private AuditDTO audit;

/** Default constructor for the builder. */
protected Builder() {}

/**
* Sets the name of the catalog.
*
* @param name The name of the catalog.
* @return The builder instance.
*/
public S withName(String name) {
this.name = name;
return (S) this;
}

/**
* Sets the type of the catalog.
*
* @param type The type of the catalog.
* @return The builder instance.
*/
public S withType(Type type) {
this.type = type;
return (S) this;
}

/**
* Sets the provider of the catalog.
*
* @param provider The provider of the catalog.
* @return The builder instance.
*/
public S withProvider(String provider) {
this.provider = provider;
return (S) this;
}

/**
* Sets the comment of the catalog.
*
* @param comment The comment of the catalog.
* @return The builder instance.
*/
public S withComment(String comment) {
this.comment = comment;
return (S) this;
}

/**
* Sets the properties of the catalog.
*
* @param properties The properties of the catalog.
* @return The builder instance.
*/
public S withProperties(Map<String, String> properties) {
this.properties = properties;
return (S) this;
}

/**
* Sets the audit information of the catalog.
*
* @param audit The audit information of the catalog.
* @return The builder instance.
*/
public S withAudit(AuditDTO audit) {
this.audit = audit;
return (S) this;
}

/**
* Builds an instance of CatalogDTO using the builder's properties.
*
* @return An instance of CatalogDTO.
* @throws IllegalArgumentException If name, type or audit are not set.
*/
public CatalogDTO build() {
Preconditions.checkArgument(StringUtils.isNotBlank(name), "name cannot be null or empty");
Preconditions.checkArgument(type != null, "type cannot be null");
Preconditions.checkArgument(
StringUtils.isNotBlank(provider), "provider cannot be null or empty");
Preconditions.checkArgument(StringUtils.isNotBlank(provider), "provider cannot be null or empty");
Preconditions.checkArgument(audit != null, "audit cannot be null");

return new CatalogDTO(name, type, provider, comment, properties, audit);
}
}

/** @return the builder for creating a new instance of CatalogDTO. */
public static Builder builder() {
return new Builder();
public static Builder<?> builder() {
return new Builder<>();
}
}
11 changes: 4 additions & 7 deletions common/src/main/java/org/apache/gravitino/dto/MetalakeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Audit auditInfo() {
*
* @param <S> The type of the builder subclass.
*/
public static class Builder<S extends Builder> {
public static class Builder<S extends Builder<S>> {

/** The name of the Metalake DTO. */
protected String name;
Expand Down Expand Up @@ -186,25 +186,22 @@ private boolean propertyEqual(Map<String, String> p1, Map<String, String> p2) {
if (p1 == null && p2 == null) {
return true;
}

if (p1 != null && p1.isEmpty() && p2 == null) {
return true;
}

if (p2 != null && p2.isEmpty() && p1 == null) {
return true;
}

return java.util.Objects.equals(p1, p2);
}

@Override
public int hashCode() {
return Objects.hashCode(name, comment, audit);
return Objects.hashCode(name, comment, properties, audit);
}

/** @return the builder for creating a new instance of MetalakeDTO. */
public static Builder builder() {
return new Builder();
public static Builder<?> builder() {
return new Builder<>();
}
}
11 changes: 8 additions & 3 deletions common/src/main/java/org/apache/gravitino/dto/SchemaDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SchemaDTO implements Schema {
@JsonProperty("audit")
private AuditDTO audit;

/** Default constructor for Jackson deserialization. */
private SchemaDTO() {}

/**
Expand Down Expand Up @@ -86,13 +87,17 @@ public AuditDTO auditInfo() {
*
* @param <S> The type of the builder subclass.
*/
public static class Builder<S extends Builder> {
public static class Builder<S extends Builder<S>> {

/** The name of the schema. */
protected String name;

/** The comment associated with the schema. */
protected String comment;

/** The properties associated with the schema. */
protected Map<String, String> properties;

/** The audit information for the schema. */
protected AuditDTO audit;

Expand Down Expand Up @@ -158,7 +163,7 @@ public SchemaDTO build() {
}

/** @return the builder for creating a new instance of SchemaDTO. */
public static Builder builder() {
return new Builder();
public static Builder<?> builder() {
return new Builder<>();
}
}
Loading