com.geotab.model.enumeration.VehicleFeatureCategory Maven / Gradle / Ivy
/*
*
* 2020 Copyright (C) Geotab Inc. All rights reserved.
*/
package com.geotab.model.enumeration;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
/**
* The names of vehicle feature categories, including external devices detected by the device and
* features that are manually activated by the server.
*
* Features enabled by the external device detected message must correspond with the device
* specification at: https://docs.google.com/a/geotab.com/document/d/1K8TfHPRpJ6biiBFGK3Ueb_Iegx6JOdOHWJJKITsEviQ/edit#heading=h.ju4vlgs9y6xy.
*/
@Slf4j
public enum VehicleFeatureCategory {
// External device detected
/**
* An unknown device.
*/
UNKNOWN_DEVICE("UnknownDevice", 0),
/**
* Third-party Garmin device.
*/
GARMIN("Garmin", 1),
/**
* Third-party Iridium device.
*/
IRIDIUM("Iridium", 2),
/**
* Legacy hours of service device.
*/
HOS("Hos", 3),
/**
* External NFC device.
*/
NFC("Nfc", 4),
/**
* External GoTalk device.
*/
GO_TALK("GoTalk", 5),
/**
* Third-party Mobileye device.
*/
MOBILEYE("Mobileye", 6),
/**
* Third-party Valor device.
*/
VALOR("Valor", 7),
/**
* Third-party Valor device.
*/
WIFI("WiFi", 8),
/**
* Third-party salt spreader device.
*/
SALT_SPREADER("SaltSpreader", 9),
/**
* Active tracking.
*/
GO_ACTIVE("GoActive", 10),
/**
* OBD Alert setting present.
*/
OBD_PRESENT("OBDPresent", 11),
/**
* OBD Alert setting enabled.
*/
OBD_ENABLED("OBDEnabled", 12),
// Manual activation
/**
* Garmin hours of service.
*/
GARMIN_HOS("GarminHos", 1001),
/**
* Geotab Drive hours of service.
*/
GEOTAB_DRIVE_HOS("GeotabDriveHos", 1002);
private String name;
private int code;
VehicleFeatureCategory(String name, int code) {
this.name = name;
this.code = code;
}
public int getCode() {
return code;
}
@JsonValue
public String getName() {
return name;
}
public static VehicleFeatureCategory findOrDefault(String name) {
if (StringUtils.isEmpty(name)) {
log.warn("Empty value is not recognized for {} enum; returning default {}",
VehicleFeatureCategory.class.getSimpleName(), VehicleFeatureCategory.UNKNOWN_DEVICE);
return UNKNOWN_DEVICE;
}
for (VehicleFeatureCategory vehicleFeatureCategory : values()) {
if (vehicleFeatureCategory.getName().equalsIgnoreCase(name.trim())) {
return vehicleFeatureCategory;
}
}
log.warn("{} is not recognized for {} enum; returning default {}",
name, VehicleFeatureCategory.class.getSimpleName(), VehicleFeatureCategory.UNKNOWN_DEVICE);
return UNKNOWN_DEVICE;
}
}