<commit_before>/**
 * Mutinack mutation detection program.
 * Copyright (C) 2014-2016 <NAME>
 *
 * 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, version 3.
 *
 * 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 uk.org.cinquin.mutinack.misc_util;

import java.io.Serializable;

public class SettableDouble implements Serializable {

	private static final long serialVersionUID = 8580008588332408546L;

	private double value;
	private boolean initialized;

	public SettableDouble(double d) {
		initialized = true;
		this.value = d;
	}

	public SettableDouble() {
		initialized = false;
	}

	private void checkInitialized() {
		if (!initialized) {
			throw new IllegalStateException("Not initialized");
		}
	}

	public final double get() {
		checkInitialized();
		return value;
	}

	public final void set(double value) {
		initialized = true;
		this.value = value;
	}

	public final void set(SettableDouble i) {
		initialized = true;
		set(i.value);
	}

	public final double incrementAndGet() {
		checkInitialized();
		return ++value;
	}

	public final double addAndGet(double i) {
		checkInitialized();
		value += i;
		return value;
	}

	public double getAndIncrement() {
		checkInitialized();
		return value++;
	}

	@Override
	public String toString() {
		return Double.toString(value);
	}

}<commit_msg>Make SettableDouble extend Number for convenience of use from other classes.<commit_after>/**
 * Mutinack mutation detection program.
 * Copyright (C) 2014-2016 <NAME>
 *
 * 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, version 3.
 *
 * 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 uk.org.cinquin.mutinack.misc_util;

import java.io.Serializable;

public class SettableDouble extends Number implements Serializable {

	private static final long serialVersionUID = 8580008588332408546L;

	private double value;
	private boolean initialized;

	public SettableDouble(double d) {
		initialized = true;
		this.value = d;
	}

	public SettableDouble() {
		initialized = false;
	}

	private void checkInitialized() {
		if (!initialized) {
			throw new IllegalStateException("Not initialized");
		}
	}

	public final double get() {
		checkInitialized();
		return value;
	}

	public final void set(double value) {
		initialized = true;
		this.value = value;
	}

	public final void set(SettableDouble i) {
		initialized = true;
		set(i.value);
	}

	public final double incrementAndGet() {
		checkInitialized();
		return ++value;
	}

	public final double addAndGet(double i) {
		checkInitialized();
		value += i;
		return value;
	}

	public double getAndIncrement() {
		checkInitialized();
		return value++;
	}

	@Override
	public String toString() {
		return Double.toString(value);
	}

	@Override
	public int intValue() {
		checkInitialized();
		return (int) value;
	}

	@Override
	public long longValue() {
		checkInitialized();
		return (long) value;
	}

	@Override
	public float floatValue() {
		checkInitialized();
		return (float) value;
	}

	@Override
	public double doubleValue() {
		checkInitialized();
		return value;
	}

}
{'fraction_non_alphanumeric': 0.08919254658385094, 'fraction_numerical': 0.01391304347826087, 'mean_word_length': 3.9888475836431225, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1561242', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1154, 'n_words': 431}