01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.core;
18:
19: /**
20: * Interface that can be implemented by objects that should be
21: * orderable, for example in a Collection.
22: *
23: * <p>The actual order can be interpreted as prioritization, with
24: * the first object (with the lowest order value) having the highest
25: * priority.
26: *
27: * <p>Note that there is a 'priority' marker for this interface:
28: * {@link PriorityOrdered}. Order values expressed by PriorityOrdered
29: * objects always apply before order values of 'plain' Ordered values.
30: *
31: * @author Juergen Hoeller
32: * @since 07.04.2003
33: * @see OrderComparator
34: * @see org.springframework.core.annotation.Order
35: */
36: public interface Ordered {
37:
38: /**
39: * Useful constant for the highest precedence value.
40: * @see java.lang.Integer#MIN_VALUE
41: */
42: int HIGHEST_PRECEDENCE = Integer.MIN_VALUE;
43:
44: /**
45: * Useful constant for the lowest precedence value.
46: * @see java.lang.Integer#MAX_VALUE
47: */
48: int LOWEST_PRECEDENCE = Integer.MAX_VALUE;
49:
50: /**
51: * Return the order value of this object, with a
52: * higher value meaning greater in terms of sorting.
53: * <p>Normally starting with 0 or 1, with {@link #LOWEST_PRECEDENCE}
54: * indicating greatest. Same order values will result in arbitrary
55: * positions for the affected objects.
56: * <p>Higher value can be interpreted as lower priority,
57: * consequently the first object has highest priority
58: * (somewhat analogous to Servlet "load-on-startup" values).
59: * <p>Note that order values below 0 are reserved for framework
60: * purposes. Application-specified values should always be 0 or
61: * greater, with only framework components (internal or third-party)
62: * supposed to use lower values.
63: * @return the order value
64: * @see #LOWEST_PRECEDENCE
65: */
66: int getOrder();
67:
68: }
|