<commit_before>/*******************************************************************************
 * Copyright (c) 2014 Whizzo Software, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.whizzosoftware.hobson.api.variable;

import com.whizzosoftware.hobson.api.device.DeviceContext;

/**
 * A class representing a variable update.
 *
 * @author <NAME>
 */
public class VariableUpdate {
    private DeviceContext ctx;
    private String name;
    private Object value;
    private long timestamp;

    /**
     * Constructor.
     *
     * @param ctx the device context
     * @param name the variable name
     * @param value the variable value
     */
    public VariableUpdate(DeviceContext ctx, String name, Object value) {
        this(ctx, name, value, System.currentTimeMillis());
    }

    /**
     * Constructor.
     *
     * @param ctx the device context
     * @param name the variable name
     * @param value the variable value
     * @param timestamp the time the variable was updated
     */
    public VariableUpdate(DeviceContext ctx, String name, Object value, long timestamp) {
        this.ctx = ctx;
        this.name = name;
        this.value = value;
        this.timestamp = timestamp;
    }

    /**
     * Returns whether this is a global variable update.
     *
     * @return a boolean
     */
    public boolean isGlobal() {
        return ctx.isGlobal();
    }

    /**
     * Returns the device context associated with the update.
     *
     * @return a DeviceContext instance
     */
    public DeviceContext getDeviceContext() {
        return ctx;
    }

    /**
     * Returns the plugin ID that updated the variable.
     *
     * @return a plugin ID
     */
    public String getPluginId() {
        return ctx.getPluginId();
    }

    /**
     * Returns the device ID that updated the variable.
     *
     * @return a device ID
     */
    public String getDeviceId() {
        return ctx.getDeviceId();
    }

    /**
     * Returns the variable name that has changed.
     *
     * @return a String
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the new variable value.
     *
     * @return an Object
     */
    public Object getValue() {
        return value;
    }

    /**
     * Returns the time the variable update occurred.
     *
     * @return a long
     */
    public long getTimestamp() {
        return timestamp;
    }

    public String toString() {
        return ctx.toString() + "." + name + "=" + value;
    }
}<commit_msg>Added an indicator for variable updates being the first non-null value encountered.<commit_after>/*******************************************************************************
 * Copyright (c) 2014 Whizzo Software, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.whizzosoftware.hobson.api.variable;

import com.whizzosoftware.hobson.api.device.DeviceContext;

/**
 * A class representing a variable update.
 *
 * @author <NAME>
 */
public class VariableUpdate {
    private DeviceContext ctx;
    private String name;
    private Object value;
    private long timestamp;
    private boolean initial;

    /**
     * Constructor.
     *
     * @param ctx the device context
     * @param name the variable name
     * @param value the variable value
     */
    public VariableUpdate(DeviceContext ctx, String name, Object value) {
        this(ctx, name, value, System.currentTimeMillis());
    }

    /**
     * Constructor.
     *
     * @param ctx the device context
     * @param name the variable name
     * @param value the variable value
     * @param timestamp the time the variable was updated
     */
    public VariableUpdate(DeviceContext ctx, String name, Object value, long timestamp) {
        this(ctx, name, value, timestamp, false);
    }

    /**
     * Constructor.
     *
     * @param ctx the device context
     * @param name the variable name
     * @param value the variable value
     * @param timestamp the time the variable was updated
     */
    public VariableUpdate(DeviceContext ctx, String name, Object value, long timestamp, boolean initial) {
        this.ctx = ctx;
        this.name = name;
        this.value = value;
        this.timestamp = timestamp;
        this.initial = initial;
    }

    /**
     * Returns whether this is a global variable update.
     *
     * @return a boolean
     */
    public boolean isGlobal() {
        return ctx.isGlobal();
    }

    /**
     * Returns the device context associated with the update.
     *
     * @return a DeviceContext instance
     */
    public DeviceContext getDeviceContext() {
        return ctx;
    }

    /**
     * Returns the plugin ID that updated the variable.
     *
     * @return a plugin ID
     */
    public String getPluginId() {
        return ctx.getPluginId();
    }

    /**
     * Returns the device ID that updated the variable.
     *
     * @return a device ID
     */
    public String getDeviceId() {
        return ctx.getDeviceId();
    }

    /**
     * Returns the variable name that has changed.
     *
     * @return a String
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the new variable value.
     *
     * @return an Object
     */
    public Object getValue() {
        return value;
    }

    /**
     * Returns the time the variable update occurred.
     *
     * @return a long
     */
    public long getTimestamp() {
        return timestamp;
    }

    /**
     * Indicates if this is the first update for this variable (i.e. the first non-null value).
     *
     * @return a boolean
     */
    public boolean isInitial() {
        return initial;
    }

    /**
     * Sets the indicator that this is the first update for this variable (i.e. the first non-null value).
     *
     * @param initial a boolean
     */
    public void setInitial(boolean initial) {
        this.initial = initial;
    }

    public String toString() {
        return ctx.toString() + "." + name + "=" + value;
    }
}
{'fraction_non_alphanumeric': 0.1357034795763994, 'fraction_numerical': 0.002420574886535552, 'mean_word_length': 2.2502458210422813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6962738', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1684, 'n_words': 604}