garydgregory commented on code in PR #271: URL: https://github.com/apache/commons-validator/pull/271#discussion_r1795363914
########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class Review Comment: Not a helpful comment. Sentences end in a period. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format + */ + public Validator(String[] formats) { + this.validator = new RegexValidator(formats); + } + } + + /** The singleton instance which uses the default formats */ + public static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator(); + + /** + * Return a singleton instance of the SIRENE validator using the default formats Review Comment: The conventions I use are a getter "Gets...", a constructor "Constructs...", a setter "Sets..." and so on. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. Review Comment: Here, I would spell out "FR", not everyone knows their country codes like they should ;-) ########## src/main/java/org/apache/commons/validator/routines/checkdigit/VATidFRCheckDigit.java: ########## @@ -0,0 +1,198 @@ +/* + * 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.validator.routines.checkdigit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.SireneValidator; + +/** + * French VAT identification number (VATIN) Check Digit calculation/validation. + * <p> + * le numéro d’identification à la taxe sur la valeur ajoutée (no TVA) + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/VAT_identification_number">Wikipedia - VAT IN</a> + * for more details. + * </p> + * + * @since 1.10.0 + */ +public final class VATidFRCheckDigit extends ModulusCheckDigit { + + private static final long serialVersionUID = -4684483629166798828L; + private static final Log LOG = LogFactory.getLog(VATidFRCheckDigit.class); + + /** Singleton Check Digit instance */ + private static final VATidFRCheckDigit INSTANCE = new VATidFRCheckDigit(); + + /** + * Gets the singleton instance of this validator. + * @return A singleton instance of the class. + */ + public static CheckDigit getInstance() { + return INSTANCE; + } + + static final int LEN = 11; // with Check Digit + static final int CHECKDIGIT_LEN = 2; + + private static final String ALPHABET = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"; + private static final int MODULUS_97 = 97; + private static final SireneValidator SIRENE_VALIDATOR = SireneValidator.getInstance(); + + /** + * Constructs a Check Digit routine. Review Comment: Not helpful IMO. Also, there is no "routine" concept in Java, this constructs a new instance if anything ;-) ########## src/main/java/org/apache/commons/validator/routines/checkdigit/VATidBGCheckDigit.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.validator.routines.checkdigit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.DateValidator; + +/** + * Bulgarian VAT identification number (VATIN) Check Digit calculation/validation. + * <p> + * Dank dobawena stoinost (DDS) + * The Bulgarian VAT (Данък върху добавената стойност) number is either 9 (for legal entities) + * or 10 digits long (ЕГН for physical persons, foreigners and others). + * Each type of number has its own check digit algorithm. + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/VAT_identification_number">Wikipedia VATIN</a> + * and <a href="https://en.wikipedia.org/wiki/Unique_citizenship_number">ЕГН (civil number)</a> + * for more details. + * </p> + * + * @since 1.10.0 + */ +public final class VATidBGCheckDigit extends ModulusCheckDigit { + + private static final long serialVersionUID = -8667365895223831325L; + private static final Log LOG = LogFactory.getLog(VATidBGCheckDigit.class); + + /** Singleton Check Digit instance */ + private static final VATidBGCheckDigit INSTANCE = new VATidBGCheckDigit(); + + /** + * Gets the singleton instance of this validator. + * @return A singleton instance of the class. + */ + public static CheckDigit getInstance() { + return INSTANCE; + } + + /** + * there ate three length Review Comment: Sentences start with a capital letter. If you expect the comment below to be renders line by line, use a `ol` or `ul` HTML tag. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format + */ + public Validator(String[] formats) { + this.validator = new RegexValidator(formats); + } + } + + /** The singleton instance which uses the default formats */ + public static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator(); + + /** + * Return a singleton instance of the SIRENE validator using the default formats + * + * @return A singleton instance of the validator Review Comment: IMO "The singleton...", since there is one. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format + */ + public Validator(String[] formats) { + this.validator = new RegexValidator(formats); + } + } + + /** The singleton instance which uses the default formats */ + public static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator(); + + /** + * Return a singleton instance of the SIRENE validator using the default formats + * + * @return A singleton instance of the validator + */ + public static SireneValidator getInstance() { + return DEFAULT_SIRENE_VALIDATOR; + } + + /** + * Create a default format validator. + */ + public SireneValidator() { + this.formatValidator = DEFAULT_FORMAT; + } + + /** + * Validate a SIRENE-ID (SIREN or SIRET) + * + * @param code The value validation is being performed on + * @return <code>true</code> if the value is valid + */ + public boolean isValid(final String code) { + if (GenericValidator.isBlankOrNull(code)) { + return false; + } + Review Comment: The blank lines are not needed IMO, it just takes up space, if you want to call something out, use an inline comment. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format Review Comment: Grammar: No `'` ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format + */ + public Validator(String[] formats) { Review Comment: Use `final` where you can. ########## src/main/java/org/apache/commons/validator/routines/checkdigit/TidDECheckDigit.java: ########## @@ -0,0 +1,132 @@ +/* + * 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.validator.routines.checkdigit; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * German Steuer-Identifikationsnummer (TIN – in short: IdNr.) is available since 2008, + * has a length of 11 digits and it applies to individual persons. + * + * <p> + * See <a href="https://download.elster.de/download/schnittstellen/Pruefung_der_Steuer_und_Steueridentifikatsnummer.pdf">Prüfung der Steuer- und Steueridentifikationsnummer (de)</a> + * for more details. + * </p> + * + * @since 1.10.0 + */ +/* (de) Review Comment: This double comment is confusing, use a single Javadoc comment. ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ Review Comment: All new public and protected elements need a Javadoc `@since` tag. The next feature version would be `1.10.0`. ########## src/main/java/org/apache/commons/validator/routines/checkdigit/Modulus97CheckDigit.java: ########## @@ -0,0 +1,177 @@ +/* + * 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.validator.routines.checkdigit; + +import java.io.Serializable; + +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; + +/** + * MOD 97-10 module according to ISO/IEC 7064, MOD 97-10. + * <p> + * See <a href="https://de.wikipedia.org/wiki/ISO/IEC_7064">Wikipedia - ISO/IEC_7064 (de)</a> + * for more details. + * </p> + * + * <p> + * This MOD 97-10 module can be used to validate the LEI (Legal Entity Identifier), ICD id 0199 + * and in VATidBECheckDigit (VATIN_BE), and also in LeitwegValidator + * + * @since 1.10.0 + */ +public class Modulus97CheckDigit extends AbstractCheckDigit implements Serializable { Review Comment: Don't implement Serializable, we are moving away from that IMO, folks that need serialization of some kind can use serialization proxies; see "Effective Java" by J. Block. ########## src/main/java/org/apache/commons/validator/routines/checkdigit/VATidBECheckDigit.java: ########## @@ -0,0 +1,112 @@ +/* + * 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.validator.routines.checkdigit; + +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; + +/** + * Belgian VAT identification number (VATIN) Check Digit calculation/validation. + * <p> + * Numéro T.V.A. BTW-nummer (Nº TVA BTW-nr.) old schema {@code 1234567pp}. + * Note the check digit has two characters and that the old numbering schema only had 9 characters, + * just adding a zero in front makes it a valid number in the new schema {@code 01234567pp}. + * <br> + * The check digits are calculated as 97 - MOD 97 + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/VAT_identification_number">Wikipedia - VAT IN</a> + * for more details. + * </p> + * + * @since 1.10.0 + */ +public final class VATidBECheckDigit extends Modulus97CheckDigit { + + private static final long serialVersionUID = 4622288405648808179L; + + /** Singleton Check Digit instance */ + private static final VATidBECheckDigit INSTANCE = new VATidBECheckDigit(); + + /** + * Gets the singleton instance of this validator. + * @return A singleton instance of the class. + */ + public static CheckDigit getInstance() { + return INSTANCE; + } + + /** + * Constructs a Check Digit routine. + */ + private VATidBECheckDigit() { + super(); + } + + /** + * {@inheritDoc} + * return expression overridden Review Comment: Missing `@` ########## src/main/java/org/apache/commons/validator/routines/VATINValidator.java: ########## @@ -0,0 +1,305 @@ +/* + * 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.validator.routines; + +import java.util.Arrays; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.routines.checkdigit.CheckDigit; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; +import org.apache.commons.validator.routines.checkdigit.Modulus11TenCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidATCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidBECheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidBGCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidCYCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidCZCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidDKCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidEECheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidELCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidESCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidFICheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidFRCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidGBCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidHUCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidIECheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidLTCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidLUCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidLVCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidMTCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidNLCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidPLCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidPTCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidROCheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidSECheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidSICheckDigit; +import org.apache.commons.validator.routines.checkdigit.VATidSKCheckDigit; + +/** + * VAT identification number (VATIN) Validator. + * <p> + * The validator includes a default set of formats and check routines for European Union countries, see + * https://en.wikipedia.org/wiki/VAT_identification_number + * </p> + * <p> + * This can be adjusted f.i. adding a new country routines by creating a validator and using the + * {@link #setValidator(String, int, String, CheckDigit)} + * method to add (or remove) an entry. + * </p> + * <p> + * For example: + * </p> + * <pre> + * VATINValidator v = new VATINValidator(); + * v.setValidator("GB", 14, "GB(\\d{3})?\\d{9}", VATidGBCheckDigit.getInstance()); + * </pre> + * <p> + * The singleton default instance cannot be modified in this way. + * </p> + * @since 1.10.0 + */ +public class VATINValidator { + + private static final Log LOG = LogFactory.getLog(VATINValidator.class); + + /** + * The validation class + */ + public static class Validator { + /* + * The minimum length does not appear to be defined. + * Denmark, Finnland are currently the shortest (including countryCode). + */ + private static final int MIN_LEN = 10; + private static final int MAX_LEN = 16; + + final String countryCode; + final RegexValidator regexValidator; + final int vatinLength; // used to avoid unnecessary regex matching + final CheckDigit routine; + + /** + * Creates the validator. + * @param cc the country code + * @param maxLength the max length of the VATIN including country code + * @param regex the regex to use to check the format, MUST start with the country code. + * @param routine the Check Digit routine + */ + public Validator(final String cc, final int maxLength, final String regex, final CheckDigit routine) { + if (!(cc.length() == 2 && Character.isUpperCase(cc.charAt(0)) && Character.isUpperCase(cc.charAt(1)))) { + throw new IllegalArgumentException("Invalid country Code; must be exactly 2 upper-case characters"); + } + if (maxLength > MAX_LEN || maxLength < MIN_LEN) { + throw new IllegalArgumentException("Invalid length parameter, must be in range " + MIN_LEN + " to " + MAX_LEN + " inclusive: " + maxLength); + } + if (!regex.startsWith(cc)) { + throw new IllegalArgumentException("countryCode '" + cc + "' does not agree with format: " + regex); + } + this.countryCode = cc; + this.vatinLength = maxLength; + this.regexValidator = new RegexValidator(regex); + this.routine = routine; + } + /** + * A convinient ctor to create a validator. The country code is prefixed in the regex. + * @param cc the country code + * @param routine the Check Digit routine + * @param maxLength the max length of the VATIN including country code + * @param regex the regex to use to check the format without country code. + */ + private Validator(final String cc, final CheckDigit routine, final int maxLength, final String regex) { + this(cc, maxLength, cc + regex, routine); + } + + /** + * Gets the RegexValidator. + * + * @return the RegexValidator. + */ + public RegexValidator getRegexValidator() { + return regexValidator; + } + } + + private static final int COUNTRY_CODE_LEN = 2; + private static final String INVALID_COUNTRY_CODE = "No CheckDigit routine or invalid country, code="; + private static final String CANNOT_MODIFY_SINGLETON = "The singleton validator cannot be modified"; + + private static final Validator[] DEFAULT_VALIDATORS = { + new Validator("AT", VATidATCheckDigit.getInstance(), 11, "U\\d{8}"), + new Validator("BE", VATidBECheckDigit.getInstance(), 12, "[0-1]\\d{9}"), + new Validator("BG", VATidBGCheckDigit.getInstance(), 12, "(\\d)?\\d{9}"), + new Validator("CY", VATidCYCheckDigit.getInstance(), 11, "[013459]\\d{7}[A-Z]"), + new Validator("CZ", VATidCZCheckDigit.getInstance(), 12, "(\\d)?(\\d)?\\d{8}"), + new Validator("DE", Modulus11TenCheckDigit.getInstance(), 11, "\\d{9}"), + new Validator("DK", VATidDKCheckDigit.getInstance(), 10, "[1-9]\\d{7}"), + new Validator("EE", VATidEECheckDigit.getInstance(), 11, "\\d{9}"), + new Validator("EL", VATidELCheckDigit.getInstance(), 11, "\\d{9}"), + new Validator("ES", VATidESCheckDigit.getInstance(), 11, "[A-Z0-9]\\d{7}[A-Z0-9]"), + new Validator("FI", VATidFICheckDigit.getInstance(), 10, "\\d{8}"), + new Validator("FR", VATidFRCheckDigit.getInstance(), 13, "[A-Z0-9]{2}\\d{9}"), + new Validator("HR", Modulus11TenCheckDigit.getInstance(), 13, "\\d{11}"), + new Validator("HU", VATidHUCheckDigit.getInstance(), 10, "\\d{8}"), + new Validator("IE", VATidIECheckDigit.getInstance(), 11, "\\d{7}[A-W]([A-I])?"), + new Validator("IT", LuhnCheckDigit.LUHN_CHECK_DIGIT, 13, "\\d{11}"), + // optional Group for Temporarily Registered Taxpayers with 12 digits, C11==1 + new Validator("LT", VATidLTCheckDigit.getInstance(), 14, "\\d{9}([0-9]1[0-9])?"), + new Validator("LU", VATidLUCheckDigit.getInstance(), 13, "\\d{8}"), + // first digit [4-9] : legal entity , [0-3] : natural person + new Validator("LV", VATidLVCheckDigit.getInstance(), 13, "\\d\\d{10}"), + new Validator("MT", VATidMTCheckDigit.getInstance(), 14, "\\d{8}"), + new Validator("NL", VATidNLCheckDigit.getInstance(), 14, "\\d{9}B\\d{2}"), + new Validator("PL", VATidPLCheckDigit.getInstance(), 12, "\\d{10}"), + new Validator("PT", VATidPTCheckDigit.getInstance(), 11, "\\d{9}"), + new Validator("RO", VATidROCheckDigit.getInstance(), 12, "[1-9](\\d)?(\\d)?(\\d)?(\\d)?(\\d)?(\\d)?(\\d)?(\\d)?\\d"), + new Validator("SE", VATidSECheckDigit.getInstance(), 14, "\\d{10}01"), + new Validator("SI", VATidSICheckDigit.getInstance(), 10, "[1-9]\\d{7}"), + // ne of 2, 3, 4, 7, 8, 9 Review Comment: "ne of" ? ########## src/main/java/org/apache/commons/validator/routines/SireneValidator.java: ########## @@ -0,0 +1,130 @@ +/* + * 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.validator.routines; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.GenericValidator; +import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; + +/** + * SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator. + * + * <p> + * International Code Designator, ICD : 0002 for SIRENE + * <br> + * Issuing Organization : + * Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.), + * Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14 + * </p> + * <p> + * Structure of Code : + * <br> + * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), + * <br> + * The 9 character number designates an organization, + * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. + * <br> + * 2) Check digits: 9th and 14th character respectively + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details. + * </p> + */ +public class SireneValidator { + + private static final Log LOG = LogFactory.getLog(SireneValidator.class); + + final Validator formatValidator; + + private static final Validator DEFAULT_FORMAT = + new Validator( new String[] + { "^(\\d{9})$" // SIREN + , "^(\\d{14})$" // SIRET + }); + + private static final int SIREN_CODE_LEN = 9; + private static final int SIRET_CODE_LEN = 14; + + /** + * The validation class + */ + public static class Validator { + final RegexValidator validator; + + /** + * Creates the format validator + * + * @param formats the regex's to use to check the format + */ + public Validator(String[] formats) { + this.validator = new RegexValidator(formats); + } + } + + /** The singleton instance which uses the default formats */ + public static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator(); + + /** + * Return a singleton instance of the SIRENE validator using the default formats + * + * @return A singleton instance of the validator + */ + public static SireneValidator getInstance() { + return DEFAULT_SIRENE_VALIDATOR; + } + + /** + * Create a default format validator. + */ + public SireneValidator() { + this.formatValidator = DEFAULT_FORMAT; + } + + /** + * Validate a SIRENE-ID (SIREN or SIRET) + * + * @param code The value validation is being performed on + * @return <code>true</code> if the value is valid + */ + public boolean isValid(final String code) { + if (GenericValidator.isBlankOrNull(code)) { + return false; + } + + String id = code.trim(); + if (id.length() != SIREN_CODE_LEN && id.length() != SIRET_CODE_LEN) { + return false; + } + + // format check: + if (!formatValidator.validator.isValid(id)) return false; Review Comment: Always use blocks. I'll have to review our Checkstyle rules if this isn't caught. ########## src/main/java/org/apache/commons/validator/routines/checkdigit/Modulus11TenCheckDigit.java: ########## @@ -0,0 +1,132 @@ +/* + * 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.validator.routines.checkdigit; + +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; + +/** + * MOD 11,10 module according to ISO/IEC 7064. + * <p> + * See <a href="https://de.wikipedia.org/wiki/ISO/IEC_7064">Wikipedia - ISO/IEC_7064 (de)</a> + * for more details. + * </p> + * + * <p> + * This MOD 11,10 module can also be used to validate TIN_DE, TIN_HR, the VATIN_DE and VATIN_HR + * used in VATINCheckDigit + * + * @since 1.10.0 + */ +public class Modulus11TenCheckDigit extends ModulusCheckDigit { + + private static final long serialVersionUID = -2146331224291537185L; + + /** Singleton Check Digit instance */ + private static final Modulus11TenCheckDigit INSTANCE = new Modulus11TenCheckDigit(); + + /** + * Gets the singleton instance of this validator. + * @return A singleton instance of the class. + */ + public static CheckDigit getInstance() { + return INSTANCE; + } + + static final int MIN_CODE_LEN = 2; + + /** + * Constructs a modulus Check Digit routine. + */ + Modulus11TenCheckDigit() { + super(MODULUS_11); + } + + /** + * Calculates the <i>weighted</i> value of a character in the + * code at a specified position. + * + * <p>In MOD 11,10 algorithm there is no weight, + * so the weighted value is equal to the character value.</p> + * + * @param charValue The numeric value of the character. + * @param leftPos The position of the character in the code, counting from left to right + * @param rightPos The positionof the character in the code, counting from right to left + * @return The weighted value equals to charValue. + */ + @Override + protected int weightedValue(final int charValue, final int leftPos, final int rightPos) { + return charValue; + } + + /** + * {@inheritDoc} + */ + @Override + public String calculate(final String code) throws CheckDigitException { + if (GenericValidator.isBlankOrNull(code)) { + throw new CheckDigitException(CheckDigitException.MISSING_CODE); + } + if (GenericTypeValidator.formatLong(code) == 0) { + throw new CheckDigitException(CheckDigitException.ZERO_SUM); + } + Review Comment: No need for blank lines, see my previous comment. ########## src/main/java/org/apache/commons/validator/routines/checkdigit/VATidCYCheckDigit.java: ########## @@ -0,0 +1,135 @@ +/* + * 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.validator.routines.checkdigit; + +import org.apache.commons.validator.GenericTypeValidator; +import org.apache.commons.validator.GenericValidator; + +/** + * Cypriot VAT identification number (VATIN) Check Digit calculation/validation. + * <p> + * Arithmos Egrafis FPA (ΦΠΑ) + * </p> + * <p> + * See <a href="https://en.wikipedia.org/wiki/VAT_identification_number">Wikipedia</a> + * for more details. + * </p> + * + * @since 1.10.0 + */ +public final class VATidCYCheckDigit extends ModulusCheckDigit { + + private static final long serialVersionUID = -844683638838062022L; + + /** Singleton Check Digit instance */ + private static final VATidCYCheckDigit INSTANCE = new VATidCYCheckDigit(); + + /** + * Gets the singleton instance of this validator. + * @return A singleton instance of the class. + */ + public static CheckDigit getInstance() { + return INSTANCE; + } + + static final int LEN = 9; // with Check Digit + static final int MODULUS_26 = 26; + + /** Weighting given to digits depending on their left position */ + private static final int[] POSITION_WEIGHT = { 1, 0, 5, 7, 9, 13, 15, 17, 19, 21 }; + private static final String CHECK_CHARACTER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private static final String INVALID_START_WITH = "12"; + private static final String INVALID_START_MSG = "Invalid code, not allowed to start with '12' :"; + + /** + * Constructs a modulus 11 Check Digit routine. + */ + private VATidCYCheckDigit() { + super(MODULUS_26); + } + + /** + * {@inheritDoc} + * <p> + * Override to get the non numeric check character + * </p> + */ + @Override + protected String toCheckDigit(final int charValue) throws CheckDigitException { + if (charValue >= 0 && charValue <= CHECK_CHARACTER.length() - 1) { + return "" + CHECK_CHARACTER.charAt(charValue); + } + throw new CheckDigitException("Invalid Check Digit Value =" + charValue); + } + + /** + * Calculates the <i>weighted</i> value of a character in the + * code at a specified position. + * + * <p>For VATID digits are weighted by their position from left to right.</p> + * + * @param charValue The numeric value of the character. + * @param leftPos The position of the character in the code, counting from left to right + * @param rightPos The positionof the character in the code, counting from right to left + * @return The weighted value of the character. + */ + @Override + protected int weightedValue(final int charValue, final int leftPos, final int rightPos) { + if (leftPos % 2 == 0) return charValue; Review Comment: Always use blocks. -- 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]
