Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed May 28, 2024
1 parent 303c6a1 commit eed6902
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public class SyncConfig {

public static final String SYNC_LANE_SPACE_TYPE = SYNC_LANE_SPACE + ".type";

public static final String SYNC_MICROSERVICE_LIVE = SYNC + ".serviceLive";

public static final String SYNC_MICROSERVICE_LIVE_TYPE = SYNC_MICROSERVICE_LIVE + ".type";

private String url;

private String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,42 +171,5 @@ public boolean isStarted() {
* @return A {@link String} representing the name of the service.
*/
protected abstract String getName();

/**
* Concatenates a URL with a single path, handling edge cases for slashes.
*
* @param url The base URL.
* @param path The path to append.
* @return The concatenated URL.
*/
protected String concat(String url, String path) {
if (path == null || path.isEmpty()) {
return url;
} else if (url == null) {
return path;
} else if (url.endsWith("/")) {
return url + (path.startsWith("/") ? path.substring(1) : path);
} else {
return url + (path.startsWith("/") ? path : "/" + path);
}
}

/**
* Concatenates a URL with multiple paths, handling edge cases for slashes.
*
* @param url The base URL.
* @param paths The paths to append.
* @return The concatenated URL.
*/
protected String concat(String url, String... paths) {
if (paths == null) {
return url;
}
String result = url;
for (String path : paths) {
result = concat(result, path);
}
return result;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,40 @@ public static String join(String[] strings, String separator) {
return sb.length() > 0 ? sb.substring(0, sb.length() - separator.length()) : StringUtils.EMPTY;
}

/**
* Concatenates a URL with a single path, handling edge cases for slashes.
*
* @param url The base URL.
* @param path The path to append.
* @return The concatenated URL.
*/
public static String url(String url, String path) {
if (path == null || path.isEmpty()) {
return url;
} else if (url == null) {
return path;
} else if (url.endsWith("/")) {
return url + (path.startsWith("/") ? path.substring(1) : path);
} else {
return url + (path.startsWith("/") ? path : "/" + path);
}
}

/**
* Concatenates a URL with multiple paths, handling edge cases for slashes.
*
* @param url The base URL.
* @param paths The paths to append.
* @return The concatenated URL.
*/
public static String url(String url, String... paths) {
if (paths == null) {
return url;
}
String result = url;
for (String path : paths) {
result = url(result, path);
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ public ValuePath(String path, Predicate<Object> predicate) {
this.paths = parse(path);
}

@SuppressWarnings("unchecked")
@Override
public Object get(Object target) {
Object result = null;
int index = 0;
for (PropertyPath path : paths) {
result = getObject(target, path);
if (result == null || index == paths.size() - 1) {
for (PropertyPath propertyPath : paths) {
result = getObject(target, propertyPath);
if (result == null) {
result = index == 0 && paths.size() > 1 && target instanceof Map ? ((Map<String, Object>) target).get(path) : null;
return result;
} else if (index == paths.size() - 1) {
return result;
} else if (predicate != null && !predicate.test(result)) {
return null;
Expand Down

0 comments on commit eed6902

Please sign in to comment.