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.oapi; 014 015import org.apache.juneau.*; 016import org.apache.juneau.parser.*; 017import org.apache.juneau.uon.*; 018 019/** 020 * OpenAPI part parser. 021 * 022 * <h5 class='section'>See Also:</h5> 023 * <ul> 024 * <li class='link'>{@doc juneau-marshall.OpenApiDetails.Parsers} 025 * </ul> 026 */ 027public class OpenApiParser extends UonParser { 028 029 //------------------------------------------------------------------------------------------------------------------- 030 // Predefined instances 031 //------------------------------------------------------------------------------------------------------------------- 032 033 /** Reusable instance of {@link OpenApiParser}. */ 034 public static final OpenApiParser DEFAULT = new OpenApiParser(PropertyStore.DEFAULT); 035 036 037 //------------------------------------------------------------------------------------------------------------------- 038 // Instance 039 //------------------------------------------------------------------------------------------------------------------- 040 041 /** 042 * Constructor. 043 * 044 * @param ps The property store containing all the settings for this object. 045 */ 046 public OpenApiParser(PropertyStore ps) { 047 this(ps, "text/openapi"); 048 } 049 050 /** 051 * Constructor. 052 * 053 * @param ps 054 * The property store containing all the settings for this object. 055 * @param consumes 056 * The list of media types that this parser consumes (e.g. <js>"application/json"</js>, <js>"*​/json"</js>). 057 */ 058 public OpenApiParser(PropertyStore ps, String...consumes) { 059 super(ps, consumes); 060 } 061 062 @Override /* Context */ 063 public OpenApiParserBuilder builder() { 064 return new OpenApiParserBuilder(getPropertyStore()); 065 } 066 067 /** 068 * Instantiates a new clean-slate {@link OpenApiParserBuilder} object. 069 * 070 * <p> 071 * This is equivalent to simply calling <code><jk>new</jk> UonPartParserBuilder()</code>. 072 * 073 * <p> 074 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies 075 * the settings of the object called on. 076 * 077 * @return A new {@link OpenApiParserBuilder} object. 078 */ 079 public static OpenApiParserBuilder create() { 080 return new OpenApiParserBuilder(); 081 } 082 083 //------------------------------------------------------------------------------------------------------------------- 084 // Entry point methods 085 //------------------------------------------------------------------------------------------------------------------- 086 087 @Override 088 public OpenApiParserSession createSession() { 089 return new OpenApiParserSession(this, ParserSessionArgs.DEFAULT); 090 } 091 092 @Override 093 public OpenApiParserSession createPartSession(ParserSessionArgs args) { 094 return new OpenApiParserSession(this, args); 095 } 096}