If you think the Android project DistributedMemory 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
/* Open Data Service
Copyright (C) 2013 Tsysin Konstantin, Reischl Patrick
/*www.java2s.com*/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/package org.faudroids.distributedmemory.utils;
import java.util.List;
publicfinalclass Assert {
private Assert() { }
publicstaticvoid assertNotNull(Object... objects) {
for (Object o : objects) {
if (o == null) thrownew NullPointerException("param is null");
}
}
publicstaticvoid assertTrue(boolean expression) {
assertTrue(expression, "expression is false");
}
publicstaticvoid assertTrue(boolean expression, String errorMsg) {
assertFalse(!expression, errorMsg);
}
publicstaticvoid assertFalse(boolean expression, String errorMsg) {
if (expression) thrownew IllegalArgumentException(errorMsg);
}
publicstaticvoid assertEquals(Object o1, Object o2, String errorMsg) {
if (o1 == null && o2 == null) return;
if (o1 == null || o2 == null) thrownew IllegalArgumentException(errorMsg);
if (!o1.equals(o2)) thrownew IllegalArgumentException(errorMsg);
}
publicstaticvoid assertValidIdx(List<?> list, int idx) {
if (idx < 0 || idx >= list.size())
thrownew IndexOutOfBoundsException("idx was " + idx + " but size is " + list.size());
}
}