Skip to content

Commit

Permalink
Merge pull request #688 from rgallardo-netflix/feature/config-proxy-c…
Browse files Browse the repository at this point in the history
…leanup-RG

Readability refactor for ConfigProxyFactory
  • Loading branch information
rgallardo-netflix authored Oct 26, 2023
2 parents c198dd6 + 9f76ecc commit e939ef5
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
*/
public class ArchaiusType implements ParameterizedType {

/** Return a ParametrizedType to represent a {@code List<listValuesType>} */
/** Return a parameterizedType to represent a {@code List<listValuesType>} */
public static ParameterizedType forListOf(Class<?> listValuesType) {
Class<?> maybeWrappedType = PRIMITIVE_WRAPPERS.getOrDefault(listValuesType, listValuesType);
return new ArchaiusType(List.class, new Class<?>[] { maybeWrappedType });
}

/** Return a ParametrizedType to represent a {@code Set<setValuesType>} */
/** Return a parameterizedType to represent a {@code Set<setValuesType>} */
public static ParameterizedType forSetOf(Class<?> setValuesType) {
Class<?> maybeWrappedType = PRIMITIVE_WRAPPERS.getOrDefault(setValuesType, setValuesType);
return new ArchaiusType(Set.class, new Class<?>[] { maybeWrappedType });
}

/** Return a ParametrizedType to represent a {@code Map<mapKeysType, mapValuesType>} */
/** Return a parameterizedType to represent a {@code Map<mapKeysType, mapValuesType>} */
public static ParameterizedType forMapOf(Class<?> mapKeysTpe, Class<?> mapValuesType) {
Class<?> maybeWrappedKeyType = PRIMITIVE_WRAPPERS.getOrDefault(mapKeysTpe, mapKeysTpe);
Class<?> maybeWrappedValuesType = PRIMITIVE_WRAPPERS.getOrDefault(mapValuesType, mapValuesType);
Expand Down Expand Up @@ -68,7 +68,7 @@ private ArchaiusType(Class<?> rawType, Class<?>[] typeArguments) {
if (rawType.isArray()
|| rawType.isPrimitive()
|| rawType.getTypeParameters().length != typeArguments.length) {
throw new IllegalArgumentException("The provided rawType and arguments don't look like a supported parametrized type");
throw new IllegalArgumentException("The provided rawType and arguments don't look like a supported parameterized type");
}
}

Expand All @@ -90,6 +90,6 @@ public Type getOwnerType() {
@Override
public String toString() {
String typeArgumentNames = Arrays.stream(typeArguments).map(Class::getSimpleName).collect(Collectors.joining(","));
return String.format("ParametrizedType for %s<%s>", rawType.getSimpleName(), typeArgumentNames);
return String.format("parameterizedType for %s<%s>", rawType.getSimpleName(), typeArgumentNames);
}
}
Loading

0 comments on commit e939ef5

Please sign in to comment.