-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from szymonpoltorak/comments-test-doc
Comments test and docs
- Loading branch information
Showing
38 changed files
with
1,056 additions
and
86 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
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
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
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
7 changes: 7 additions & 0 deletions
7
...app-backend/src/main/java/razepl/dev/socialappbackend/exceptions/NegativeIdException.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,7 @@ | ||
package razepl.dev.socialappbackend.exceptions; | ||
|
||
public class NegativeIdException extends IllegalArgumentException { | ||
public NegativeIdException(String message) { | ||
super(message); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...nd/src/main/java/razepl/dev/socialappbackend/exceptions/validators/ArgumentValidator.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,42 @@ | ||
package razepl.dev.socialappbackend.exceptions.validators; | ||
|
||
import razepl.dev.socialappbackend.exceptions.NegativeIdException; | ||
import razepl.dev.socialappbackend.exceptions.NullArgumentException; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
public class ArgumentValidator { | ||
private ArgumentValidator() { | ||
} | ||
|
||
public static void throwIfNegativeId(long... ids) { | ||
if (!ArgumentValidator.areIdPositive(ids)) { | ||
throw new NegativeIdException("There are negative id's!"); | ||
} | ||
} | ||
|
||
public static void throwIfNegativeId(int... ids) { | ||
if (!ArgumentValidator.areIdPositive(ids)) { | ||
throw new NegativeIdException("There are negative id's!"); | ||
} | ||
} | ||
|
||
public static void throwIfNull(Object... objects) { | ||
if (!ArgumentValidator.areArgumentsNullSafe(objects)) { | ||
throw new NullArgumentException("Encountered null arguments in method!"); | ||
} | ||
} | ||
|
||
private static boolean areIdPositive(long... ids) { | ||
return Arrays.stream(ids).noneMatch(id -> id < 0L); | ||
} | ||
|
||
private static boolean areIdPositive(int... ids) { | ||
return Arrays.stream(ids).noneMatch(id -> id < 0); | ||
} | ||
|
||
private static boolean areArgumentsNullSafe(Object... objects) { | ||
return Arrays.stream(objects).noneMatch(Objects::isNull); | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
...-backend/src/main/java/razepl/dev/socialappbackend/exceptions/validators/NullChecker.java
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
Oops, something went wrong.