All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.abavilla.fpi.telco.ext.enums.Telco Maven / Gradle / Ivy

There is a newer version: 1.3.13
Show newest version
/******************************************************************************
 * FPI Application - Abavilla                                                 *
 * Copyright (C) 2022  Vince Jerald Villamora                                 *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation, either version 3 of the License, or          *
 * (at your option) any later version.                                        *
 *                                                                            *
 * 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 General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License          *
 * along with this program.  If not, see .     *
 ******************************************************************************/

package com.abavilla.fpi.telco.ext.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

import com.abavilla.fpi.fw.entity.enums.IBaseEnum;
import com.abavilla.fpi.fw.util.FWConst;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * Enum for storing the operator or telco assigned to an entity
 *
 * @author Vince Villamora
 */
@Getter
@AllArgsConstructor
@RegisterForReflection
public enum Telco implements IBaseEnum {
  GLOBE(1, "Globe"),
  SMART(2, "Smart"),
  SUN(3, "Sun"),
  DITO(4, "DITO"),
  CIGNAL(200, "Cignal"),
  UNKNOWN(-1, FWConst.UNKNOWN_PREFIX);

  /**
   * Ordinal id to enum mapping
   */
  private static final Map ENUM_MAP = new HashMap<>();

  static {
    for(Telco w : EnumSet.allOf(Telco.class))
      ENUM_MAP.put(w.getId(), w);
  }

  /**
   * The enum ordinal id
   */
  private final int id;

  /**
   * The enum value
   */
  private final String value;

  /**
   * Creates an enum based from given string value
   *
   * @param value the string value
   * @return the created enum
   */
  @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
  public static Telco fromValue(String value) {
    return (Telco) IBaseEnum.fromValue(value, ENUM_MAP, UNKNOWN);
  }

  /**
   * Creates an enum based from given an ordinal id
   *
   * @param id the ordinal id
   * @return the created enum
   */
  public static Telco fromId(int id) {
    return (Telco) IBaseEnum.fromId(id, ENUM_MAP, UNKNOWN);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  @JsonValue
  public String toString() {
    return value;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy