Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Feb 19, 2022
1 parent c5c9267 commit 8c6d59a
Show file tree
Hide file tree
Showing 37 changed files with 132 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,16 +61,15 @@ public void setup() {
this.propertyAccessor = new BeanWrapperImpl(this.target);
}
switch (this.customEditor) {
case "stringTrimmer" -> this.propertyAccessor.registerCustomEditor(String.class,
new StringTrimmerEditor(false));
case "numberOnPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array.somePath",
new CustomNumberEditor(Integer.class, false));
case "numberOnNestedPath" -> this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath",
new CustomNumberEditor(Integer.class, false));
case "numberOnType" -> this.propertyAccessor.registerCustomEditor(int.class,
new CustomNumberEditor(Integer.class, false));
case "stringTrimmer" ->
this.propertyAccessor.registerCustomEditor(String.class, new StringTrimmerEditor(false));
case "numberOnPath" ->
this.propertyAccessor.registerCustomEditor(int.class, "array.somePath", new CustomNumberEditor(Integer.class, false));
case "numberOnNestedPath" ->
this.propertyAccessor.registerCustomEditor(int.class, "array[0].somePath", new CustomNumberEditor(Integer.class, false));
case "numberOnType" ->
this.propertyAccessor.registerCustomEditor(int.class, new CustomNumberEditor(Integer.class, false));
}

}

}
Expand All @@ -94,4 +93,5 @@ public void setArray(int[] array) {
this.array = array;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -353,8 +353,8 @@ protected void createMimeMultiparts(MimeMessage mimeMessage, int multipartMode)
rootMixedMultipart.addBodyPart(relatedBodyPart);
setMimeMultiparts(rootMixedMultipart, nestedRelatedMultipart);
}
default -> throw new IllegalArgumentException(
"Only multipart modes MIXED_RELATED, RELATED and NO supported");
default ->
throw new IllegalArgumentException("Only multipart modes MIXED_RELATED, RELATED and NO supported");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -93,17 +93,17 @@ public static List<TypeFilter> createTypeFiltersFor(AnnotationAttributes filterA
environment, resourceLoader, registry);
typeFilters.add(filter);
}
default -> throw new IllegalArgumentException(
"Filter type not supported with Class value: " + filterType);
default ->
throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
}
}

for (String expression : filterAttributes.getStringArray("pattern")) {
switch (filterType) {
case ASPECTJ -> typeFilters.add(new AspectJTypeFilter(expression, resourceLoader.getClassLoader()));
case REGEX -> typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
default -> throw new IllegalArgumentException(
"Filter type not supported with String pattern: " + filterType);
default ->
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,8 +46,8 @@ public class AsyncConfigurationSelector extends AdviceModeImportSelector<EnableA
@NonNull
public String[] selectImports(AdviceMode adviceMode) {
return switch (adviceMode) {
case PROXY -> new String[]{ProxyAsyncConfiguration.class.getName()};
case ASPECTJ -> new String[]{ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME};
case PROXY -> new String[] {ProxyAsyncConfiguration.class.getName()};
case ASPECTJ -> new String[] {ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME};
};
}

Expand Down
23 changes: 16 additions & 7 deletions spring-core/src/main/java/org/springframework/asm/TypePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,22 @@ public String toString() {
int length = getLength();
StringBuilder result = new StringBuilder(length * 2);
for (int i = 0; i < length; ++i) {
switch (getStep(i)) {
case ARRAY_ELEMENT -> result.append('[');
case INNER_TYPE -> result.append('.');
case WILDCARD_BOUND -> result.append('*');
case TYPE_ARGUMENT -> result.append(getStepArgument(i)).append(';');
default -> throw new AssertionError();
}
switch (getStep(i)) {
case ARRAY_ELEMENT:
result.append('[');
break;
case INNER_TYPE:
result.append('.');
break;
case WILDCARD_BOUND:
result.append('*');
break;
case TYPE_ARGUMENT:
result.append(getStepArgument(i)).append(';');
break;
default:
throw new AssertionError();
}
}
return result.toString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -607,8 +607,10 @@ public static Matcher matcher(byte[]... delimiters) {
}

private static NestedMatcher createMatcher(byte[] delimiter) {
Assert.isTrue(delimiter.length > 0, "Delimiter must not be empty");
return switch (delimiter.length) {
// extract length due to Eclipse IDE compiler error in switch expression
int length = delimiter.length;
Assert.isTrue(length > 0, "Delimiter must not be empty");
return switch (length) {
case 1 -> (delimiter[0] == 10 ? SingleByteMatcher.NEWLINE_MATCHER : new SingleByteMatcher(delimiter));
case 2 -> new TwoByteMatcher(delimiter);
default -> new KnuthMorrisPrattMatcher(delimiter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -145,9 +145,8 @@ public static class FindRequest {
@Setup(Level.Trial)
public void doSetup(ServerState serverState) {
switch (this.contention) {
case "noSubscribers" -> {
case "noSubscribers" ->
this.destination = "someDestination_withNoSubscribers_" + serverState.uniqueIdGenerator.incrementAndGet();
}
case "sameDestination" -> this.destination = serverState.destinationIds[0];
case "none" -> {
int uniqueNumber = serverState.uniqueIdGenerator.getAndIncrement();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -197,10 +197,10 @@ public static RSocketFrameTypeMessageCondition getCondition(int cardinalityIn, i
case 0 -> REQUEST_FNF_OR_RESPONSE_CONDITION;
case 1 -> REQUEST_RESPONSE_CONDITION;
case 2 -> REQUEST_STREAM_CONDITION;
default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityOut);
default -> throw new IllegalStateException("Invalid response cardinality: " + cardinalityOut);
};
case 2 -> REQUEST_CHANNEL_CONDITION;
default -> throw new IllegalStateException("Invalid cardinality: " + cardinalityIn);
default -> throw new IllegalStateException("Invalid request cardinality: " + cardinalityIn);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -173,19 +173,16 @@ public Object getAttribute(String name) {
@Nullable
public Object getAttribute(String name, int scope) {
Assert.notNull(name, "Attribute name must not be null");
switch (scope) {
case PAGE_SCOPE:
return getAttribute(name);
case REQUEST_SCOPE:
return this.request.getAttribute(name);
case SESSION_SCOPE:
return switch (scope) {
case PAGE_SCOPE -> getAttribute(name);
case REQUEST_SCOPE -> this.request.getAttribute(name);
case SESSION_SCOPE -> {
HttpSession session = this.request.getSession(false);
return (session != null ? session.getAttribute(name) : null);
case APPLICATION_SCOPE:
return this.servletContext.getAttribute(name);
default:
throw new IllegalArgumentException("Invalid scope: " + scope);
}
yield (session != null ? session.getAttribute(name) : null);
}
case APPLICATION_SCOPE -> this.servletContext.getAttribute(name);
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
};
}

@Override
Expand Down Expand Up @@ -250,19 +247,16 @@ public Enumeration<String> getAttributeNames() {

@Override
public Enumeration<String> getAttributeNamesInScope(int scope) {
switch (scope) {
case PAGE_SCOPE:
return getAttributeNames();
case REQUEST_SCOPE:
return this.request.getAttributeNames();
case SESSION_SCOPE:
return switch (scope) {
case PAGE_SCOPE -> getAttributeNames();
case REQUEST_SCOPE -> this.request.getAttributeNames();
case SESSION_SCOPE -> {
HttpSession session = this.request.getSession(false);
return (session != null ? session.getAttributeNames() : Collections.emptyEnumeration());
case APPLICATION_SCOPE:
return this.servletContext.getAttributeNames();
default:
throw new IllegalArgumentException("Invalid scope: " + scope);
}
yield (session != null ? session.getAttributeNames() : Collections.emptyEnumeration());
}
case APPLICATION_SCOPE -> this.servletContext.getAttributeNames();
default -> throw new IllegalArgumentException("Invalid scope: " + scope);
};
}

@Override
Expand Down
Loading

0 comments on commit 8c6d59a

Please sign in to comment.