1 /* 2 * Copyright 2002-2006 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 * @author Juergen Hoeller 28 * @since 07.04.2003 29 * @see OrderComparator 30 * @see org.springframework.core.annotation.Order 31 */ 32 public interface Ordered { 33 34 /** 35 * Useful constant for the highest precedence value. 36 * @see java.lang.Integer#MIN_VALUE 37 */ 38 int HIGHEST_PRECEDENCE = Integer.MIN_VALUE; 39 40 /** 41 * Useful constant for the lowest precedence value. 42 * @see java.lang.Integer#MAX_VALUE 43 */ 44 int LOWEST_PRECEDENCE = Integer.MAX_VALUE; 45 46 47 /** 48 * Return the order value of this object, with a 49 * higher value meaning greater in terms of sorting. 50 * <p>Normally starting with 0 or 1, with {@link #LOWEST_PRECEDENCE} 51 * indicating greatest. Same order values will result in arbitrary 52 * positions for the affected objects. 53 * <p>Higher value can be interpreted as lower priority, 54 * consequently the first object has highest priority 55 * (somewhat analogous to Servlet "load-on-startup" values). 56 * <p>Note that order values below 0 are reserved for framework 57 * purposes. Application-specified values should always be 0 or 58 * greater, with only framework components (internal or third-party) 59 * supposed to use lower values. 60 * @return the order value 61 * @see #LOWEST_PRECEDENCE 62 */ 63 int getOrder(); 64 65 } 66