List of usage examples for java.lang IllegalStateException IllegalStateException
public IllegalStateException(Throwable cause)
From source file:com.ace.erp.common.inject.support.InjectBaseDependencyHelper.java
public static void findAndInjectGenericServiceDependency(BaseController<?, ?> baseController) { final Set<Object> candidates = findDependencies(baseController, BaseComponent.class); if (candidates.size() > 1) { throw new IllegalStateException( "expect 1 @BaseComponent anntation AbstractService subclass bean, but found " + candidates.size() + ", please check class [" + baseController.getClass() + "] @BaseComponent annotation."); }/* w w w. ja v a 2 s. c o m*/ Object genericService = candidates.iterator().next(); if (genericService.getClass().isAssignableFrom(BaseComponent.class)) { throw new IllegalStateException("[" + baseController.getClass() + "] @BaseComponent annotation bean " + "must be AbstractService subclass"); } baseController.setGenericService((GenericService) genericService); }
From source file:com.thinkbiganalytics.spark.shell.SparkClientUtil.java
/** * Gets the major version number from the Spark client. *//*from w ww. j a v a2s. co m*/ public static String getMajorVersion() { if (majorVersion == null) { try { majorVersion = StringUtils.substringBefore(getVersion(), "."); } catch (final IOException e) { throw new IllegalStateException("Unable to determine Spark version"); } } return majorVersion; }
From source file:com.ram.topup.api.ws.security.filter.TokenUtils.java
public static String computeSignature(String username, String password, long expires) { StringBuilder signatureBuilder = new StringBuilder(); signatureBuilder.append(username);/*from ww w.j a v a2 s . c om*/ signatureBuilder.append(":"); signatureBuilder.append(expires); signatureBuilder.append(":"); signatureBuilder.append(password); signatureBuilder.append(":"); signatureBuilder.append(TokenUtils.MAGIC_KEY); MessageDigest digest; try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No MD5 algorithm available!"); } return new String(Hex.encode(digest.digest(signatureBuilder.toString().getBytes()))); }
From source file:com.mattermost.service.jacksonconverter.PromiseConverterFactory.java
@Override public CallAdapter<?> get(final Type returnType, Annotation[] annotations, Retrofit retrofit) { Class<?> cls = TypeFactory.rawClass(returnType); if (!Promise.class.isAssignableFrom(cls)) return null; if (!(returnType instanceof ParameterizedType)) { throw new IllegalStateException("Promise must have generic type (e.g., Promise<T>)"); }//from w w w. j a v a 2 s. c o m final Type responseType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; return new CallAdapter<Promise<?>>() { @Override public Type responseType() { return responseType; } @Override public <R> Promise<R> adapt(Call<R> call) { Promise<R> promise = new Promise<R>(); call.enqueue(promise.callback()); promise.onStarted(); return promise; } }; }
From source file:net.openid.appauth.JsonUtil.java
public static void put(@NonNull JSONObject json, @NonNull String field, @NonNull int value) { checkNotNull(json, "json must not be null"); checkNotNull(field, "field must not be null"); checkNotNull(value, "value must not be null"); try {// www .java2 s .co m json.put(field, value); } catch (JSONException ex) { throw new IllegalStateException("JSONException thrown in violation of contract, ex"); } }
From source file:com.parse.PointerEncoder.java
@Override public JSONObject encodeRelatedObject(ParseObject object) { // Ensure the ParseObject has an id so it can be encoded as a pointer. if (object.getObjectId() == null) { // object that hasn't been saved. throw new IllegalStateException("unable to encode an association with an unsaved ParseObject"); }/* ww w . j av a2 s . co m*/ return super.encodeRelatedObject(object); }
From source file:com.l2jfree.gameserver.model.skills.conditions.ConditionLogic.java
public final void add(Condition condition) { if (condition == null) throw new IllegalStateException("Tried to add a 'null' condition to an <" + getClass().getSimpleName().replace("ConditionLogic", "").toLowerCase() + "> condition"); _conditions = ArrayUtils.add(_conditions, condition); }
From source file:Main.java
public static void writeXml(Document doc, OutputStream outputStream) { try {//from www . j a v a 2s . c o m // Prepare the DOM document for writing Source source = new DOMSource(doc); // Prepare the output file Result result = new StreamResult(outputStream); // Write the DOM document to the file Transformer xformer = TransformerFactory.newInstance().newTransformer(); try { xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3"); } catch (IllegalArgumentException e) { // ignore } try { xformer.setOutputProperty(OutputKeys.INDENT, "yes"); } catch (IllegalArgumentException e) { // ignore } xformer.transform(source, result); } catch (TransformerConfigurationException e) { throw new IllegalStateException(e); } catch (TransformerException e) { throw new IllegalStateException(e); } }
From source file:com.partnet.automation.util.PathUtils.java
/** * Search for a specific file nested inside of a specific path * /*from w ww . j a v a2 s .co m*/ * @param path * - path that contains the file * @param fileName * - file name of the file * @return - the file that was found * * @throws IllegalStateException * - if more then one file with that specific name was found. */ public static File getFileInPath(final String path, final String fileName) { File dir = new File(path); // find the correct file List<File> files = (List<File>) FileUtils.listFiles(dir, FileFilterUtils.nameFileFilter(fileName), TrueFileFilter.TRUE); LOG.debug("Files found: {}", Arrays.asList(files)); if (files.size() != 1) { throw new IllegalStateException(String.format( "Searching for a file '%s' did not result in the correct number of files! Found %d, expected %d", fileName, files.size(), 1)); } return files.get(0); }
From source file:com.wingnest.play2.origami.IdManager.java
public String encodeId(final ORID identity) { if (identity.isTemporary()) { throw new IllegalStateException("Temporary object does not ganerates id : " + identity.toString()); }//from w w w . ja v a2 s.c o m if (ID_HANDLER == null) { final String rid = identity.toString(); return Codec.byteToHexString(rid.getBytes()); } return ID_HANDLER.encode(identity); }