<commit_before>/**
 * Copyright 2014-present Liquid Data Intelligence S.A.
 *
 * 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 io.lqd.sdk.model;

import io.lqd.sdk.LQLog;
import io.lqd.sdk.LiquidTools;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

import android.content.Context;

public abstract class LQModel implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * Generate a random unique id
	 * @return
	 */
	public static String newIdentifier() {
		UUID uid = UUID.randomUUID();
		String uidStr = uid.toString();
		uidStr = uidStr.replace("-", "");
		long timeSince1970 = Calendar.getInstance().getTimeInMillis();
		return uidStr.substring(0, 16) + "" + timeSince1970;
	}

	/*
	 * *******************
	 * Attributes Assertion
	 * *******************
	 */

	/**
	 * Check if the key have invalid chars: { $ . \0 } are the invalid attributes
	 * @param key key that will be checked
	 * @param raiseException if true will raise IllegalArgumentException, otherwise will Log
	 * @return true if the key is valid, false otherwise
	 */
	public static boolean validKey(String key, boolean raiseException) {
		boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0"));
		if(!isValid) {
			LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)");
		}
		return isValid;
	}
<commit_msg>Change the UUID generation algorithm<commit_after>/**
 * Copyright 2014-present Liquid Data Intelligence S.A.
 *
 * 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 io.lqd.sdk.model;

import io.lqd.sdk.LQLog;
import io.lqd.sdk.LiquidTools;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;

import android.content.Context;

public abstract class LQModel implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * Generate a random unique id
	 * @return
	 */
	public static String newIdentifier() {
		String uid = UUID.randomUUID().toString().toUpperCase();
		long timeSince1970 = Calendar.getInstance().getTimeInMillis();
		return uid + "-" + String.valueOf(timeSince1970).substring(0,10);
	}

	/*
	 * *******************
	 * Attributes Assertion
	 * *******************
	 */

	/**
	 * Check if the key have invalid chars: { $ . \0 } are the invalid attributes
	 * @param key key that will be checked
	 * @param raiseException if true will raise IllegalArgumentException, otherwise will Log
	 * @return true if the key is valid, false otherwise
	 */
	public static boolean validKey(String key, boolean raiseException) {
		boolean isValid = (!key.contains("$") && !key.contains(".") && !key.contains("\0"));
		if(!isValid) {
			LiquidTools.exceptionOrLog(raiseException, "Key: (" + key + ") contains invalid chars: (. $ \\0)");
		}
		return isValid;
	}

{'fraction_non_alphanumeric': 0.1257303108202851, 'fraction_numerical': 0.010750175274596869, 'mean_word_length': 4.101311084624553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4769267', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1195, 'n_words': 422}