projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add unit test for Sone accessor
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
data
/
Profile.java
diff --git
a/src/main/java/net/pterodactylus/sone/data/Profile.java
b/src/main/java/net/pterodactylus/sone/data/Profile.java
index
9c7da48
..
0f9b8ff
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Profile.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Profile.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - Profile.java - Copyright © 2010–201
3
David Roden
+ * Sone - Profile.java - Copyright © 2010–201
6
David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-325,7
+325,9
@@
public class Profile implements Fingerprintable {
*/
public Field addField(String fieldName) throws IllegalArgumentException {
checkNotNull(fieldName, "fieldName must not be null");
*/
public Field addField(String fieldName) throws IllegalArgumentException {
checkNotNull(fieldName, "fieldName must not be null");
- checkArgument(fieldName.length() > 0, "fieldName must not be empty");
+ if (fieldName.length() == 0) {
+ throw new EmptyFieldName();
+ }
if (getFieldByName(fieldName) != null) {
throw new DuplicateField();
}
if (getFieldByName(fieldName) != null) {
throw new DuplicateField();
}
@@
-556,6
+558,13
@@
public class Profile implements Fingerprintable {
}
/**
}
/**
+ * Exception that signals the addition of a field with an empty name.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ public static class EmptyFieldName extends IllegalArgumentException { }
+
+ /**
* Exception that signals the addition of a field that already exists.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
* Exception that signals the addition of a field that already exists.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>