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 org.apache.juneau.*; 016import org.apache.juneau.jsonschema.annotation.*; 017import org.apache.juneau.parser.*; 018 019/** 020 * Metadata on bean properties specific to the JSON-Schema pulled from the {@link Schema @Schema} annotation 021 * on the bean property. 022 */ 023public class JsonSchemaBeanPropertyMeta extends ExtendedBeanPropertyMeta { 024 025 /** 026 * Default instance. 027 */ 028 public static final JsonSchemaBeanPropertyMeta DEFAULT = new JsonSchemaBeanPropertyMeta(); 029 030 private final ObjectMap schema; 031 032 /** 033 * Constructor. 034 * 035 * @param bpm The metadata of the bean property of this additional metadata. 036 * @param mp JSON-schema metadata provider (for finding information about other artifacts). 037 */ 038 public JsonSchemaBeanPropertyMeta(BeanPropertyMeta bpm, JsonSchemaMetaProvider mp) { 039 super(bpm); 040 041 this.schema = new ObjectMap(); 042 043 try { 044 for (Schema s : bpm.getAnnotations(Schema.class)) 045 schema.appendAll(SchemaUtils.asMap(s)); 046 } catch (ParseException e) { 047 throw new RuntimeException(e); 048 } 049 } 050 051 private JsonSchemaBeanPropertyMeta() { 052 super(null); 053 this.schema = ObjectMap.EMPTY_MAP; 054 } 055 056 /** 057 * Returns the schema information gathered from all the {@link Schema @Schema} annotations on the bean property. 058 * 059 * @return The schema information as a generic map. Never <jk>null</jk>. 060 */ 061 protected ObjectMap getSchema() { 062 return schema; 063 } 064}