11package com .sap .cloud .sdk .datamodel .odata .utility ;
22
33import java .util .Collection ;
4+ import java .util .Locale ;
45
56import javax .annotation .Nonnull ;
67import javax .annotation .Nullable ;
@@ -120,8 +121,8 @@ public String generateJavaMethodName( @Nonnull final String name )
120121 methodName = CaseFormat .UPPER_CAMEL .to (CaseFormat .LOWER_CAMEL , methodName );
121122 methodName = appendSuffixIfNameIsReservedKeyword (methodName , "Objects" );
122123
123- methodName = StringUtils . removeStart (methodName , "to" );
124- methodName = StringUtils . removeStart (methodName , "_" );
124+ methodName = removeStartIgnoreCase (methodName , "to" );
125+ methodName = removeStartIgnoreCase (methodName , "_" );
125126 methodName = NamingUtils .uncapitalize (methodName );
126127
127128 throwIfConversionResultIsNullOrEmpty (name , null , methodName , "Java method name" );
@@ -134,8 +135,8 @@ public String generateJavaMethodName( @Nonnull final String name )
134135 public String generateJavaBuilderMethodName ( @ Nonnull final String name )
135136 {
136137 String methodName = generateNameFromProperty (name , null );
137- methodName = StringUtils . removeStartIgnoreCase (methodName , "to" );
138- methodName = StringUtils . removeStart (methodName , "_" );
138+ methodName = removeStartIgnoreCase (methodName , "to" );
139+ methodName = removeStartIgnoreCase (methodName , "_" );
139140 methodName = uncapitalizeLeadingAcronym (methodName );
140141 methodName = appendSuffixIfNameIsReservedKeyword (methodName , "Property" );
141142
@@ -152,8 +153,8 @@ public String generateJavaOperationMethodName( @Nonnull final String name, @Null
152153 methodName = CaseFormat .UPPER_CAMEL .to (CaseFormat .LOWER_CAMEL , methodName );
153154 methodName = appendSuffixIfNameIsReservedKeyword (methodName , "Function" );
154155
155- methodName = StringUtils . removeStart (methodName , "to" );
156- methodName = StringUtils . removeStart (methodName , "_" );
156+ methodName = removeStartIgnoreCase (methodName , "to" );
157+ methodName = removeStartIgnoreCase (methodName , "_" );
157158
158159 throwIfConversionResultIsNullOrEmpty (name , label , methodName , "Java function import method name" );
159160
@@ -250,7 +251,7 @@ private String removeFirstPrefix( final String name, final Iterable<String> pref
250251 {
251252 String formattedName = name .trim ();
252253 for ( final String prefixToRemove : prefixes ) {
253- if ( StringUtils .startsWith (formattedName , prefixToRemove ) ) {
254+ if ( formattedName .startsWith (prefixToRemove ) ) {
254255 formattedName = formattedName .substring (prefixToRemove .length ());
255256 break ;
256257 }
@@ -262,9 +263,27 @@ private String removeAllSuffixes( @Nonnull final String name, @Nonnull final Ite
262263 {
263264 String formattedName = name ;
264265 for ( final String suffix : suffixes ) {
265- formattedName = StringUtils . removeEndIgnoreCase (formattedName , suffix );
266+ formattedName = removeEndIgnoreCase (formattedName , suffix );
266267 }
267268
268269 return formattedName ;
269270 }
271+
272+ @ Nonnull
273+ private static String removeStartIgnoreCase ( @ Nonnull final String s , @ Nonnull final String prefix )
274+ {
275+ if ( s .toLowerCase (Locale .ROOT ).startsWith (prefix .toLowerCase (Locale .ROOT )) ) {
276+ return s .substring (prefix .length ());
277+ }
278+ return s ;
279+ }
280+
281+ @ Nonnull
282+ private static String removeEndIgnoreCase ( @ Nonnull final String s , @ Nonnull final String prefix )
283+ {
284+ if ( s .toLowerCase (Locale .ROOT ).endsWith (prefix .toLowerCase (Locale .ROOT )) ) {
285+ return s .substring (0 , s .length () - prefix .length ());
286+ }
287+ return s ;
288+ }
270289}
0 commit comments