Skip to content

Commit c588eac

Browse files
committed
Fix compilation
1 parent 687d71e commit c588eac

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

cloudplatform/security/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
<groupId>io.vavr</groupId>
5050
<artifactId>vavr</artifactId>
5151
</dependency>
52-
<dependency>
53-
<groupId>org.apache.commons</groupId>
54-
<artifactId>commons-lang3</artifactId>
55-
</dependency>
5652
<dependency>
5753
<groupId>com.sap.cloud.security</groupId>
5854
<artifactId>java-api</artifactId>

cloudplatform/security/src/main/java/com/sap/cloud/sdk/cloudplatform/security/BearerCredentials.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import javax.annotation.Nonnull;
44

5-
import org.apache.commons.lang3.StringUtils;
6-
75
import lombok.Data;
86

97
/**
@@ -34,8 +32,9 @@ public class BearerCredentials implements Credentials
3432
public BearerCredentials( @Nonnull final String token )
3533
{
3634
final String trimmedToken = token.trim();
37-
if( StringUtils.startsWithIgnoreCase(trimmedToken, BEARER_PREFIX) ) {
38-
this.token = trimmedToken.substring(BEARER_PREFIX.length()).trim();
35+
final int l = BEARER_PREFIX.length();
36+
if( trimmedToken.length() > l && trimmedToken.substring(0, l).equalsIgnoreCase(BEARER_PREFIX) ) {
37+
this.token = trimmedToken.substring(l).trim();
3938
} else {
4039
this.token = trimmedToken;
4140
}

datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/S4HanaNamingStrategy.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.sap.cloud.sdk.datamodel.odata.utility;
22

33
import java.util.Collection;
4+
import java.util.Locale;
45

56
import javax.annotation.Nonnull;
67
import 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

Comments
 (0)