LipidCategory.java

  1. /*
  2.  * Copyright 2021 Dominik Kopczynski, Nils Hoffmann.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *      http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.lifstools.jgoslin.domain;

  17. import java.util.Arrays;
  18. import java.util.List;

  19. /**
  20.  * The lipid category nomenclature follows the shorthand notation of
  21.  * <pre>Liebisch, G., Vizcaíno,
  22.  * J.A., Köfeler, H., Trötzmüller, M., Griffiths, W.J., Schmitz, G., Spener, F.,
  23.  * and Wakelam, M.J.O. (2013). Shorthand notation for lipid structures derived
  24.  * from mass spectrometry. J. Lipid Res. 54, 1523–1530.</pre>
  25.  *
  26.  * We use the associations to either LIPID MAPS categories where appropriate.
  27.  *
  28.  * @author Dominik Kopczynski
  29.  * @author Nils Hoffmann
  30.  */
  31. public enum LipidCategory {

  32.     NO_CATEGORY("Unknown lipid category"),
  33.     UNDEFINED("Undefined lipid category"),
  34.     /* SLM:000117142 Glycerolipids */
  35.     GL("Glycerolipids"),
  36.     /* SLM:000001193 Glycerophospholipids */
  37.     GP("Glycerophospholipids"),
  38.     /* SLM:000000525 Sphingolipids */
  39.     SP("Sphingolipids"),
  40.     /* SLM:000500463 Steroids and derivatives */
  41.     ST("Sterollipids"),
  42.     /* SLM:000390054 Fatty acyls and derivatives */
  43.     FA("Fattyacyls"),
  44.     /* LipidMAPS [PK]*/
  45.     PK("Polyketides"),
  46.     /* LipidMAPS [SL]*/
  47.     SL("Saccharolipids");

  48.     private final String fullName;

  49.     private LipidCategory(String fullName) {
  50.         this.fullName = fullName;
  51.     }

  52.     public String getFullName() {
  53.         return this.fullName;
  54.     }

  55.     public static LipidCategory forFullName(String fullName) {
  56.         List<LipidCategory> matches = Arrays.asList(LipidCategory.values()).stream().filter((t) -> {
  57.             return t.getFullName().equalsIgnoreCase(fullName);
  58.         }).toList();
  59.         if (matches.isEmpty()) {
  60.             return LipidCategory.UNDEFINED;
  61.         } else if (matches.size() > 1) {
  62.             throw new ConstraintViolationException("Query string " + fullName + " found more than once in enum values! Please check enum definition: fullName is compared case insensitive!");
  63.         }
  64.         return matches.get(0);
  65.     }
  66. }