Skip to content

Commit

Permalink
Sort
Browse files Browse the repository at this point in the history
  • Loading branch information
moarychan committed Jan 10, 2025
1 parent 34236ee commit 65472e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package com.azure.spring.messaging.servicebus.implementation.properties.merger.util;

import com.azure.spring.messaging.servicebus.implementation.properties.merger.util.TestPropertiesUtils;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ public class TestPropertiesUtils {
public static final String GETTER_METHOD = "getter";
private static final String OTHERS_METHOD = "others";

public static final Set<Class<?>> IGNORED_CLASSES = Set.of(Consumer.class, Object.class, Class.class);
public static final Set<Class<?>> IGNORED_CLASSES = Set.of(Class.class, Consumer.class, Object.class);

public static final Set<String> BUILT_IN_MEMBER_VARIABLE_NAMES =
Set.of("client", "proxy", "retry", "credential", "profile", "environment", "fixed", "exponential");
Set.of("client", "credential", "environment", "exponential", "fixed", "profile", "proxy", "retry");

public static final Class<?>[] NO_SETTER_PROPERTIES_CLASSES = new Class[] {
AzureAmqpSdkProperties.class,
AmqpClientProperties.class,
AmqpProxyProperties.class,
AmqpRetryProperties.class,
TokenCredentialProperties.class,
AzureAmqpSdkProperties.class,
AzureEnvironmentProperties.class,
AzureProfileOptionsAdapter.class,
AzureProfileProperties.class,
ClientProperties.class,
ExponentialRetryProperties.class,
FixedRetryProperties.class,
ProxyProperties.class,
RetryProperties.class,
AzureEnvironmentProperties.class,
AzureProfileOptionsAdapter.class,
FixedRetryProperties.class,
ExponentialRetryProperties.class
TokenCredentialProperties.class
};

public static String groupMethodName(Method method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider;
import com.azure.spring.cloud.core.provider.RetryOptionsProvider;
import com.azure.spring.cloud.service.servicebus.properties.ServiceBusEntityType;
import com.azure.spring.messaging.servicebus.implementation.properties.merger.util.TestPropertiesUtils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -146,26 +145,26 @@ private static <T> void invokeSetter(T target,

static class HighPriorityMethodComparator implements Comparator<Method> {

private final List<String> highPriorityVariables;
private final List<String> priorities;

HighPriorityMethodComparator(List<String> highPriorityVariables) {
this.highPriorityVariables = highPriorityVariables;
HighPriorityMethodComparator(List<String> priorities) {
this.priorities = priorities;
}

@Override
public int compare(Method o1, Method o2) {
String o1Value = o1.getName().toLowerCase();
String o2Value = o2.getName().toLowerCase();
if (highPriorityVariables.contains(o1Value) && !highPriorityVariables.contains(o2Value)) {
if (priorities.contains(o1Value) && !priorities.contains(o2Value)) {
return 1;
}

if (!highPriorityVariables.contains(o1Value) && highPriorityVariables.contains(o2Value)) {
if (!priorities.contains(o1Value) && priorities.contains(o2Value)) {
return -1;
}

if (highPriorityVariables.contains(o1Value) && highPriorityVariables.contains(o2Value)) {
return highPriorityVariables.indexOf(o1Value) - highPriorityVariables.indexOf(o2Value);
if (priorities.contains(o1Value) && priorities.contains(o2Value)) {
return priorities.indexOf(o1Value) - priorities.indexOf(o2Value);
}

return o1Value.compareTo(o2Value);
Expand Down

0 comments on commit 65472e4

Please sign in to comment.