dan-s1 commented on code in PR #8417: URL: https://github.com/apache/nifi/pull/8417#discussion_r1491624067
########## nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/encoding/EncodingMode.java: ########## @@ -0,0 +1,56 @@ +/* + * 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.standard.encoding; + +import org.apache.nifi.components.DescribedValue; + +public enum EncodingMode implements DescribedValue { + + ENCODE { + @Override + public String getValue() { + return "encode"; + } + + @Override + public String getDisplayName() { + return "Encode"; + } + + @Override + public String getDescription() { + return "Sets the operation mode to 'encode'."; + } + }, + + DECODE { + @Override + public String getValue() { + return "decode"; + } + + @Override + public String getDisplayName() { + return "Decode"; + } + + @Override + public String getDescription() { + return "Sets the operation mode to 'decode'."; + } + } +} Review Comment: While how you defined this enum is not incorrect it is not the standard way enums which extend `DescribedValue` are implemented in the code base. I will demonstrate for this class and similar changes should be made for the `EncodingType` and `LineOutputMode` classes. For the `value` you can use `name()` method which should simplify your if statements and obviate the need to use `equalIgnoreCase`. ```suggestion public enum EncodingMode implements DescribedValue { ENCODE("Encode", "Sets the operation mode to 'encode'."), DECODE("Decode", "Sets the operation mode to 'decode'."); EncodingMode(String displayName, String description) { this.displayName = displayName; this.description = description; } private final String displayName; private final String description; @Override public String getValue() { return name(); } @Override public String getDisplayName() { return displayName; } @Override public String getDescription() { return description; } } ``` -- 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]
