From: Debayan Sutradhar Date: Fri, 09 Oct 2020 20:54:39 +0530 Subject: First Commit --- First Commit --- --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file --- /dev/null +++ b/Util.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file --- /dev/null +++ b/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.StreamPi + Util + 1.0 + + + + 11 + 11 + + + \ No newline at end of file --- /dev/null +++ b/src/main/java/com/StreamPi/Util/Exception/MinorException.java @@ -0,0 +1,14 @@ +package com.StreamPi.Util.Exception; + +public class MinorException extends StreamPiException { + + public MinorException(String message) + { + super(message); + } + + public MinorException(String title, String message) + { + super(title, message); + } +} --- /dev/null +++ b/src/main/java/com/StreamPi/Util/Exception/SevereException.java @@ -0,0 +1,13 @@ +package com.StreamPi.Util.Exception; + +public class SevereException extends StreamPiException{ + public SevereException(String message) + { + super(message); + } + + public SevereException(String title, String message) + { + super(title, message); + } +} --- /dev/null +++ b/src/main/java/com/StreamPi/Util/Exception/StreamPiException.java @@ -0,0 +1,42 @@ +package com.StreamPi.Util.Exception; + +public class StreamPiException extends Exception { + private String title; + private String message; + + + public StreamPiException(String message) + { + super(message); + + this.title = ""; + this.message = message; + } + + public StreamPiException(String title, String message) + { + super(message); + this.title = title; + this.message = message; + } + + public String getShortMessage() + { + return message; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public void setShortMessage(String message) + { + this.message = message; + } +} --- /dev/null +++ b/src/main/java/com/StreamPi/Util/Version/Version.java @@ -0,0 +1,95 @@ +package com.StreamPi.Util.Version; + + +import com.StreamPi.Util.Exception.MinorException; + +public class Version { + private int major, minor, revision; + + public Version() + { + major = 0; + minor = 0; + revision = 0; + } + + public Version(int major, int minor, int revision) + { + this.major = major; + this.minor = minor; + this.revision = revision; + } + + public Version(String version) throws MinorException + { + String[] v = version.trim().split("\\."); + if(v.length == 3) + { + try + { + major = Integer.parseInt(v[0]); + minor = Integer.parseInt(v[1]); + revision = Integer.parseInt(v[2]); + } + catch (NumberFormatException e) + { + throw new MinorException("Invalid versioning!"); + } + } + else + { + throw new MinorException("Invalid versioning!"); + } + } + + public int getMajor() + { + return major; + } + + public int getMinor() + { + return minor; + } + + public int getRevision() + { + return minor; + } + + public String getText() + { + return this.major+"."+this.minor+"."+this.revision; + } + + public void setMajor(int major) + { + this.major = major; + } + + public void setMinor(int minor) + { + this.minor = minor; + } + + public void setRevision(int revision) + { + this.revision = revision; + } + + public boolean isBiggerThan(Version version) + { + if(major>version.major) + return true; + else + { + if(minor > version.minor) + return true; + else + { + return revision > version.revision; + } + } + } + +} --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,5 @@ +module com.StreamPi.Util { + exports com.StreamPi.Util.Exception; + //exports com.StreamPi.Util.Networking; + exports com.StreamPi.Util.Version; +} \ No newline at end of file