1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Use diamond type

This commit is contained in:
Johnny Lim
2017-11-20 02:25:30 +09:00
committed by Rob Winch
parent cfe40358bd
commit 57353d18e5
221 changed files with 423 additions and 428 deletions
@@ -68,7 +68,7 @@ public final class ExpressionBasedMessageSecurityMetadataSourceFactory {
*/
public static MessageSecurityMetadataSource createExpressionMessageMetadataSource(
LinkedHashMap<MessageMatcher<?>, String> matcherToExpression) {
return createExpressionMessageMetadataSource(matcherToExpression, new DefaultMessageSecurityExpressionHandler<Object>());
return createExpressionMessageMetadataSource(matcherToExpression, new DefaultMessageSecurityExpressionHandler<>());
}
/**
@@ -121,4 +121,4 @@ public final class ExpressionBasedMessageSecurityMetadataSourceFactory {
private ExpressionBasedMessageSecurityMetadataSourceFactory() {
}
}
}
@@ -37,7 +37,7 @@ import java.util.Collection;
* @author Rob Winch
*/
public class MessageExpressionVoter<T> implements AccessDecisionVoter<Message<T>> {
private SecurityExpressionHandler<Message<T>> expressionHandler = new DefaultMessageSecurityExpressionHandler<T>();
private SecurityExpressionHandler<Message<T>> expressionHandler = new DefaultMessageSecurityExpressionHandler<>();
public int vote(Authentication authentication, Message<T> message,
Collection<ConfigAttribute> attributes) {
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
*/
public final class ChannelSecurityInterceptor extends AbstractSecurityInterceptor
implements ChannelInterceptor {
private static final ThreadLocal<InterceptorStatusToken> tokenHolder = new ThreadLocal<InterceptorStatusToken>();
private static final ThreadLocal<InterceptorStatusToken> tokenHolder = new ThreadLocal<>();
private final MessageSecurityMetadataSource metadataSource;
@@ -60,7 +60,7 @@ public final class DefaultMessageSecurityMetadataSource implements
}
public Collection<ConfigAttribute> getAllConfigAttributes() {
Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>();
Set<ConfigAttribute> allAttributes = new HashSet<>();
for (Collection<ConfigAttribute> entry : messageMap.values()) {
allAttributes.addAll(entry);
@@ -115,7 +115,7 @@ public final class SecurityContextChannelInterceptor extends ChannelInterceptorA
Stack<SecurityContext> contextStack = ORIGINAL_CONTEXT.get();
if (contextStack == null) {
contextStack = new Stack<SecurityContext>();
contextStack = new Stack<>();
ORIGINAL_CONTEXT.set(contextStack);
}
contextStack.push(currentContext);
@@ -51,9 +51,9 @@ public class DefaultMessageSecurityExpressionHandlerTests {
@Before
public void setup() {
handler = new DefaultMessageSecurityExpressionHandler<Object>();
handler = new DefaultMessageSecurityExpressionHandler<>();
message = new GenericMessage<Object>("");
message = new GenericMessage<>("");
authentication = new AnonymousAuthenticationToken("key", "anonymous",
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
}
@@ -43,39 +43,39 @@ public class AndMessageMatcherTest {
@Test(expected = NullPointerException.class)
public void constructorNullArray() {
new AndMessageMatcher<Object>((MessageMatcher<Object>[]) null);
new AndMessageMatcher<>((MessageMatcher<Object>[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void constructorArrayContainsNull() {
new AndMessageMatcher<Object>((MessageMatcher<Object>) null);
new AndMessageMatcher<>((MessageMatcher<Object>) null);
}
@SuppressWarnings("unchecked")
@Test(expected = IllegalArgumentException.class)
public void constructorEmptyArray() {
new AndMessageMatcher<Object>((MessageMatcher<Object>[]) new MessageMatcher[0]);
new AndMessageMatcher<>((MessageMatcher<Object>[]) new MessageMatcher[0]);
}
@Test(expected = IllegalArgumentException.class)
public void constructorNullList() {
new AndMessageMatcher<Object>((List<MessageMatcher<Object>>) null);
new AndMessageMatcher<>((List<MessageMatcher<Object>>) null);
}
@Test(expected = IllegalArgumentException.class)
public void constructorListContainsNull() {
new AndMessageMatcher<Object>(Arrays.asList((MessageMatcher<Object>) null));
new AndMessageMatcher<>(Arrays.asList((MessageMatcher<Object>) null));
}
@Test(expected = IllegalArgumentException.class)
public void constructorEmptyList() {
new AndMessageMatcher<Object>(Collections.<MessageMatcher<Object>> emptyList());
new AndMessageMatcher<>(Collections.emptyList());
}
@Test
public void matchesSingleTrue() {
when(delegate.matches(message)).thenReturn(true);
matcher = new AndMessageMatcher<Object>(delegate);
matcher = new AndMessageMatcher<>(delegate);
assertThat(matcher.matches(message)).isTrue();
}
@@ -84,7 +84,7 @@ public class AndMessageMatcherTest {
public void matchesMultiTrue() {
when(delegate.matches(message)).thenReturn(true);
when(delegate2.matches(message)).thenReturn(true);
matcher = new AndMessageMatcher<Object>(delegate, delegate2);
matcher = new AndMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isTrue();
}
@@ -92,7 +92,7 @@ public class AndMessageMatcherTest {
@Test
public void matchesSingleFalse() {
when(delegate.matches(message)).thenReturn(false);
matcher = new AndMessageMatcher<Object>(delegate);
matcher = new AndMessageMatcher<>(delegate);
assertThat(matcher.matches(message)).isFalse();
}
@@ -100,7 +100,7 @@ public class AndMessageMatcherTest {
@Test
public void matchesMultiBothFalse() {
when(delegate.matches(message)).thenReturn(false);
matcher = new AndMessageMatcher<Object>(delegate, delegate2);
matcher = new AndMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isFalse();
}
@@ -109,7 +109,7 @@ public class AndMessageMatcherTest {
public void matchesMultiSingleFalse() {
when(delegate.matches(message)).thenReturn(true);
when(delegate2.matches(message)).thenReturn(false);
matcher = new AndMessageMatcher<Object>(delegate, delegate2);
matcher = new AndMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isFalse();
}
@@ -43,39 +43,39 @@ public class OrMessageMatcherTest {
@Test(expected = NullPointerException.class)
public void constructorNullArray() {
new OrMessageMatcher<Object>((MessageMatcher<Object>[]) null);
new OrMessageMatcher<>((MessageMatcher<Object>[]) null);
}
@Test(expected = IllegalArgumentException.class)
public void constructorArrayContainsNull() {
new OrMessageMatcher<Object>((MessageMatcher<Object>) null);
new OrMessageMatcher<>((MessageMatcher<Object>) null);
}
@SuppressWarnings("unchecked")
@Test(expected = IllegalArgumentException.class)
public void constructorEmptyArray() {
new OrMessageMatcher<Object>((MessageMatcher<Object>[]) new MessageMatcher[0]);
new OrMessageMatcher<>((MessageMatcher<Object>[]) new MessageMatcher[0]);
}
@Test(expected = IllegalArgumentException.class)
public void constructorNullList() {
new OrMessageMatcher<Object>((List<MessageMatcher<Object>>) null);
new OrMessageMatcher<>((List<MessageMatcher<Object>>) null);
}
@Test(expected = IllegalArgumentException.class)
public void constructorListContainsNull() {
new OrMessageMatcher<Object>(Arrays.asList((MessageMatcher<Object>) null));
new OrMessageMatcher<>(Arrays.asList((MessageMatcher<Object>) null));
}
@Test(expected = IllegalArgumentException.class)
public void constructorEmptyList() {
new OrMessageMatcher<Object>(Collections.<MessageMatcher<Object>> emptyList());
new OrMessageMatcher<>(Collections.emptyList());
}
@Test
public void matchesSingleTrue() {
when(delegate.matches(message)).thenReturn(true);
matcher = new OrMessageMatcher<Object>(delegate);
matcher = new OrMessageMatcher<>(delegate);
assertThat(matcher.matches(message)).isTrue();
}
@@ -83,7 +83,7 @@ public class OrMessageMatcherTest {
@Test
public void matchesMultiTrue() {
when(delegate.matches(message)).thenReturn(true);
matcher = new OrMessageMatcher<Object>(delegate, delegate2);
matcher = new OrMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isTrue();
}
@@ -91,7 +91,7 @@ public class OrMessageMatcherTest {
@Test
public void matchesSingleFalse() {
when(delegate.matches(message)).thenReturn(false);
matcher = new OrMessageMatcher<Object>(delegate);
matcher = new OrMessageMatcher<>(delegate);
assertThat(matcher.matches(message)).isFalse();
}
@@ -100,7 +100,7 @@ public class OrMessageMatcherTest {
public void matchesMultiBothFalse() {
when(delegate.matches(message)).thenReturn(false);
when(delegate2.matches(message)).thenReturn(false);
matcher = new OrMessageMatcher<Object>(delegate, delegate2);
matcher = new OrMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isFalse();
}
@@ -108,7 +108,7 @@ public class OrMessageMatcherTest {
@Test
public void matchesMultiSingleFalse() {
when(delegate.matches(message)).thenReturn(true);
matcher = new OrMessageMatcher<Object>(delegate, delegate2);
matcher = new OrMessageMatcher<>(delegate, delegate2);
assertThat(matcher.matches(message)).isTrue();
}
@@ -51,7 +51,7 @@ public class CsrfChannelInterceptorTests {
messageHeaders = SimpMessageHeaderAccessor.create(SimpMessageType.CONNECT);
messageHeaders.setNativeHeader(token.getHeaderName(), token.getToken());
messageHeaders.setSessionAttributes(new HashMap<String, Object>());
messageHeaders.setSessionAttributes(new HashMap<>());
messageHeaders.getSessionAttributes().put(CsrfToken.class.getName(), token);
}
@@ -55,7 +55,7 @@ public class CsrfTokenHandshakeInterceptorTests {
@Before
public void setup() {
httpRequest = new MockHttpServletRequest();
attributes = new HashMap<String, Object>();
attributes = new HashMap<>();
request = new ServletServerHttpRequest(httpRequest);
interceptor = new CsrfTokenHandshakeInterceptor();