本文整理汇总了Java中com.facebook.stetho.common.Util.throwIfNot方法的典型用法代码示例。如果您正苦于以下问题:Java Util.throwIfNot方法的具体用法?Java Util.throwIfNot怎么用?Java Util.throwIfNot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.stetho.common.Util
的用法示例。
在下文中一共展示了Util.throwIfNot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerDescriptor
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
@Override
public DescriptorMap registerDescriptor(Class<?> elementClass, Descriptor descriptor) {
Util.throwIfNull(elementClass);
Util.throwIfNull(descriptor);
Util.throwIf(descriptor.isInitialized());
Util.throwIfNot(mIsInitializing);
// Cannot register two descriptors for one class
if (mMap.containsKey(elementClass)) {
throw new UnsupportedOperationException();
}
// Cannot reuse one descriptor for two classes
if (mMap.containsValue(descriptor)) {
throw new UnsupportedOperationException();
}
mMap.put(elementClass, descriptor);
return this;
}
示例2: endInit
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
public DescriptorMap endInit() {
Util.throwIfNot(mIsInitializing);
Util.throwIfNull(mHost);
mIsInitializing = false;
for (final Class<?> elementClass : mMap.keySet()) {
final Descriptor descriptor = mMap.get(elementClass);
if (descriptor instanceof ChainedDescriptor) {
final ChainedDescriptor chainedDescriptor = (ChainedDescriptor) descriptor;
Class<?> superClass = elementClass.getSuperclass();
Descriptor superDescriptor = getImpl(superClass);
chainedDescriptor.setSuper(superDescriptor);
}
descriptor.initialize(mHost);
}
return this;
}
示例3: flattenRows
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
/**
* Flatten all columns and all rows of a cursor to a single array. The array cannot be
* interpreted meaningfully without the number of columns.
*
* @param cursor
* @param limit Maximum number of rows to process.
* @return List of Java primitives matching the value type of each column, converted to
* strings.
*/
private static ArrayList<String> flattenRows(Cursor cursor, int limit) {
Util.throwIfNot(limit >= 0);
ArrayList<String> flatList = new ArrayList<>();
final int numColumns = cursor.getColumnCount();
for (int row = 0; row < limit && cursor.moveToNext(); row++) {
for (int column = 0; column < numColumns; column++) {
switch (cursor.getType(column)) {
case Cursor.FIELD_TYPE_NULL:
flatList.add(null);
break;
case Cursor.FIELD_TYPE_INTEGER:
flatList.add(String.valueOf(cursor.getLong(column)));
break;
case Cursor.FIELD_TYPE_FLOAT:
flatList.add(String.valueOf(cursor.getDouble(column)));
break;
case Cursor.FIELD_TYPE_BLOB:
flatList.add(blobToString(cursor.getBlob(column)));
break;
case Cursor.FIELD_TYPE_STRING:
default:
flatList.add(cursor.getString(column));
break;
}
}
}
if (!cursor.isAfterLast()) {
for (int column = 0; column < numColumns; column++) {
flatList.add("{truncated}");
}
}
return flatList;
}
示例4: add
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
public void add(Activity activity) {
Util.throwIfNull(activity);
Util.throwIfNot(Looper.myLooper() == Looper.getMainLooper());
mActivities.add(new WeakReference<>(activity));
for (Listener listener : mListeners) {
listener.onActivityAdded(activity);
}
}
示例5: remove
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
public void remove(Activity activity) {
Util.throwIfNull(activity);
Util.throwIfNot(Looper.myLooper() == Looper.getMainLooper());
if (removeFromWeakList(mActivities, activity)) {
for (Listener listener : mListeners) {
listener.onActivityRemoved(activity);
}
}
}
示例6: setHost
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
public DescriptorMap setHost(Descriptor.Host host) {
Util.throwIfNull(host);
Util.throwIfNot(mIsInitializing);
Util.throwIfNotNull(mHost);
mHost = host;
return this;
}
示例7: isDevtoolsMethod
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
/**
* Determines if the method is a {@link ChromeDevtoolsMethod}, and validates accordingly
* if it is.
*
* @throws IllegalArgumentException Thrown if it is a {@link ChromeDevtoolsMethod} but
* it otherwise fails to satisfy requirements.
*/
private static boolean isDevtoolsMethod(Method method) throws IllegalArgumentException {
if (!method.isAnnotationPresent(ChromeDevtoolsMethod.class)) {
return false;
} else {
Class<?> args[] = method.getParameterTypes();
String methodName = method.getDeclaringClass().getSimpleName() + "." + method.getName();
Util.throwIfNot(args.length == 2,
"%s: expected 2 args, got %s",
methodName,
args.length);
Util.throwIfNot(args[0].equals(JsonRpcPeer.class),
"%s: expected 1st arg of JsonRpcPeer, got %s",
methodName,
args[0].getName());
Util.throwIfNot(args[1].equals(JSONObject.class),
"%s: expected 2nd arg of JSONObject, got %s",
methodName,
args[1].getName());
Class<?> returnType = method.getReturnType();
if (!returnType.equals(void.class)) {
Util.throwIfNot(JsonRpcResult.class.isAssignableFrom(returnType),
"%s: expected JsonRpcResult return type, got %s",
methodName,
returnType.getName());
}
return true;
}
}
示例8: verifyThreadAccess
import com.facebook.stetho.common.Util; //导入方法依赖的package包/类
/**
* Enforces that the current thread is the same thread that the {@link Handler} is associated
* with.
* @throws IllegalStateException if the current thread is not the same thread that the
* {@link Handler} is associated with.
*/
public static void verifyThreadAccess(Handler handler) {
Util.throwIfNot(checkThreadAccess(handler));
}