List of usage examples for java.lang UnsupportedOperationException UnsupportedOperationException
public UnsupportedOperationException(Throwable cause)
From source file:Main.java
public static <T> T unsupported(final String op, final Object... a) { final StringBuilder msg = new StringBuilder(INITIAL_SIZE); msg.append("Nobody told me how to run "); msg.append(op);// www . j a v a 2 s.com if (a.length > 0) { msg.append(" with parameters of class: "); for (final Object o : a) { msg.append(o == null ? "null" : o.getClass().getSimpleName()); msg.append(", "); } msg.delete(msg.length() - 2, msg.length()); msg.append('.'); } throw new UnsupportedOperationException(msg.toString()); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getPref(Context _context, String prefKey, T defValue, Class<T> clazz) { final SharedPreferences pref = getDefaultSharedPreferences(_context); if (Long.class == clazz) { return (T) (Long.valueOf(pref.getLong(prefKey, (Long) defValue))); } else if (Integer.class == clazz) { return (T) (Integer.valueOf(pref.getInt(prefKey, (Integer) defValue))); } else if (defValue instanceof String) { return (T) (pref.getString(prefKey, String.valueOf(defValue))); } else if (defValue instanceof Boolean) { return (T) (Boolean.valueOf(pref.getBoolean(prefKey, (Boolean) defValue))); }//from w ww .j a v a2 s . com throw new UnsupportedOperationException("Class " + clazz + " not supported"); }
From source file:com.wormsim.animals.DevelopmentFunction.java
/** * Returns a development function which is represented by the specified * string. Note this may be a bit challenging. * * @param arg The string representation of the function. * * @return The function.//from w w w .j a v a2 s.com */ public static DevelopmentFunction interpret(String arg) { // TODO: interpret development function. throw new UnsupportedOperationException("NOT YET IMPLEMENTED"); }
From source file:Main.java
/** * Execute an {@link AsyncTask} on a thread pool * * @param <T> Task argument type/*from w w w . j av a 2s . c om*/ * @param forceSerial True to force the task to run in serial order * @param task Task to execute * @param args Optional arguments to pass to * {@link AsyncTask#execute(Object[])} */ @SuppressLint("NewApi") public static <T> WeakReference<AsyncTask<T, ?, ?>> execute(final boolean forceSerial, final AsyncTask<T, ?, ?> task, final T... args) { final WeakReference<AsyncTask<T, ?, ?>> taskReference = new WeakReference<AsyncTask<T, ?, ?>>(task); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT) { throw new UnsupportedOperationException("This class can only be used on API 4 and newer."); } try { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || forceSerial) { taskReference.get().execute(args); } else { taskReference.get().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args); } } catch (Exception e) { e.printStackTrace(); } return taskReference; }
From source file:Main.java
/** add serialized helper */ private static void addSerialized(StringBuilder result, String key, Object value) { result.append(key.replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)).append(SERIALIZATION_SEPARATOR); if (value instanceof Integer) { result.append('i').append(value); } else if (value instanceof Double) { result.append('d').append(value); } else if (value instanceof Long) { result.append('l').append(value); } else if (value instanceof String) { result.append('s').append(value.toString().replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)); } else if (value instanceof Boolean) { result.append('b').append(value); } else {/*w w w .j a v a2 s. co m*/ throw new UnsupportedOperationException(value.getClass().toString()); } result.append(SERIALIZATION_SEPARATOR); }
From source file:Main.java
/** * Put an arbitrary object into a {@link ContentValues} *///from w w w .j a v a2 s .c om public static void putInto(ContentValues target, String key, Object value) { if (value instanceof Boolean) { target.put(key, (Boolean) value); } else if (value instanceof Byte) { target.put(key, (Byte) value); } else if (value instanceof Double) { target.put(key, (Double) value); } else if (value instanceof Float) { target.put(key, (Float) value); } else if (value instanceof Integer) { target.put(key, (Integer) value); } else if (value instanceof Long) { target.put(key, (Long) value); } else if (value instanceof Short) { target.put(key, (Short) value); } else if (value instanceof String) { target.put(key, (String) value); } else { throw new UnsupportedOperationException("Could not handle type " + //$NON-NLS-1$ value.getClass()); } }
From source file:com.netflix.hystrix.serial.SerialHystrixRequestEvents.java
@Deprecated public static byte[] toBytes(HystrixRequestEvents requestEvents) { throw new UnsupportedOperationException( "Not implemented anymore. Will be implemented in a new class shortly"); }
From source file:com.netflix.hystrix.serial.SerialHystrixMetric.java
@Deprecated public static String fromByteBufferToString(ByteBuffer bb) { throw new UnsupportedOperationException( "Not implemented anymore. Will be implemented in a new class shortly"); }
From source file:com.anyun.sample.db.doma.BeanLoader.java
private static void assertContext() { if (applicationContext == null) { throw new UnsupportedOperationException("Set this class as bean to your @Configuration class."); }/*from www. j av a 2 s. c o m*/ }
From source file:Main.java
/** * Extracts child elements from node whith type <code>ELEMENT_NODE</code>. * * @param node root node of XML document for search. * @return iterator with proper node childs. *//*from w ww . j a v a 2 s. c om*/ public static Iterator<Element> getChildElements(final Node node) { // node.normalize(); return new Iterator<Element>() { private final NodeList nodes = node.getChildNodes(); private int nextPos = 0; private Element nextElement = seekNext(); public boolean hasNext() { return nextElement != null; } public Element next() { if (nextElement == null) throw new NoSuchElementException(); final Element result = nextElement; nextElement = seekNext(); return result; } public void remove() { throw new UnsupportedOperationException("operation not supported"); } private Element seekNext() { for (int i = nextPos, len = nodes.getLength(); i < len; i++) { final Node childNode = nodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { nextPos = i + 1; return (Element) childNode; } } return null; } }; }