garydgregory commented on a change in pull request #47: URL: https://github.com/apache/commons-beanutils/pull/47#discussion_r550222552
########## File path: src/main/java/org/apache/commons/beanutils2/converters/ColorConverter.java ########## @@ -0,0 +1,216 @@ +/* + * 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.commons.beanutils2.converters; + +import java.awt.Color; +import java.util.Objects; + +/** + * <p>Converts a configuration property into a Java {@link Color} object.</p> + * + * <p> + * This converter aims to be compatible with some some of the web color + * formats supported by browsers with CSS, rather than only support + * literal interpretations of numbers, such as: + * </p> + * + * <ul> + * <li>#RGB</li> + * <li>#RGBA</li> + * <li>#RRGGBBAA</li> + * </ul> + * + * <p> + * This converter will use the web based hexadecimal interpretations if + * the value is prefixed with {@link #HEX_COLOR_PREFIX}. + * + * If using a literal number, or {@link Color#decode(String)} is desired, you must + * prefix your value with <code>0x</code> instead of {@link #HEX_COLOR_PREFIX}. + * </p> + * + * @since 2.0.0 + */ +public class ColorConverter extends AbstractConverter { + + /** To be a web based hexadecimal color, it must be prefixed with this. */ + private static final String HEX_COLOR_PREFIX = "#"; + + /** + * Construct a <b>{@link Color}</b> <i>Converter</i> that throws + * a {@code ConversionException} if an error occurs. + */ + public ColorConverter() { + super(); + } + + /** + * @param defaultValue The default value to be returned Review comment: Missing sentence in Javadoc: "Constructs...". See git master for `BooleanConverter` which I've just updated as an example. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
