com.eg.agent.android.ApplicationInformation Maven / Gradle / Ivy
package com.eg.agent.android;
import com.eg.google.gson.JsonArray;
import com.eg.google.gson.JsonObject;
import com.eg.google.gson.JsonPrimitive;
import static org.gradle.internal.impldep.org.apache.commons.lang.Validate.notEmpty;
public class ApplicationInformation {
private String appBuild;
private String appName;
private String packageId;
private int versionCode;
private String appVersion;
public String getPackageId() {
return packageId;
}
public void setPackageId(String packageId) {
this.packageId = packageId;
}
public int getVersionCode() {
return versionCode;
}
public void setVersionCode(int versionCode) {
this.versionCode = versionCode;
}
public ApplicationInformation() {
this.versionCode = -1;
}
public String getAppBuild() {
return appBuild;
}
public void setAppBuild(String appBuild) {
this.appBuild = appBuild;
}
private static ApplicationInformation instance = new ApplicationInformation();
public static ApplicationInformation getInstance() {
return instance;
}
public void setAppName(String AppName) {
appName = AppName;
}
public String getAppName() {
return appName;
}
public void setPackage_name(String PackageName) {
packageId = PackageName;
}
public void setPackage_versionCode(int PackageVersionCode) {
versionCode = PackageVersionCode;
}
public void setAppVersion(String appVersion) {
appVersion = appVersion;
}
public String getPackage_name() {
return packageId;
}
public int getPackage_versionCode() {
return versionCode;
}
public String getAppVersion() {
return appVersion;
}
public JsonObject asJsonObject() {
JsonObject data = new JsonObject();
data.add("App Name", new JsonPrimitive(this.appName));
data.add("packageId", new JsonPrimitive(this.packageId));
data.add("Version code", new JsonPrimitive(this.versionCode));
data.add("Package version name ", new JsonPrimitive(this.appVersion));
return data;
}
public static ApplicationInformation newFromJson(JsonObject jsonObject) {
ApplicationInformation info = new ApplicationInformation();
info.appName = jsonObject.get("appName").getAsString();
info.packageId = jsonObject.get("packageId").getAsString();
info.versionCode = jsonObject.get("versionCode").getAsInt();
info.appVersion = jsonObject.get("appVersion").getAsString();
return info;
}
public ApplicationInformation(String appName, String appVersion, String packageId, String appBuild) {
this();
this.appName = appName;
this.appVersion = appVersion;
this.packageId = packageId;
this.appBuild = appBuild;
}
public JsonArray asJsonArray() {
JsonArray array = new JsonArray();
notEmpty(this.appName);
array.add(new JsonPrimitive(this.appName));
notEmpty(this.appVersion);
array.add(new JsonPrimitive(this.appVersion));
notEmpty(this.packageId);
array.add(new JsonPrimitive(this.packageId));
return array;
}
public boolean isAppUpgrade(ApplicationInformation that) {
if (that.versionCode == -1) {
return this.versionCode >= 0 && that.appVersion != null;
} else {
return this.versionCode > that.versionCode;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy