001/* 002 * Copyright 2015-2024 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2015-2024 Ping Identity Corporation 007 * 008 * Licensed under the Apache License, Version 2.0 (the "License"); 009 * you may not use this file except in compliance with the License. 010 * You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, software 015 * distributed under the License is distributed on an "AS IS" BASIS, 016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017 * See the License for the specific language governing permissions and 018 * limitations under the License. 019 */ 020/* 021 * Copyright (C) 2015-2024 Ping Identity Corporation 022 * 023 * This program is free software; you can redistribute it and/or modify 024 * it under the terms of the GNU General Public License (GPLv2 only) 025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 026 * as published by the Free Software Foundation. 027 * 028 * This program is distributed in the hope that it will be useful, 029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 031 * GNU General Public License for more details. 032 * 033 * You should have received a copy of the GNU General Public License 034 * along with this program; if not, see <http://www.gnu.org/licenses>. 035 */ 036package com.unboundid.ldap.sdk.unboundidds.jsonfilter; 037 038 039 040import com.unboundid.util.NotNull; 041import com.unboundid.util.Nullable; 042import com.unboundid.util.StaticUtils; 043import com.unboundid.util.ThreadSafety; 044import com.unboundid.util.ThreadSafetyLevel; 045 046 047 048/** 049 * An enum that defines the possible values that may be used for the 050 * {@code expectedType} element of a {@link ContainsFieldJSONObjectFilter}. 051 * <BR> 052 * <BLOCKQUOTE> 053 * <B>NOTE:</B> This class, and other classes within the 054 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 055 * supported for use against Ping Identity, UnboundID, and 056 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 057 * for proprietary functionality or for external specifications that are not 058 * considered stable or mature enough to be guaranteed to work in an 059 * interoperable way with other types of LDAP servers. 060 * </BLOCKQUOTE> 061 */ 062@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 063public enum ExpectedValueType 064{ 065 /** 066 * Indicates that the target field may have a value of {@code true} or 067 * {@code false}. 068 */ 069 BOOLEAN("boolean"), 070 071 072 073 /** 074 * Indicates that the target field may have a value that is an array 075 * containing zero elements. 076 */ 077 EMPTY_ARRAY("empty-array"), 078 079 080 081 /** 082 * Indicates that the target field may have a value that is an array 083 * containing at least one element. No restriction will be placed on the type 084 * of elements that may be held in the array. 085 */ 086 NON_EMPTY_ARRAY("non-empty-array"), 087 088 089 090 /** 091 * Indicates that the target field may have a value of {@code null}. 092 * {@code null}. 093 */ 094 NULL("null"), 095 096 097 098 /** 099 * Indicates that the target field may have a value that is a number. 100 */ 101 NUMBER("number"), 102 103 104 105 /** 106 * Indicates that the target field may have a value that is a JSON object. 107 */ 108 OBJECT("object"), 109 110 111 112 /** 113 * Indicates that the target field may have a value that is a string. 114 */ 115 STRING("string"); 116 117 118 119 // The name that should be used for the type. 120 @NotNull private final String name; 121 122 123 124 /** 125 * Creates a new expected value type with the specified name. 126 * 127 * @param name The name for the type. 128 */ 129 ExpectedValueType(@NotNull final String name) 130 { 131 this.name = name; 132 } 133 134 135 136 /** 137 * Retrieves the expected value type with the specified name. 138 * 139 * @param name The name of the expected value type to retrieve. 140 * 141 * @return The expected value type with the specified name, ro {@code null} 142 * if there is no type with the given name. 143 */ 144 @Nullable() 145 public static ExpectedValueType forName(@NotNull final String name) 146 { 147 switch (StaticUtils.toLowerCase(name)) 148 { 149 case "boolean": 150 return BOOLEAN; 151 case "emptyarray": 152 case "empty-array": 153 case "empty_array": 154 return EMPTY_ARRAY; 155 case "nonemptyarray": 156 case "non-empty-array": 157 case "non_empty_array": 158 return NON_EMPTY_ARRAY; 159 case "null": 160 return NULL; 161 case "number": 162 return NUMBER; 163 case "object": 164 return OBJECT; 165 case "string": 166 return STRING; 167 default: 168 return null; 169 } 170 } 171 172 173 174 /** 175 * Retrieves a string representation of this expected value type. 176 * 177 * @return A string representation of this expected value type. 178 */ 179 @Override() 180 @NotNull() 181 public String toString() 182 { 183 return name; 184 } 185}