Created
February 29, 2016 16:37
-
-
Save mkorman/d81fae873c08b78761f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class InstallHandlerBase implements InstallHandler | |
{ | |
public abstract Version GetLastPackageVersionWithoutFeature (); | |
public void onInstall(InstallContext context) | |
{ | |
if (isFreshInstall (context)) | |
{ | |
OnFreshInstall (context); | |
} | |
else if (previousVersionContainsFeature(context)) | |
{ | |
OnUpgradeFromRecentPackage (context); | |
} | |
else | |
{ | |
OnUpgradeFromOldPackage (context); | |
} | |
} | |
protected Boolean isFreshInstall (InstallContext context) | |
{ | |
return context.previousVersion() == null; | |
} | |
protected boolean previousVersionContainsFeature(InstallContext context) | |
{ | |
Version previousVersion = context.PreviousVersion(); | |
return previousVersion.compareTo (GetLastPackageVersionWithoutFeature()) > 0; | |
} | |
public virtual void OnUpgradeFromOldPackage (InstallContext context) {} | |
public virtual void OnUpgradeFromRecentPackage (InstallContext context) {} | |
public virtual void OnFreshInstall (InstallContext context) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment