ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Scokart" <gscok...@gmail.com>
Subject ModuleRevisionId factories and constructors
Date Fri, 04 May 2007 11:19:15 GMT



In ModuleRevisionId, is there any reason to have both factory methods and
public constructor mixed.  I'm wondering which one should be used.  And why
there is 2 different style (if there is any reasons).

Here is all the methods that exists:

    public static ModuleRevisionId newInstance(String organisation, String
name, String revision) {
        return new ModuleRevisionId(new ModuleId(organisation, name),
revision);
    }
    public static ModuleRevisionId newInstance(String organisation, String
name, String revision, Map extraAttributes) {
        return new ModuleRevisionId(new ModuleId(organisation, name),
revision, extraAttributes);
    }
    public static ModuleRevisionId newInstance(String organisation, String
name, String branch, String revision) {
        return new ModuleRevisionId(new ModuleId(organisation, name),
branch, revision);
    }
    public static ModuleRevisionId newInstance(String organisation, String
name, String branch, String revision, Map extraAttributes) {
        return new ModuleRevisionId(new ModuleId(organisation, name),
branch, revision, extraAttributes);
    }
	public static ModuleRevisionId newInstance(ModuleRevisionId mrid,
String rev) {
		return new ModuleRevisionId(mrid.getModuleId(),
mrid.getBranch(), rev, mrid.getExtraAttributes());
	}
    
    public ModuleRevisionId(ModuleId moduleId, String revision) {
        this(moduleId, null, revision, null);
    }
    public ModuleRevisionId(ModuleId moduleId, String branch, String
revision) {
        this(moduleId, branch, revision, null);
    }
    public ModuleRevisionId(ModuleId moduleId, String revision, Map
extraAttributes) {
    	this(moduleId, null, revision, extraAttributes);
    }
    public ModuleRevisionId(ModuleId moduleId, String branch, String
revision, Map extraAttributes) {
        super(null, extraAttributes);
        _moduleId = moduleId;
        _branch = branch == null ?
IvyContext.getContext().getSettings().getDefaultBranch(moduleId) : branch;
        _revision = revision == null ? Ivy.getWorkingRevision() : revision;
        _hash = _hashCode(); //stored for performance reasons, hashCode is
very used in many maps
        setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY,
_moduleId.getOrganisation());
        setStandardAttribute(IvyPatternHelper.MODULE_KEY,
_moduleId.getName());
        setStandardAttribute(IvyPatternHelper.BRANCH_KEY, _branch);
        setStandardAttribute(IvyPatternHelper.REVISION_KEY, _revision);
    }


Gilles


Mime
View raw message