001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Anahide Tchertchian 018 */ 019package org.nuxeo.targetplatforms.api.impl; 020 021import java.util.List; 022 023import org.nuxeo.targetplatforms.api.TargetPackage; 024 025/** 026 * {@link TargetPackage} implementation relying on an original implementation, useful for override when adding 027 * additional metadata. 028 * 029 * @since 5.7.1 030 */ 031public class TargetPackageExtension extends TargetExtension implements TargetPackage, Comparable<TargetPackage> { 032 033 private static final long serialVersionUID = 1L; 034 035 protected TargetPackage origPackage; 036 037 // needed by GWT serialization 038 protected TargetPackageExtension() { 039 super(); 040 } 041 042 public TargetPackageExtension(TargetPackage orig) { 043 super(orig); 044 origPackage = orig; 045 } 046 047 @Override 048 public List<String> getDependencies() { 049 return origPackage.getDependencies(); 050 } 051 052 @Override 053 public TargetPackage getParent() { 054 return origPackage.getParent(); 055 } 056 057 @Override 058 public int compareTo(TargetPackage o) { 059 // compare first on name, then on version 060 int comp = getName().compareTo(o.getName()); 061 if (comp == 0) { 062 comp = getVersion().compareTo(o.getVersion()); 063 } 064 return comp; 065 } 066 067}