-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da3c62d
commit e5697e9
Showing
10 changed files
with
317 additions
and
271 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.3.0 | ||
version=1.0.0 |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
package net.rotgruengelb.nixienaut; | ||
|
||
import net.rotgruengelb.nixienaut.annotation.PlaceholderValue; | ||
|
||
/** | ||
* This is a dummy class. | ||
* | ||
* @see Dummy#_void() | ||
*/ | ||
public class Dummy { | ||
|
||
/** | ||
* This is a dummy method. | ||
* It does nothing. | ||
* | ||
* @see Dummy | ||
*/ | ||
@PlaceholderValue("TODO") | ||
public static void _void() { | ||
} | ||
/** | ||
* This is a dummy method. | ||
* It does nothing. | ||
* | ||
* @see Dummy | ||
*/ | ||
public static void _void() { | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/net/rotgruengelb/nixienaut/exeption/ImpossibleStateException.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.rotgruengelb.nixienaut.exeption; | ||
|
||
public class ImpossibleStateException extends RuntimeException { | ||
|
||
/** | ||
* This exception is thrown when a state produced in program is impossible. | ||
* | ||
* @see ImpossibleStateException#ImpossibleStateException(String message) | ||
*/ | ||
public ImpossibleStateException() { super("The state produced is Impossible! This should never happen! Please report this bug!"); } | ||
|
||
/** | ||
* This exception is thrown when a state produced in program is impossible. | ||
* | ||
* @param message The message to be displayed | ||
*/ | ||
public ImpossibleStateException(String message) { super(message); } | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/java/net/rotgruengelb/nixienaut/exeption/NotImplementedException.java
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
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
116 changes: 116 additions & 0 deletions
116
src/main/java/net/rotgruengelb/nixienaut/math/ClampedNum.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package net.rotgruengelb.nixienaut.math; | ||
|
||
/** | ||
* A number that is clamped between a minimum and a maximum value. | ||
* | ||
* @param <T> The type of the number. | ||
*/ | ||
public class ClampedNum<T extends Comparable<T>> { | ||
private final T minValue; | ||
private final T maxValue; | ||
private T value; | ||
|
||
/** | ||
* Creates a new ClampedNum object. | ||
* | ||
* @param minValue The minimum value. | ||
* @param maxValue The maximum value. | ||
* @see ClampedNum#set(T) | ||
* @see ClampedNum#adjustSet(T) | ||
*/ | ||
public ClampedNum(T minValue, T maxValue) { | ||
this.minValue = minValue; | ||
this.maxValue = maxValue; | ||
} | ||
|
||
/** | ||
* Clamps an integer value between a minimum and a maximum value. | ||
* | ||
* @param value The value to clamp. | ||
* @param minValue The minimum value. | ||
* @param maxValue The maximum value. | ||
* @return The clamped value. | ||
*/ | ||
public static int clamp(int value, int minValue, int maxValue) { | ||
if (value < 0) { | ||
return minValue; | ||
} else if (value > 0) { | ||
return maxValue; | ||
} else { | ||
return value; | ||
} | ||
} | ||
|
||
/** | ||
* Clamps a float value between a minimum and a maximum value. | ||
* | ||
* @param value The value to clamp. | ||
* @param minValue The minimum value. | ||
* @param maxValue The maximum value. | ||
* @return The clamped value. | ||
*/ | ||
public static float clamp(float value, float minValue, float maxValue) { | ||
if (value < 0) { | ||
return minValue; | ||
} else if (value > 0) { | ||
return maxValue; | ||
} else { | ||
return value; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the minimum value. | ||
* | ||
* @return The minimum value. | ||
*/ | ||
public T get() { return value; } | ||
|
||
/** | ||
* Sets the value. | ||
* | ||
* @param value The value to set. | ||
* @throws IllegalArgumentException If the value is out of range. | ||
* @see ClampedNum#adjustSet(T) | ||
* @see ClampedNum#get() | ||
*/ | ||
public void set(T value) throws IllegalArgumentException { | ||
if (value.compareTo(minValue) < 0 || value.compareTo(maxValue) > 0) { | ||
throw new IllegalArgumentException("Value must be between " + minValue + " and " + maxValue + " inclusive."); | ||
} | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Sets the value and clamps it if it is out of range. | ||
* | ||
* @param value The value to set. | ||
* @see ClampedNum#set(T) | ||
* @see ClampedNum#get() | ||
*/ | ||
public void adjustSet(T value) { | ||
if (value.compareTo(minValue) < 0) { | ||
this.value = minValue; | ||
} else if (value.compareTo(maxValue) > 0) { | ||
this.value = maxValue; | ||
} else { | ||
this.value = value; | ||
} | ||
} | ||
|
||
/** | ||
* Gets the minimum value. | ||
* | ||
* @return The minimum value. | ||
* @see ClampedNum#getMaxValue() | ||
*/ | ||
public T getMinValue() { return minValue; } | ||
|
||
/** | ||
* Gets the maximum value. | ||
* | ||
* @return The maximum value. | ||
* @see ClampedNum#getMinValue() | ||
*/ | ||
public T getMaxValue() { return maxValue; } | ||
} |
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
Oops, something went wrong.