Skip to content
Merged
Prev Previous commit
Added javadoc to validate methods
  • Loading branch information
tomvangreen committed Jul 2, 2018
commit 6d0870e90b019a9d4459ed6d6d18e8a147b56268
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
private static final String X_DISCRIMINATOR_TYPE = "x-discriminator-value";
private static String CLASS_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9]*$";
private static String FILE_NAME_SUFFIX_PATTERN = "^[a-zA-Z0-9.-]*$";

public static final String NPM_NAME = "npmName";
public static final String NPM_VERSION = "npmVersion";
public static final String NPM_REPOSITORY = "npmRepository";
Expand Down Expand Up @@ -530,6 +530,12 @@ private String removeModelSuffixIfNecessary(String name) {
return name.substring(0, name.length() - modelSuffix.length());
}

/**
* Validates that the given string value only contains '-', '.' and alpha numeric characters.
* Throws an IllegalArgumentException, if the string contains any other characters.
* @param argument The name of the argument being validated. This is only used for displaying an error message.
* @param value The value that is being validated.
*/
private void validateFileSuffixArgument(String argument, String value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a method description. describe what argument and value are or rename them to better understand their meaning

if (!value.matches(FILE_NAME_SUFFIX_PATTERN)) {
throw new IllegalArgumentException(
Expand All @@ -538,6 +544,12 @@ private void validateFileSuffixArgument(String argument, String value) {
}
}

/**
* Validates that the given string value only contains alpha numeric characters.
* Throws an IllegalArgumentException, if the string contains any other characters.
* @param argument The name of the argument being validated. This is only used for displaying an error message.
* @param value The value that is being validated.
*/
private void validateClassSuffixArgument(String argument, String value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

if (!value.matches(CLASS_NAME_SUFFIX_PATTERN)) {
throw new IllegalArgumentException(
Expand Down