Merge pull request #188 from olivergierke/SPR-10038
# By Oliver Gierke * SPR-10038: Introduce AnnotationAwareOrderComparator#INSTANCE
This commit is contained in:
commit
40e8d3f1a9
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2012 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,12 +27,15 @@ import org.springframework.core.Ordered;
|
||||||
* annotation value (if any).
|
* annotation value (if any).
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Oliver Gierke
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
* @see org.springframework.core.Ordered
|
* @see org.springframework.core.Ordered
|
||||||
* @see Order
|
* @see Order
|
||||||
*/
|
*/
|
||||||
public class AnnotationAwareOrderComparator extends OrderComparator {
|
public class AnnotationAwareOrderComparator extends OrderComparator {
|
||||||
|
|
||||||
|
public static AnnotationAwareOrderComparator INSTANCE = new AnnotationAwareOrderComparator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getOrder(Object obj) {
|
protected int getOrder(Object obj) {
|
||||||
if (obj instanceof Ordered) {
|
if (obj instanceof Ordered) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.core.annotation;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {@link AnnotationAwareOrderComparator}.
|
||||||
|
*
|
||||||
|
* @author Oliver Gierke
|
||||||
|
*/
|
||||||
|
public class AnnotationAwareOrderComparatorTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void instanceVariableIsAnAnnotationAwareOrderComparator() {
|
||||||
|
assertThat(AnnotationAwareOrderComparator.INSTANCE, is(instanceOf(AnnotationAwareOrderComparator.class)));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue