com.geotab.model.entity.faultdata.FaultData Maven / Gradle / Ivy
/*
*
* 2020 Copyright (C) Geotab Inc. All rights reserved.
*/
package com.geotab.model.entity.faultdata;
import static com.geotab.model.serialization.filter.FaultDataFilterProvider.FAULT_DATA_FILTER;
import static java.lang.Boolean.FALSE;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.geotab.model.entity.Entity;
import com.geotab.model.entity.controller.Controller;
import com.geotab.model.entity.controller.NoController;
import com.geotab.model.entity.device.Device;
import com.geotab.model.entity.diagnostic.Diagnostic;
import com.geotab.model.entity.failuremode.FailureMode;
import com.geotab.model.entity.flashcode.FlashCode;
import com.geotab.model.entity.user.NoUser;
import com.geotab.model.entity.user.User;
import com.geotab.model.enumeration.DtcClass;
import com.geotab.model.enumeration.DtcSeverity;
import com.geotab.model.enumeration.FaultLampState;
import com.geotab.model.enumeration.FaultState;
import com.geotab.model.serialization.ControllerAsStringSerializer;
import com.geotab.model.serialization.UserAsStringSerializer;
import java.time.LocalDateTime;
import java.util.Optional;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* A record that represents a fault code record from the engine system of the specific {@link
* com.geotab.model.entity.device.Device}.
*/
@NoArgsConstructor
@Getter
@Setter
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@JsonFilter(FAULT_DATA_FILTER)
public class FaultData extends Entity {
/**
* Whether the amber warning lamp state.
*/
private Boolean amberWarningLamp = FALSE;
/**
* The {@link Controller} code related to the fault code; if applicable.
*/
@JsonSerialize(using = ControllerAsStringSerializer.class)
private Controller controller = NoController.getInstance();
/**
* The number of times the fault occurred.
*/
private Integer count;
/**
* The date and time at which the event occurred.
*/
private LocalDateTime dateTime;
/**
* The {@link Device} that generated the fault.
*/
private Device device;
/**
* The {@link Diagnostic} associated with the fault.
*/
private Diagnostic diagnostic;
/**
* The date and time that the DismissUser dismissed the fault.
*/
private LocalDateTime dismissDateTime;
/**
* The {@link User} that dismissed the fault.
*/
@JsonSerialize(using = UserAsStringSerializer.class)
private User dismissUser = NoUser.getInstance();
/**
* The {@link FailureMode} of the fault; if applicable.
*/
private FailureMode failureMode;
/**
* The {@link FaultLampState} of a J1939 vehicle.
*/
private FaultLampState faultLampState;
/**
* The {@link FaultState} code from the engine system of the specific device.
*/
private FaultState faultState;
/**
* The {@link FlashCode} associated with the fault.
*/
private FlashCode flashCode;
/**
* The malfunction light state.
*/
private Boolean malfunctionLamp = FALSE;
/**
* Whether the protect warning lamp is on.
*/
private Boolean protectWarningLamp = FALSE;
/**
* Whether the red stop lamp is on.
*/
private Boolean redStopLamp = FALSE;
/**
* The {@link DtcSeverity} of the fault.
*/
private DtcSeverity severity;
/**
* The {@link DtcClass} code of the fault.
*/
private DtcClass classCode;
/**
* The source address for enhanced faults.
*/
private Integer sourceAddress;
@Builder
public FaultData(String id, Boolean amberWarningLamp,
Controller controller, Integer count, LocalDateTime dateTime,
Device device, Diagnostic diagnostic, LocalDateTime dismissDateTime,
User dismissUser, FailureMode failureMode,
FaultLampState faultLampState, FaultState faultState,
FlashCode flashCode, Boolean malfunctionLamp, Boolean protectWarningLamp,
Boolean redStopLamp, DtcSeverity severity, DtcClass classCode, Integer sourceAddress) {
super(id);
this.amberWarningLamp = Optional.ofNullable(amberWarningLamp).orElse(FALSE);
this.controller = Optional.ofNullable(controller).orElse(NoController.getInstance());
this.count = count;
this.dateTime = dateTime;
this.device = device;
this.diagnostic = diagnostic;
this.dismissDateTime = dismissDateTime;
this.dismissUser = Optional.ofNullable(dismissUser).orElse(NoUser.getInstance());
this.failureMode = failureMode;
this.faultLampState = faultLampState;
this.faultState = faultState;
this.flashCode = flashCode;
this.malfunctionLamp = Optional.ofNullable(malfunctionLamp).orElse(FALSE);
this.protectWarningLamp = Optional.ofNullable(protectWarningLamp).orElse(FALSE);
this.redStopLamp = Optional.ofNullable(redStopLamp).orElse(FALSE);
this.severity = severity;
this.classCode = classCode;
this.sourceAddress = sourceAddress;
}
}