001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.jsonschema; 014 015import java.util.*; 016 017import org.apache.juneau.internal.*; 018 019/** 020 * Represents possible values for the following properties: 021 * 022 * <ul class='doctree'> 023 * <li class='jf'>{@link JsonSchemaGenerator#JSONSCHEMA_addExamplesTo} 024 * <li class='jf'>{@link JsonSchemaGenerator#JSONSCHEMA_addDescriptionsTo} 025 * </ul> 026 */ 027public enum TypeCategory { 028 029 /** Beans */ 030 BEAN, 031 032 /** Map */ 033 MAP, 034 035 /** List/Set */ 036 COLLECTION, 037 038 /** Array */ 039 ARRAY, 040 041 /** Boolean (including primitives) */ 042 BOOLEAN, 043 044 /** Short/Integer/Long/Float/Double (including primitives) */ 045 NUMBER, 046 047 /** String/CharSequence/Character */ 048 STRING, 049 050 /** Enums */ 051 ENUM, 052 053 /** Anything else */ 054 OTHER, 055 056 /** Anything */ 057 ANY; 058 059 /** 060 * Parses a comma-delimited list of values into a set of {@link TypeCategory} values. 061 * 062 * @param s The comma-delimited string. 063 * @return A comma-delimited list of values into a set of {@link TypeCategory} values. 064 */ 065 public static Set<TypeCategory> parse(String s) { 066 if (s == null || s.isEmpty()) 067 return Collections.emptySet(); 068 Set<TypeCategory> set = new LinkedHashSet<>(); 069 for (String ss : StringUtils.split(s)) 070 set.add(valueOf(ss.toUpperCase())); 071 return set; 072 } 073}