If you think the Android project BagOfPix listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright 2010-present Facebook.//www.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.facebook.internal;
import java.util.Collection;
/**
* com.facebook.internal is solely for the use of other packages within the Facebook SDK for Android. Use of
* any of the classes in this package is unsupported, and they may be modified or removed without warning at
* any time.
*/publicfinalclass Validate {
publicstaticvoid notNull(Object arg, String name) {
if (arg == null) {
thrownew NullPointerException("Argument '" + name + "' cannot be null");
}
}
publicstatic <T> void notEmpty(Collection<T> container, String name) {
if (container.isEmpty()) {
thrownew IllegalArgumentException("Container '" + name + "' cannot be empty");
}
}
publicstatic <T> void containsNoNulls(Collection<T> container, String name) {
Validate.notNull(container, name);
for (T item : container) {
if (item == null) {
thrownew NullPointerException("Container '" + name + "' cannot contain null values");
}
}
}
publicstaticvoid containsNoNullOrEmpty(Collection<String> container, String name) {
Validate.notNull(container, name);
for (String item : container) {
if (item == null) {
thrownew NullPointerException("Container '" + name + "' cannot contain null values");
}
if (item.length() == 0) {
thrownew IllegalArgumentException("Container '" + name + "' cannot contain empty values");
}
}
}
publicstatic <T> void notEmptyAndContainsNoNulls(Collection<T> container, String name) {
Validate.containsNoNulls(container, name);
Validate.notEmpty(container, name);
}
publicstaticvoid notNullOrEmpty(String arg, String name) {
if (Utility.isNullOrEmpty(arg)) {
thrownew IllegalArgumentException("Argument '" + name + "' cannot be null or empty");
}
}
publicstaticvoid oneOf(Object arg, String name, Object... values) {
for (Object value : values) {
if (value != null) {
if (value.equals(arg)) {
return;
}
} else {
if (arg == null) {
return;
}
}
}
thrownew IllegalArgumentException("Argument '" + name + "' was not one of the allowed values");
}
}