/* * Copyright (C) 2016 TIBCO Jaspersoft Corporation. All rights reserved. * http://community.jaspersoft.com/project/mobile-sdk-android * * Unless you have purchased a commercial license agreement from TIBCO Jaspersoft, * the following license terms apply: * * This program is part of TIBCO Jaspersoft Mobile SDK for Android. * * TIBCO Jaspersoft Mobile SDK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * TIBCO Jaspersoft Mobile SDK 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with TIBCO Jaspersoft Mobile SDK for Android. If not, see * <http://www.gnu.org/licenses/lgpl>. */ package com.jaspersoft.android.sdk.network; /** * @author Tom Koptel * @since 2.3 */ final class Utils { private Utils() { } public static <T> T checkNotNull(T object, String message) { if (object == null) { throw new NullPointerException(message); } return object; } public static void checkArgument(boolean condition, String message) { if (condition) { throw new IllegalArgumentException(message); } } public static int headerToInt(com.squareup.okhttp.Headers headers, String key) { String header = headers.get(key); if (header == null) { return 0; } else { return Integer.valueOf(header); } } public static String normalizeBaseUrl(String url) { // If url is empty skip appending slash if (url == null || url.length() == 0) { return url; } if (url.endsWith("/")) { return url; } return url + "/"; } public static String joinString(CharSequence delimiter, Iterable tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); } sb.append(token); } return sb.toString(); } }