List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:com.gistlabs.mechanize.filters.DefaultMechanizeChainFilter.java
public DefaultMechanizeChainFilter(final MechanizeFilter theEnd) { if (theEnd == null) throw new NullPointerException("The end of the processing chain can't be null!"); this.theEnd = theEnd; }
From source file:com.github.rvesse.airline.utils.predicates.LocaleSensitiveStringFinder.java
public LocaleSensitiveStringFinder(String value, Locale locale) { if (locale == null) throw new NullPointerException("locale cannot be null"); this.value = value; this.collator = Collator.getInstance(locale); }
From source file:com.netflix.config.ConfigurationBackedDynamicPropertySupportImpl.java
public ConfigurationBackedDynamicPropertySupportImpl(AbstractConfiguration config) { if (config == null) { throw new NullPointerException("config is null"); }/*from w w w. java2s .c o m*/ this.config = config; }
From source file:cz.muni.pa165.carparkapp.DAOImpl.LoanDAOImpl.java
@Override public Loan addLoan(Loan loan) { if (loan == null) { throw new NullPointerException("Argument can't be null"); }/*from ww w .j ava 2 s . co m*/ em.persist(loan); return loan; }
From source file:FileUtils.java
/** * //from www . java 2 s . c o m * Starts at the directory given and tests to see whether it is empty; if so, * it deletes it and moves up the directory tree, deleting empty directories * until it finds a non-empty one. * * @param directory * The first directory to test. * * @throws IOException * <ul> * <li>If the directory does not exist or the user does not have * permission to delete it or its parents.</li> * </ul> * */ public static void pruneEmptyDirectories(File directory) throws IOException { if (directory == null) throw new NullPointerException("NullFile"); if (!directory.isDirectory()) { Object[] filler = { directory.getAbsolutePath() }; String message = "NotDirectory"; throw new IllegalArgumentException(message); } // // check to see if the directory is now empty and, if so, delete it // too, moving up the tree until we find one with stuff in it // while (directory != null) { File[] directoryFiles = directory.listFiles(); // // if the directory has files, we're done // if (directoryFiles.length > 0) break; if (!directory.delete()) { Object[] filler = { directory.getAbsolutePath() }; String message = "DeleteFailed"; throw new IOException(message); } // // go up the tree // directory = directory.getParentFile(); } }
From source file:net.portalblock.untamedchat.bungee.UCConfig.java
public static void load() { final String NEW_LINE = System.getProperty("line.separator"); File cfgDir = new File("plugins/UntamedChat"); if (!cfgDir.exists()) { UntamedChat.getInstance().getLogger().info("No config directory found, generating one now!"); cfgDir.mkdir();//from ww w . j a va2 s. c o m } File configFile = new File(cfgDir + "/config.json"); if (!configFile.exists()) { UntamedChat.getInstance().getLogger().info("No config file found, generating one now!"); try { configFile.createNewFile(); InputStream is = UCConfig.class.getResourceAsStream("/config.json"); String line; if (is == null) throw new NullPointerException("is"); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); FileWriter configWriter = new FileWriter(configFile); while ((line = reader.readLine()) != null) { configWriter.write(line + NEW_LINE); } configWriter.flush(); configWriter.close(); reader.close(); is.close(); } catch (IOException e) { e.printStackTrace(); } } try { BufferedReader reader = new BufferedReader(new FileReader(configFile)); StringBuilder configBuilder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { configBuilder.append(line); } JSONObject config = new JSONObject(configBuilder.toString()); TARGET_FORMAT = config.optString("target_format", "&6{sender} &7-> &6Me&7: {msg}"); SENDER_FORMAT = config.optString("sender_format", "&6Me &7-> &6{target}&7: {msg}"); SOCIAL_SPY_FORMAT = config.optString("social_spy_format", "{sender} -> {target}: {msg}"); GLOBAL_FORMAT = config.optString("global_format", "&7[&6{server}&7] [&6{sender}&7]: &r{msg}"); gcDefault = config.optBoolean("global_chat_default", false); chatCoolDowns = config.optBoolean("enable_chat_cooldown", true); spDefault = config.optBoolean("social_spy_default", false); chatCooldown = config.optLong("chat_cooldown", 10); SPAM_MESSAGE = config.optString("spam_message", "&7[&cUntamedChat&7] &cDon't spam the chat!"); JSONObject commands = config.optJSONObject("commands"); if (commands == null) { msgAliases = new String[] { "msg", "m" }; replyAliases = new String[] { "reply", "r" }; globalAliases = new String[] { "globalchat", "global", "g" }; socialSpyAliases = new String[] { "socialspy", "sp", "spy" }; } else { msgAliases = makeCommandArray(commands.optJSONArray("msg"), "msg", "m"); replyAliases = makeCommandArray(commands.optJSONArray("reply"), "reply", "r"); globalAliases = makeCommandArray(commands.optJSONArray("global_chat"), "globalchat", "global", "g"); socialSpyAliases = makeCommandArray(commands.optJSONArray("social_spy"), "socialspy", "sp", "spy"); } } catch (IOException e) { e.printStackTrace(); } }
From source file:com.github.sebhoss.contract.verifier.SpringBasedParameterNamesLookup.java
@Override public String[] lookupParameterNames(final Method method) { final String[] parameterNames = nameDiscoverer.getParameterNames(method); if (parameterNames == null) { throw new NullPointerException("Discovered parameter names are NULL"); //$NON-NLS-1$ }// w w w . j a va 2 s. co m return parameterNames; }
From source file:Main.java
/** * Determines the {@literal "length"} of a given object. This method * currently understands:<ul>/*from w ww . jav a2 s . c o m*/ * <li>{@link Collection}</li> * <li>{@link Map}</li> * <li>{@link CharSequence}</li> * <li>{@link Array}</li> * <li>{@link Iterable}</li> * <li>{@link Iterator}</li> * </ul> * * <p>More coming! * * @param o {@code Object} whose length we want. Cannot be {@code null}. * * @return {@literal "Length"} of {@code o}. * * @throws NullPointerException if {@code o} is {@code null}. * @throws IllegalArgumentException if the method doesn't know how to test * whatever type of object {@code o} might be. */ @SuppressWarnings({ "WeakerAccess" }) public static int len(final Object o) { if (o == null) { throw new NullPointerException("Null arguments do not have a length"); } if (o instanceof Collection<?>) { return ((Collection<?>) o).size(); } else if (o instanceof Map<?, ?>) { return ((Map<?, ?>) o).size(); } else if (o instanceof CharSequence) { return ((CharSequence) o).length(); } else if (o instanceof Iterator<?>) { int count = 0; Iterator<?> it = (Iterator<?>) o; while (it.hasNext()) { it.next(); count++; } return count; } else if (o instanceof Iterable<?>) { return len(((Iterable<?>) o).iterator()); } throw new IllegalArgumentException("Don't know how to find the length of a " + o.getClass().getName()); }
From source file:TableModel.RestaurantTableModel.java
public String[] getColumnNames() { if (columnNames != null) return columnNames; else/*from ww w.j a va 2s.c om*/ throw new NullPointerException("String[] variable columnNames is null!!"); }
From source file:net.adamcin.httpsig.http.apache4.Http4Util.java
public static void enableAuth(final AbstractHttpClient client, final Keychain keychain, final KeyId keyId) { if (client == null) { throw new NullPointerException("client"); }/*from w w w . j a v a 2s.c om*/ if (keychain == null) { throw new NullPointerException("keychain"); } client.getAuthSchemes().register(Constants.SCHEME, new AuthSchemeFactory() { public AuthScheme newInstance(HttpParams params) { return new Http4SignatureAuthScheme(); } }); Signer signer = new Signer(keychain, keyId); client.getCredentialsProvider().setCredentials(AuthScope.ANY, new SignerCredentials(signer)); client.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, Arrays.asList(Constants.SCHEME)); HttpClientParams.setAuthenticating(client.getParams(), true); }