jerryshao commented on code in PR #8644: URL: https://github.com/apache/gravitino/pull/8644#discussion_r2378744375
########## api/src/main/java/org/apache/gravitino/job/JobTemplateChange.java: ########## @@ -0,0 +1,701 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.job; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.apache.commons.lang3.StringUtils; + +/** + * The interface for job template changes. A job template change is an operation that modifies a job + * template. It can be one of the following: + * + * <ul> + * <li>Rename the job template. + * <li>Update the comment of the job template. + * <li>Update the job template details, such as executable, arguments, environments, custom + * fields, etc. + * </ul> + */ +public interface JobTemplateChange { + + /** + * Creates a new job template change to update the name of the job template. + * + * @param newName The new name of the job template. + * @return The job template change. + */ + static JobTemplateChange rename(String newName) { + return new RenameJobTemplate(newName); + } + + /** + * Creates a new job template change to update the comment of the job template. + * + * @param newComment The new comment of the job template. + * @return The job template change. + */ + static JobTemplateChange updateComment(String newComment) { + return new UpdateJobTemplateComment(newComment); + } + + /** + * Creates a new job template change to update the details of the job template. + * + * @param templateUpdate The job template update details. + * @return The job template change. + */ + static JobTemplateChange updateTemplate(TemplateUpdate templateUpdate) { + return new UpdateJobTemplate(templateUpdate); + } + + /** A job template change to rename the job template. */ + final class RenameJobTemplate implements JobTemplateChange { + private final String newName; + + private RenameJobTemplate(String newName) { + this.newName = newName; + } + + /** + * Get the new name of the job template. + * + * @return The new name of the job template. + */ + public String getNewName() { + return newName; + } + + /** + * Checks if this RenameJobTemplate is equal to another object. + * + * @param o The object to compare with. + * @return true if the objects are equal, false otherwise. + */ + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) return false; + RenameJobTemplate that = (RenameJobTemplate) o; + return Objects.equals(newName, that.newName); + } + + /** + * Generates a hash code for this RenameJobTemplate. + * + * @return The hash code. + */ + @Override + public int hashCode() { + return Objects.hash(newName); + } + + /** + * Get the string representation of the job template change. + * + * @return The string representation of the job template change. + */ + @Override + public String toString() { + return "RENAME JOB TEMPLATE " + newName; Review Comment: I aligned with other xxxChanges. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
