@@ -27,30 +27,27 @@ public class ValidationUtil
2727{
2828 private  static  final  Pattern  PATTERN  = Pattern .compile ("\\ ." );
2929
30-  private  static  final  Set <String > CPP_KEYWORDS  = new  HashSet <>(
31-  Arrays .asList (new  String []
32-  {
33-  "alignas" , "and" , "and_eq" , "asm" , "auto" ,
34-  "bitand" , "bitor" , "bool" , "break" , "case" ,
35-  "catch" , "char" , "class" , "compl" , "const" ,
36-  "const_cast" , "continue" , "char16_t" , "char32_t" , "default" ,
37-  "delete" , "do" , "double" , "dynamic_cast" , "else" ,
38-  "enum" , "explicit" , "export" , "extern" , "false" ,
39-  "float" , "for" , "friend" , "goto" , "if" ,
40-  "inline" , "int" , "long" , "mutable" , "namespace" ,
41-  "new" , "not" , "not_eq" , "noexcept" , "operator" ,
42-  "or" , "or_eq" , "private" , "protected" , "public" ,
43-  "register" , "reinterpret_cast" , "return" , "short" , "signed" ,
44-  "sizeof" , "static" , "static_cast" , "struct" , "switch" ,
45-  "template" , "this" , "throw" , "true" , "try" ,
46-  "typedef" , "typeid" , "typename" , "union" , "unsigned" ,
47-  "using" , "virtual" , "void" , "volatile" , "wchar_t" ,
48-  "while" , "xor" , "xor_eq" , "override" ,
49-  // since C++11 
50-  "alignof" , "constexpr" , "decltype" , "nullptr" , "static_assert" , "thread_local" ,
51-  // since C++11 have special meaning, so avoid 
52-  "final" 
53-  }));
30+  private  static  final  Set <String > CPP_KEYWORDS  = new  HashSet <>(Arrays .asList (
31+  "alignas" , "and" , "and_eq" , "asm" , "auto" ,
32+  "bitand" , "bitor" , "bool" , "break" , "case" ,
33+  "catch" , "char" , "class" , "compl" , "const" ,
34+  "const_cast" , "continue" , "char16_t" , "char32_t" , "default" ,
35+  "delete" , "do" , "double" , "dynamic_cast" , "else" ,
36+  "enum" , "explicit" , "export" , "extern" , "false" ,
37+  "float" , "for" , "friend" , "goto" , "if" ,
38+  "inline" , "int" , "long" , "mutable" , "namespace" ,
39+  "new" , "not" , "not_eq" , "noexcept" , "operator" ,
40+  "or" , "or_eq" , "private" , "protected" , "public" ,
41+  "register" , "reinterpret_cast" , "return" , "short" , "signed" ,
42+  "sizeof" , "static" , "static_cast" , "struct" , "switch" ,
43+  "template" , "this" , "throw" , "true" , "try" ,
44+  "typedef" , "typeid" , "typename" , "union" , "unsigned" ,
45+  "using" , "virtual" , "void" , "volatile" , "wchar_t" ,
46+  "while" , "xor" , "xor_eq" , "override" ,
47+  // since C++11 
48+  "alignof" , "constexpr" , "decltype" , "nullptr" , "static_assert" , "thread_local" ,
49+  // since C++11 have special meaning, so avoid 
50+  "final" ));
5451
5552 /** 
5653 * Check value for validity of usage as a C++ identifier. A programmatic variable 
@@ -116,21 +113,18 @@ private static boolean isSbeCppIdentifierPart(final char c)
116113 return  Character .isLetterOrDigit (c ) || c  == '_' ;
117114 }
118115
119-  private  static  final  Set <String > JAVA_KEYWORDS  = new  HashSet <>(
120-  Arrays .asList (new  String []
121-  {
122-  "abstract" , "assert" , "boolean" , "break" , "byte" ,
123-  "case" , "catch" , "char" , "class" , "const" ,
124-  "continue" , "default" , "do" , "double" , "else" ,
125-  "enum" , "extends" , "final" , "finally" , "float" ,
126-  "for" , "goto" , "if" , "implements" , "import" ,
127-  "instanceof" , "int" , "interface" , "long" , "native" ,
128-  "new" , "package" , "private" , "protected" , "public" ,
129-  "return" , "short" , "static" , "strictfp" , "super" ,
130-  "switch" , "synchronized" , "this" , "throw" , "throws" ,
131-  "transient" , "try" , "void" , "volatile" , "while" ,
132-  "null" , "true" , "false" , "_" 
133-  }));
116+  private  static  final  Set <String > JAVA_KEYWORDS  = new  HashSet <>(Arrays .asList (
117+  "abstract" , "assert" , "boolean" , "break" , "byte" ,
118+  "case" , "catch" , "char" , "class" , "const" ,
119+  "continue" , "default" , "do" , "double" , "else" ,
120+  "enum" , "extends" , "final" , "finally" , "float" ,
121+  "for" , "goto" , "if" , "implements" , "import" ,
122+  "instanceof" , "int" , "interface" , "long" , "native" ,
123+  "new" , "package" , "private" , "protected" , "public" ,
124+  "return" , "short" , "static" , "strictfp" , "super" ,
125+  "switch" , "synchronized" , "this" , "throw" , "throws" ,
126+  "transient" , "try" , "void" , "volatile" , "while" ,
127+  "null" , "true" , "false" , "_" ));
134128
135129 /** 
136130 * Check string for validity of usage as a Java identifier. Avoiding keywords. 
@@ -199,29 +193,26 @@ private static boolean isJavaIdentifier(final String token)
199193 return  true ;
200194 }
201195
202-  private  static  final  Set <String > GOLANG_KEYWORDS  = new  HashSet <>(
203-  Arrays .asList (new  String []
204-  {
205-  /* https://golang.org/ref/spec#Keywords */ 
206-  "break" , "default" , "func" , "interface" , "select" ,
207-  "case" , "defer" , "go" , "map" , "struct" ,
208-  "chan" , "else" , "goto" , "package" , "switch" ,
209-  "const" , "fallthrough" , "if" , "range" , "type" ,
210-  "continue" , "for" , "import" , "return" , "var" ,
211- 
212-  /* https://golang.org/ref/spec#Predeclared_identifiers */ 
213-  /* types */ 
214-  "bool" , "byte" , "complex64" , "complex128" , "error" , "float32" , "float64" ,
215-  "int" , "int8" , "int16" , "int32" , "int64" , "rune" , "string" ,
216-  "uint" , "uint8" , "uint16" , "uint32" , "uint64" , "uintptr" ,
217-  /* constants */ 
218-  "true" , "false" , "iota" ,
219-  /* zero value */ 
220-  "nil" ,
221-  /* functions */ 
222-  "append" , "cap" , "close" , "complex" , "copy" , "delete" , "imag" , "len" ,
223-  "make" , "new" , "panic" , "print" , "println" , "real" , "recover" 
224-  }));
196+  /* https://golang.org/ref/spec#Keywords */ 
197+  private  static  final  Set <String > GOLANG_KEYWORDS  = new  HashSet <>(Arrays .asList (
198+  "break" , "default" , "func" , "interface" , "select" ,
199+  "case" , "defer" , "go" , "map" , "struct" ,
200+  "chan" , "else" , "goto" , "package" , "switch" ,
201+  "const" , "fallthrough" , "if" , "range" , "type" ,
202+  "continue" , "for" , "import" , "return" , "var" ,
203+ 
204+  /* https://golang.org/ref/spec#Predeclared_identifiers */ 
205+  /* types */ 
206+  "bool" , "byte" , "complex64" , "complex128" , "error" , "float32" , "float64" ,
207+  "int" , "int8" , "int16" , "int32" , "int64" , "rune" , "string" ,
208+  "uint" , "uint8" , "uint16" , "uint32" , "uint64" , "uintptr" ,
209+  /* constants */ 
210+  "true" , "false" , "iota" ,
211+  /* zero value */ 
212+  "nil" ,
213+  /* functions */ 
214+  "append" , "cap" , "close" , "complex" , "copy" , "delete" , "imag" , "len" ,
215+  "make" , "new" , "panic" , "print" , "println" , "real" , "recover" ));
225216
226217 /** 
227218 * "Check" value for validity of usage as a golang identifier. From: 
@@ -291,36 +282,33 @@ private static boolean isSbeGolangIdentifierPart(final char c)
291282 return  Character .isLetterOrDigit (c ) || c  == '_' ;
292283 }
293284
294-  private  static  final  Set <String > CSHARP_KEYWORDS  = new  HashSet <>(
295-  Arrays .asList (new  String []
296-  {
297-  /** 
298-  * https://docs.microsoft.com/en-gb/dotnet/articles/csharp/language-reference/keywords/index 
299-  * Note this does not include the contextual keywords 
300-  * Note "virtual" is no longer but was in early versions of C# 
301-  */ 
302-  "abstract" , "as" , "base" , "bool" , "break" ,
303-  "byte" , "case" , "catch" , "char" , "checked" ,
304-  "class" , "const" , "continue" , "decimal" , "default" ,
305-  "delegate" , "do" , "double" , "else" , "enum" ,
306-  "event" , "explicit" , "extern" , "false" , "finally" ,
307-  "fixed" , "float" , "for" , "foreach" , "goto" ,
308-  "if" , "implicit" , "in" , "int" , "interface" ,
309-  "internal" , "is" , "lock" , "long" , "namespace" ,
310-  "new" , "null" , "object" , "operator" , "out" ,
311-  "override" , "params" , "private" , "protected" , "public" ,
312-  "readonly" , "ref" , "return" , "sbyte" , "sealed" ,
313-  "short" , "sizeof" , "stackalloc" , "static" , "string" ,
314-  "struct" , "switch" , "this" , "throw" , "true" ,
315-  "try" , "typeof" , "uint" , "ulong" , "unchecked" ,
316-  "unsafe" , "ushort" , "using" , "using static" , "virtual" ,
317-  "void" , "volatile" , "while" 
318-  }));
285+  /** 
286+  * https://docs.microsoft.com/en-gb/dotnet/articles/csharp/language-reference/keywords/index 
287+  * Note this does not include the contextual keywords 
288+  * Note "virtual" is no longer but was in early versions of C# 
289+  */ 
290+  private  static  final  Set <String > CSHARP_KEYWORDS  = new  HashSet <>(Arrays .asList (
291+  "abstract" , "as" , "base" , "bool" , "break" ,
292+  "byte" , "case" , "catch" , "char" , "checked" ,
293+  "class" , "const" , "continue" , "decimal" , "default" ,
294+  "delegate" , "do" , "double" , "else" , "enum" ,
295+  "event" , "explicit" , "extern" , "false" , "finally" ,
296+  "fixed" , "float" , "for" , "foreach" , "goto" ,
297+  "if" , "implicit" , "in" , "int" , "interface" ,
298+  "internal" , "is" , "lock" , "long" , "namespace" ,
299+  "new" , "null" , "object" , "operator" , "out" ,
300+  "override" , "params" , "private" , "protected" , "public" ,
301+  "readonly" , "ref" , "return" , "sbyte" , "sealed" ,
302+  "short" , "sizeof" , "stackalloc" , "static" , "string" ,
303+  "struct" , "switch" , "this" , "throw" , "true" ,
304+  "try" , "typeof" , "uint" , "ulong" , "unchecked" ,
305+  "unsafe" , "ushort" , "using" , "using static" , "virtual" ,
306+  "void" , "volatile" , "while" ));
319307
320308 /** 
321309 * "Check" value for validity of usage as a csharp identifier. 
322310 * https://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx 
323-  ( Which basically boils down to 
311+  *  ( Which basically boils down to 
324312 * 
325313 * first subsequent* 
326314 * first is { @ | letter | underscore } 
@@ -338,11 +326,11 @@ private static boolean isSbeGolangIdentifierPart(final char c)
338326 * @param value to check 
339327 * @return true for validity as a csharp name. false if not. 
340328 */ 
341-  public  static  boolean  isSbeCsharpName (final  String  value )
329+  public  static  boolean  isSbeCSharpName (final  String  value )
342330 {
343-  if  (possibleCsharpKeyword (value ))
331+  if  (possibleCSharpKeyword (value ))
344332 {
345-  if  (isCsharpKeyword (value ))
333+  if  (isCSharpKeyword (value ))
346334 {
347335 return  false ;
348336 }
@@ -355,23 +343,23 @@ public static boolean isSbeCsharpName(final String value)
355343 return  true ;
356344 }
357345
358-  public  static  boolean  isCsharpKeyword (final  String  token )
346+  public  static  boolean  isCSharpKeyword (final  String  token )
359347 {
360348 return  CSHARP_KEYWORDS .contains (token );
361349 }
362350
363-  private  static  boolean  possibleCsharpKeyword (final  String  value )
351+  private  static  boolean  possibleCSharpKeyword (final  String  value )
364352 {
365353 for  (int  i  = 0 , size  = value .length (); i  < size ; i ++)
366354 {
367355 final  char  c  = value .charAt (i );
368356
369-  if  (i  == 0  && isSbeCsharpIdentifierStart (c ))
357+  if  (i  == 0  && isSbeCSharpIdentifierStart (c ))
370358 {
371359 continue ;
372360 }
373361
374-  if  (isSbeCsharpIdentifierPart (c ))
362+  if  (isSbeCSharpIdentifierPart (c ))
375363 {
376364 continue ;
377365 }
@@ -382,14 +370,14 @@ private static boolean possibleCsharpKeyword(final String value)
382370 return  true ;
383371 }
384372
385-  private  static  boolean  isSbeCsharpIdentifierStart (final  char  c )
373+  private  static  boolean  isSbeCSharpIdentifierStart (final  char  c )
386374 {
387375 return  Character .isLetter (c ) || c  == '_'  || c  == '@' ;
388376 }
389377
390-  private  static  boolean  isSbeCsharpIdentifierPart (final  char  c )
378+  private  static  boolean  isSbeCSharpIdentifierPart (final  char  c )
391379 {
392-  if  (isSbeCsharpIdentifierStart (c ))
380+  if  (isSbeCSharpIdentifierStart (c ))
393381 {
394382 return  true ;
395383 }
@@ -406,5 +394,4 @@ private static boolean isSbeCsharpIdentifierPart(final char c)
406394 return  false ;
407395 }
408396 }
409- 
410397}
0 commit comments