/******************************************************************************* * Copyright (c) 2007, 2010 Association for Decentralized Information Management * in Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.project.features.registry; import java.util.Collection; import java.util.HashSet; import java.util.Set; /** * A reference to a P2 feature group installable unit (IU). * *
* Contains an ID and an optional version specifier. If a version is not
* specified, it is null
. The version can be either a single
* version or a version range.
*
*
* Serializes to the format ID/version
*
* @author Tuukka Lehtonen
*/
public class GroupReference implements Comparabletrue
if id's are equal
*/
public boolean idEquals(GroupReference other) {
return id.equals(other.id);
}
/**
* Checks whether this feature reference fulfills the demand imposed by the
* specified feature reference. Fulfillment implies matching feature ID and
* a version match or a version range for this feature reference that includes the
* absolute version in the specified feature reference.
*
* @param ref
* @return
*/
public boolean includes(GroupReference request) {
if (!id.equals(request.id))
return false;
if (version == null)
// Any version will do.
return true;
// TODO: implement version checking
// ASSERT: request.version is an absolute version, not a range
// If this.version is a absolute version, check that request.version is
// greater or equal than this.version.
// If this.version is a version range, check that the range includes
// request.version.
return true;
}
@Override
public int compareTo(GroupReference o) {
int idDelta = id.compareTo(o.id);
if (idDelta != 0)
return idDelta;
// TODO: comparability based on version comparability
return 0;
}
}