001 /* 002 * Copyright 2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.jsonfilter; 022 023 024 025 import com.unboundid.util.StaticUtils; 026 import com.unboundid.util.ThreadSafety; 027 import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031 /** 032 * <BLOCKQUOTE> 033 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 034 * LDAP SDK for Java. It is not available for use in applications that 035 * include only the Standard Edition of the LDAP SDK, and is not supported for 036 * use in conjunction with non-UnboundID products. 037 * </BLOCKQUOTE> 038 * An enum that defines the possible values that may be used for the 039 * {@code expectedType} element 040 * 041 * An enum defining the possible values for the expected data types for the 042 * value of a given field. 043 */ 044 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 045 public enum ExpectedValueType 046 { 047 /** 048 * Indicates that the target field may have a value of {@code true} or 049 * {@code false}. 050 */ 051 BOOLEAN("boolean"), 052 053 054 055 /** 056 * Indicates that the target field may have a value that is an array 057 * containing zero elements. 058 */ 059 EMPTY_ARRAY("empty-array"), 060 061 062 063 /** 064 * Indicates that the target field may have a value that is an array 065 * containing at least one element. No restriction will be placed on the type 066 * of elements that may be held in the array. 067 */ 068 NON_EMPTY_ARRAY("non-empty-array"), 069 070 071 072 /** 073 * Indicates that the target field may have a value of {@code null}. 074 * {@code null}. 075 */ 076 NULL("null"), 077 078 079 080 /** 081 * Indicates that the target field may have a value that is a number. 082 */ 083 NUMBER("number"), 084 085 086 087 /** 088 * Indicates that the target field may have a value that is a JSON object. 089 */ 090 OBJECT("object"), 091 092 093 094 /** 095 * Indicates that the target field may have a value that is a string. 096 */ 097 STRING("string"); 098 099 100 101 // The name that should be used for the type. 102 private final String name; 103 104 105 106 /** 107 * Creates a new expected value type with the specified name. 108 * 109 * @param name The name for the type. 110 */ 111 private ExpectedValueType(final String name) 112 { 113 this.name = name; 114 } 115 116 117 118 /** 119 * Retrieves the expected value type with the specified name. 120 * 121 * @param name The name of the expected value type to retrieve. 122 * 123 * @return The expected value type with the specified name, ro {@code null} 124 * if there is no type with the given name. 125 */ 126 public static ExpectedValueType forName(final String name) 127 { 128 final String lowerName = StaticUtils.toLowerCase(name); 129 for (final ExpectedValueType t : values()) 130 { 131 if (t.name.equals(lowerName)) 132 { 133 return t; 134 } 135 } 136 137 return null; 138 } 139 140 141 142 /** 143 * Retrieves a string representation of this expected value type. 144 * 145 * @return A string representation of this expected value type. 146 */ 147 @Override() 148 public String toString() 149 { 150 return name; 151 } 152 }