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

org.knowm.xchange.coinbase.dto.serialization.EnumFromStringHelper Maven / Gradle / Ivy

There is a newer version: 5.2.1
Show newest version
package org.knowm.xchange.coinbase.dto.serialization;

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

/** @author jamespedwards42 */
public class EnumFromStringHelper> {

  private final Map fromString = new HashMap<>();

  public EnumFromStringHelper(Class enumClass) {

    for (T enumVal : enumClass.getEnumConstants())
      fromString.put(enumVal.toString().toLowerCase(), enumVal);
  }

  public EnumFromStringHelper addJsonStringMapping(String jsonString, final T enumVal) {

    fromString.put(jsonString, enumVal);
    return this;
  }

  public T fromJsonString(String jsonString) {

    return fromString.get(jsonString.toLowerCase());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy