diff options
Diffstat (limited to 'spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java')
-rw-r--r-- | spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java index 26fb5641..1c1ba726 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -28,16 +28,39 @@ import java.util.Iterator; */ public abstract class AbstractRequestCondition<T extends AbstractRequestCondition<T>> implements RequestCondition<T> { + /** + * Indicates whether this condition is empty, i.e. whether or not it + * contains any discrete items. + * @return {@code true} if empty; {@code false} otherwise + */ + public boolean isEmpty() { + return getContent().isEmpty(); + } + + /** + * Return the discrete items a request condition is composed of. + * <p>For example URL patterns, HTTP request methods, param expressions, etc. + * @return a collection of objects (never {@code null}) + */ + protected abstract Collection<?> getContent(); + + /** + * The notation to use when printing discrete items of content. + * <p>For example {@code " || "} for URL patterns or {@code " && "} + * for param expressions. + */ + protected abstract String getToStringInfix(); + + @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (obj != null && getClass() == obj.getClass()) { - AbstractRequestCondition<?> other = (AbstractRequestCondition<?>) obj; - return getContent().equals(other.getContent()); + if (other == null || getClass() != other.getClass()) { + return false; } - return false; + return getContent().equals(((AbstractRequestCondition<?>) other).getContent()); } @Override @@ -59,28 +82,4 @@ public abstract class AbstractRequestCondition<T extends AbstractRequestConditio return builder.toString(); } - /** - * Indicates whether this condition is empty, i.e. whether or not it - * contains any discrete items. - * @return {@code true} if empty; {@code false} otherwise - */ - public boolean isEmpty() { - return getContent().isEmpty(); - } - - - /** - * Return the discrete items a request condition is composed of. - * <p>For example URL patterns, HTTP request methods, param expressions, etc. - * @return a collection of objects, never {@code null} - */ - protected abstract Collection<?> getContent(); - - /** - * The notation to use when printing discrete items of content. - * <p>For example {@code " || "} for URL patterns or {@code " && "} - * for param expressions. - */ - protected abstract String getToStringInfix(); - } |