-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocialNetworkUtility.java
More file actions
26 lines (23 loc) · 988 Bytes
/
SocialNetworkUtility.java
File metadata and controls
26 lines (23 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** A collection of methods used by classes making up the Social Network.
* @author Billy Barbaro
*/
public class SocialNetworkUtility {
// An enum to let helper methods know their caller
public enum Caller {
ESTABLISH,
TEARDOWN
};
/** Checks the validity of this link. If it is uninitialized, throws an exception
* @param o the object to be tested if it is null
* @param type a string to help customize the message thrown with the excpetion
* @throws NullPointerException if the object passed in is null
*/
public static void checkNull(Object o, String type) {
if (o == null)
throw new NullPointerException(type + " may not be null.");
}
public static void checkValid(SocialNetworkObject sno, String objectType, String field) throws UninitializedObjectException {
if (!sno.isValid())
throw new UninitializedObjectException(objectType + " must be initialized before " + field + " is set.");
}
}