krisztina-zsihovszki commented on code in PR #6861: URL: https://github.com/apache/nifi/pull/6861#discussion_r1082933702
########## 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: You are absolutely right, it'd be a nicer solution to use valueOf(). In the actual case the enum values already exist as AllowableValue's on processors with lower case values ("fail", "ignore", "replace"), we need to keep that naming. I am not fond of lower case enum names, would keep the HashMap instead. -- 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]
