001/* 002 * Copyright 2011-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2011-2019 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.persist; 022 023 024 025import com.unboundid.util.StaticUtils; 026 027 028 029/** 030 * This enum defines a set of filter types for filters that may be generated 031 * for an object using the LDAP SDK persistence framework. Classes created by 032 * {@link GenerateSourceFromSchema} (including the 033 * {@code generate-source-from-schema} command-line tool) will include methods 034 * that may be used to generate filters for object contents. 035 */ 036public enum PersistFilterType 037{ 038 /** 039 * The filter type that may be used to generate a presence filter, like 040 * "(attrName=*)". 041 */ 042 PRESENCE, 043 044 045 046 /** 047 * The filter type that may be used to generate an equality filter, like 048 * "(attrName=value)". 049 */ 050 EQUALITY, 051 052 053 054 /** 055 * The filter type that may be used to generate a substring filter with a 056 * subInitial element, like "(attrName=value*)". 057 */ 058 STARTS_WITH, 059 060 061 062 /** 063 * The filter type that may be used to generate a substring filter with a 064 * subFinal element, like "(attrName=*value)". 065 */ 066 ENDS_WITH, 067 068 069 070 /** 071 * The filter type that may be used to generate a substring filter with a 072 * subAny element, like "(attrName=*value*)". 073 */ 074 CONTAINS, 075 076 077 078 /** 079 * The filter type that may be used to generate a greater-than-or-equal-to 080 * filter, like "(attrName>=value)". 081 */ 082 GREATER_OR_EQUAL, 083 084 085 086 /** 087 * The filter type that may be used to generate a less-than-or-equal-to 088 * filter, like "(attrName<=value)". 089 */ 090 LESS_OR_EQUAL, 091 092 093 094 /** 095 * The filter type that may be used to generate an approximate match filter, 096 * like "(attrName~=value)". 097 */ 098 APPROXIMATELY_EQUAL_TO; 099 100 101 102 /** 103 * Retrieves the filter type with the specified name. 104 * 105 * @param name The name of the filter type to retrieve. It must not be 106 * {@code null}. 107 * 108 * @return The requested filter type, or {@code null} if no such type is 109 * defined. 110 */ 111 public static PersistFilterType forName(final String name) 112 { 113 switch (StaticUtils.toLowerCase(name)) 114 { 115 case "presence": 116 return PRESENCE; 117 case "equality": 118 return EQUALITY; 119 case "startswith": 120 case "starts-with": 121 case "starts_with": 122 return STARTS_WITH; 123 case "endswith": 124 case "ends-with": 125 case "ends_with": 126 return ENDS_WITH; 127 case "contains": 128 return CONTAINS; 129 case "greaterorequal": 130 case "greater-or-equal": 131 case "greater_or_equal": 132 return GREATER_OR_EQUAL; 133 case "lessorequal": 134 case "less-or-equal": 135 case "less_or_equal": 136 return LESS_OR_EQUAL; 137 case "approximatelyequalto": 138 case "approximately-equal-to": 139 case "approximately_equal_to": 140 return APPROXIMATELY_EQUAL_TO; 141 default: 142 return null; 143 } 144 } 145}