@Override public String description(String fieldName, Comparable first, Comparable second) { return StringUtils.format("%s (%s) less than %s", fieldName, first, second); } },
/** * Constructs and returns a string object that is the result of interposing a separator between the elements of the list */ public static <T> String join(List<T> list) { return join(list, ","); }
private static String toPrettyDate(Object value) { if (value instanceof Apptentive.DateTime) { Apptentive.DateTime date = (Apptentive.DateTime) value; return StringUtils.toPrettyDate(date.getDateTime()); } return StringUtils.toString(value); } }
public EncryptionKey(@NonNull String hexKey) { if (StringUtils.isNullOrEmpty(hexKey)) { throw new IllegalArgumentException("Hex key is null or empty"); } this.key = new SecretKeySpec(StringUtils.hexToBytes(hexKey), ALGORITHM); this.transformation = DEFAULT_TRANSFORMATION; this.hexKey = hexKey; }
private MessageEntry findMessageEntry(String nonce) { for (MessageEntry entry : messageEntries) { if (StringUtils.equal(entry.nonce, nonce)) { return entry; } } return null; }
public boolean hasSessionId() { return !StringUtils.isNullOrEmpty(sessionId); }
public HttpJsonRequest createFetchInteractionsRequest(String conversationToken, String conversationId, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationToken)) { throw new IllegalArgumentException("Conversation token is null or empty"); } if (StringUtils.isNullOrEmpty(conversationId)) { throw new IllegalArgumentException("Conversation id is null or empty"); } final String endPoint = StringUtils.format(ENDPOINT_INTERACTIONS, conversationId); HttpJsonRequest request = createJsonRequest(endPoint, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "Bearer " + conversationToken); request.addListener(listener); return request; }
@Override public String toString() { return String.format("name=%s userInfo={%s}", name, StringUtils.toString(userInfo)); } }
public static String table(Object[][] rows) { return table(rows, null); }
/** * @return true is Apptimize SDK library version is supported. */ public static boolean isSupportedLibraryVersion() { String libraryVersion = getLibraryVersion(); if (libraryVersion == null) { return false; } String[] tokens = libraryVersion.split("\\."); if (tokens.length != 3) { return false; } int major = StringUtils.parseInt(tokens[0], 0); return major >= 3; }
protected String exitTypeToDataJson(ApptentiveViewExitType exitType) { return exitType.isShouldAddToEngage() ? StringUtils.asJson("cause", exitType.getName()) : null; }
log0(level, StringUtils.getStackTrace(throwable));
public void setOsName(String osName) { if (!StringUtils.equal(this.osName, osName)) { this.osName = osName; notifyDataChanged(); } }
public boolean hasSession() { return !StringUtils.isNullOrEmpty(sessionId); }
public HttpJsonRequest createAppConfigurationRequest(String conversationId, String token, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationId)) { throw new IllegalArgumentException("Conversation id is null or empty"); } if (StringUtils.isNullOrEmpty(token)) { throw new IllegalArgumentException("Conversation token is null or empty"); } String endPoint = StringUtils.format(ENDPOINT_CONFIGURATION, conversationId); HttpJsonRequest request = createJsonRequest(endPoint, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "Bearer " + token); request.addListener(listener); return request; }
public static String table(Object[][] rows, String title) { int[] columnSizes = new int[rows[0].length]; for (Object[] row : rows) { for (int i = 0; i < row.length; ++i) { columnSizes[i] = Math.max(columnSizes[i], toString(row[i]).length()); } } StringBuilder line = new StringBuilder(); int totalSize = 0; for (int i = 0; i < columnSizes.length; ++i) { totalSize += columnSizes[i]; } totalSize += columnSizes.length > 0 ? (columnSizes.length - 1) * " | ".length() : 0; while (totalSize-- > 0) { line.append('-'); } StringBuilder result = new StringBuilder(line); for (Object[] row : rows) { result.append("\n"); for (int i = 0; i < row.length; ++i) { if (i > 0) { result.append(" | "); } result.append(String.format("%-" + columnSizes[i] + "s", row[i])); } } result.append("\n").append(line); return result.toString(); }
}; ApptentiveLog.v(PAYLOADS, "%s (%d payload(s)):\n%s", title, payloadCount, StringUtils.table(rows)); } catch (Exception e) { ApptentiveLog.e(CONVERSATION, e, "Exception while printing metadata");
@Override public String description(String fieldName, Comparable first, Comparable second) { return StringUtils.format("%s ('%s') is less than or equal to '%s'", fieldName, first, second); } },
public void setAdvertiserId(String advertiserId) { if (!StringUtils.equal(this.advertiserId, advertiserId)) { this.advertiserId = advertiserId; notifyDataChanged(); } }
public ApptentiveNotification(String name, Map<String, Object> userInfo) { if (StringUtils.isNullOrEmpty(name)) { throw new IllegalArgumentException("Name is null or empty"); } this.name = name; this.userInfo = userInfo; }