001/*
002 * Copyright 2012-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2012-2018 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldif;
022
023
024
025import com.unboundid.util.StaticUtils;
026import com.unboundid.util.ThreadSafety;
027import com.unboundid.util.ThreadSafetyLevel;
028
029
030
031/**
032 * This enum defines a set of possible behaviors that may be exhibited by the
033 * LDIF reader when encountering entries with duplicate attribute values.
034 */
035@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
036public enum DuplicateValueBehavior
037{
038  /**
039   * Indicates that duplicate values should be stripped, so that the resulting
040   * entry will have only one copy of the value.
041   */
042  STRIP,
043
044
045
046  /**
047   * Indicates that duplicate values should be retained, so that the resulting
048   * entry may have multiple copies of the value.  This is illegal and may cause
049   * significant problems with attempts to use the resulting entry.
050   */
051  RETAIN,
052
053
054
055  /**
056   * Indicates that any entry containing duplicate attribute values should be
057   * rejected.
058   */
059  REJECT;
060
061
062
063  /**
064   * Retrieves the duplicate value behavior with the specified name.
065   *
066   * @param  name  The name of the duplicate value behavior to retrieve.  It
067   *               must not be {@code null}.
068   *
069   * @return  The requested duplicate value behavior, or {@code null} if no such
070   *          behavior is defined.
071   */
072  public static DuplicateValueBehavior forName(final String name)
073  {
074    switch (StaticUtils.toLowerCase(name))
075    {
076      case "strip":
077        return STRIP;
078      case "retain":
079        return RETAIN;
080      case "reject":
081        return REJECT;
082      default:
083        return null;
084    }
085  }
086}