1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with this 4 * work for additional information regarding copyright ownership. The ASF 5 * licenses this file to You under the Apache License, Version 2.0 (the 6 * "License"); you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law 9 * or agreed to in writing, software distributed under the License is 10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language 12 * governing permissions and limitations under the License. 13 */ 14 package org.apache.webbeans.decorator; 15 16 import java.io.Serializable; 17 import java.util.Comparator; 18 19 import javax.enterprise.inject.spi.Decorator; 20 21 public class DecoratorComparator<T> implements Comparator<Decorator<T>>, Serializable 22 { 23 24 /** default serial version UID */ 25 private static final long serialVersionUID = 1L; 26 27 public int compare(Decorator<T> o1, Decorator<T> o2) 28 { 29 WebBeansDecorator<T> src = (WebBeansDecorator<T>) o1; 30 WebBeansDecorator<T> target = (WebBeansDecorator<T>) o2; 31 32 if (o1.equals(o2)) 33 { 34 return 0; 35 } 36 else 37 { 38 Class<?> o1Clazz = src.getClazz(); 39 Class<?> o2Clazz = target.getClazz(); 40 41 return DecoratorsManager.getInstance().compare(o1Clazz, o2Clazz); 42 43 } 44 } 45 46 }