nandorsoma commented on code in PR #6861: URL: https://github.com/apache/nifi/pull/6861#discussion_r1082793187
########## nifi-nar-bundles/nifi-extension-utils/nifi-conflict-resolution/src/main/java/org/apache/nifi/processors/conflictresolution/ConflictResolutionStrategy.java: ########## @@ -0,0 +1,64 @@ +/* + * 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.nifi.processors.conflictresolution; + +import java.util.HashMap; +import java.util.Map; +import org.apache.nifi.components.DescribedValue; + +public enum ConflictResolutionStrategy implements DescribedValue { + FAIL("fail", "fail", "Handle file conflict as failure."), + IGNORE("ignore", "ignore", "Ignore conflict, do not change the original file."), + REPLACE("replace", "replace", "Replace existing file in case of conflict."); + + private static final Map<String, ConflictResolutionStrategy> ENUM_MAP = new HashMap<>(); + + static { + for (ConflictResolutionStrategy strategy : ConflictResolutionStrategy.values()) { + ENUM_MAP.put(strategy.getValue(), strategy); + } + } + + private final String value; Review Comment: I think we don't need an additional value field since in an enum the entry is a value in itself. Without that, we can leverage the default `valueOf()` method, and we won't need the extra HashMap. An example of how it was used in another case: https://github.com/apache/nifi/blob/a71556f115af551e40f0004694dfe82a7d86535a/nifi-nar-bundles/nifi-azure-bundle/nifi-azure-services-api/src/main/java/org/apache/nifi/services/azure/storage/AzureStorageConflictResolutionStrategy.java#L21 -- 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]
