001/* 002 * Copyright 2015-2018 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-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.ldap.sdk.unboundidds.jsonfilter; 022 023 024 025import com.unboundid.util.StaticUtils; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * An enum that defines the possible values that may be used for the 033 * {@code expectedType} element of a {@link ContainsFieldJSONObjectFilter}. 034 * <BR> 035 * <BLOCKQUOTE> 036 * <B>NOTE:</B> This class, and other classes within the 037 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 038 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 039 * server products. These classes provide support for proprietary 040 * functionality or for external specifications that are not considered stable 041 * or mature enough to be guaranteed to work in an interoperable way with 042 * other types of LDAP servers. 043 * </BLOCKQUOTE> 044 */ 045@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 046public enum ExpectedValueType 047{ 048 /** 049 * Indicates that the target field may have a value of {@code true} or 050 * {@code false}. 051 */ 052 BOOLEAN("boolean"), 053 054 055 056 /** 057 * Indicates that the target field may have a value that is an array 058 * containing zero elements. 059 */ 060 EMPTY_ARRAY("empty-array"), 061 062 063 064 /** 065 * Indicates that the target field may have a value that is an array 066 * containing at least one element. No restriction will be placed on the type 067 * of elements that may be held in the array. 068 */ 069 NON_EMPTY_ARRAY("non-empty-array"), 070 071 072 073 /** 074 * Indicates that the target field may have a value of {@code null}. 075 * {@code null}. 076 */ 077 NULL("null"), 078 079 080 081 /** 082 * Indicates that the target field may have a value that is a number. 083 */ 084 NUMBER("number"), 085 086 087 088 /** 089 * Indicates that the target field may have a value that is a JSON object. 090 */ 091 OBJECT("object"), 092 093 094 095 /** 096 * Indicates that the target field may have a value that is a string. 097 */ 098 STRING("string"); 099 100 101 102 // The name that should be used for the type. 103 private final String name; 104 105 106 107 /** 108 * Creates a new expected value type with the specified name. 109 * 110 * @param name The name for the type. 111 */ 112 ExpectedValueType(final String name) 113 { 114 this.name = name; 115 } 116 117 118 119 /** 120 * Retrieves the expected value type with the specified name. 121 * 122 * @param name The name of the expected value type to retrieve. 123 * 124 * @return The expected value type with the specified name, ro {@code null} 125 * if there is no type with the given name. 126 */ 127 public static ExpectedValueType forName(final String name) 128 { 129 switch (StaticUtils.toLowerCase(name)) 130 { 131 case "boolean": 132 return BOOLEAN; 133 case "emptyarray": 134 case "empty-array": 135 case "empty_array": 136 return EMPTY_ARRAY; 137 case "nonemptyarray": 138 case "non-empty-array": 139 case "non_empty_array": 140 return NON_EMPTY_ARRAY; 141 case "null": 142 return NULL; 143 case "number": 144 return NUMBER; 145 case "object": 146 return OBJECT; 147 case "string": 148 return STRING; 149 default: 150 return null; 151 } 152 } 153 154 155 156 /** 157 * Retrieves a string representation of this expected value type. 158 * 159 * @return A string representation of this expected value type. 160 */ 161 @Override() 162 public String toString() 163 { 164 return name; 165 } 166}