001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2021–2022 microBean™. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 014 * implied. See the License for the specific language governing 015 * permissions and limitations under the License. 016 */ 017package org.microbean.loader.jackson.toml; 018 019import java.lang.reflect.Type; 020 021import com.fasterxml.jackson.dataformat.toml.TomlMapper; 022 023import org.microbean.loader.jackson.InputStreamJacksonProvider; 024 025import org.microbean.invoke.CachingSupplier; 026 027/** 028 * An {@link InputStreamJacksonProvider} that reads TOML-formatted 029 * {@code application.toml} classpath resources. 030 * 031 * @author <a href="https://about.me/lairdnelson" 032 * target="_parent">Laird Nelson</a> 033 * 034 * @see InputStreamJacksonProvider 035 */ 036public class TomlProvider extends InputStreamJacksonProvider { 037 038 039 /* 040 * Constructors. 041 */ 042 043 044 /** 045 * Creates a new {@link TomlProvider} that reads TOML-formatted 046 * {@code application.toml} classpath resources. 047 * 048 * @see #TomlProvider(Type, String) 049 */ 050 public TomlProvider() { 051 this(null, "application.toml"); 052 } 053 054 /** 055 * Creates a new {@link TomlProvider}. 056 * 057 * @param lowerBound the {@linkplain #lowerBound() lower type bound} 058 * of this {@link InputStreamJacksonProvider} implementation; may be 059 * {@code null} 060 * 061 * @param resourceName the name of the classpath resource to read 062 * from; must not be {@code null} 063 * 064 * @exception NullPointerException if {@code resourceName} is {@code 065 * null} 066 */ 067 public TomlProvider(final Type lowerBound, final String resourceName) { 068 super(lowerBound, new CachingSupplier<>(TomlMapper::new), resourceName); 069 } 070 071}