com.geotab.model.entity.controller.Controller Maven / Gradle / Ivy
package com.geotab.model.entity.controller;
import static com.geotab.model.entity.controller.GoFaultController.GO_FAULT_CONTROLLER_ID;
import static com.geotab.model.entity.controller.LegacyFaultController.LEGACY_FAULT_CONTROLLER_ID;
import static com.geotab.model.entity.controller.NoController.NO_CONTROLLER_ID;
import static com.geotab.model.entity.controller.ProprietaryFaultController.PROPRIETARY_FAULT_CONTROLLER_ID;
import com.geotab.model.entity.NameEntityWithVersion;
import com.geotab.model.entity.source.Source;
import com.geotab.util.Util;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
/**
* The controller that the diagnostic belongs to. Controllers could be ABS controller, suspension controller etc.
*/
@Getter @Setter
@NoArgsConstructor
@SuperBuilder
public class Controller extends NameEntityWithVersion {
/**
* Controller diagnostic code (if applicable).
*/
protected Short code;
/**
* The message identification code for the controller of the diagnostic (if applicable).
*/
protected Short codeId;
/**
* The standard (format) of the {@link Source}.
*/
protected Source source;
public static Controller fromSystem(String id) {
if (Util.isEmpty(id)) return null;
return switch (id) {
case GO_FAULT_CONTROLLER_ID -> GoFaultController.getInstance();
case LEGACY_FAULT_CONTROLLER_ID -> LegacyFaultController.getInstance();
case PROPRIETARY_FAULT_CONTROLLER_ID -> ProprietaryFaultController.getInstance();
case NO_CONTROLLER_ID -> NoController.getInstance();
default -> null;
};
}
}