/** * Check for null parameter when not allowed. * * @throws NullPointerException * if parameter is null (the message indicates the name of the parameter). */ public static void notNull(Object parameter, String parameterName) { if (parameter == null) throw new NullPointerException(HiveMindMessages.paramNotNull(parameterName)); }
/** * Technically, this should be a synchronized method, but the _shutdown variable hardly ever * changes, and the consequences are pretty minimal. See HIVEMIND-104. */ private void checkShutdown() { if (_shutdown) throw new ApplicationRuntimeException(HiveMindMessages.registryShutdown()); }
/** * Invokes {@link #getLocation(Object)}, then translate the result to a string value, or * "unknown location" if null. */ public static String getLocationString(Object object) { Location l = getLocation(object); if (l != null) return l.toString(); return HiveMindMessages.unknownLocation(); }
/** * Check that a parameter is not null, and assignable to a particular type. * * @throws ClassCastException * if not assignable (with a useable message) */ public static void isAssignable(Object parameter, Class expectedType, String parameterName) { Defense.notNull(parameter, parameterName); if (!expectedType.isAssignableFrom(parameter.getClass())) throw new ClassCastException(HiveMindMessages.paramWrongType( parameterName, parameter, expectedType)); } }
public static ApplicationRuntimeException createRegistryShutdownException() { return new ApplicationRuntimeException(HiveMindMessages.registryShutdown()); }