net.cactusthorn.config.extras.hjson.ClasspathHjsonLoader Maven / Gradle / Ivy
/*
* Copyright (C) 2021, Alexei Khatskevich
*
* Licensed under the BSD 3-Clause license.
* You may obtain a copy of the License at
*
* https://github.com/Gmugra/net.cactusthorn.config/blob/main/LICENSE
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.cactusthorn.config.extras.hjson;
import java.io.Reader;
import java.net.URI;
import java.util.Map;
import net.cactusthorn.config.core.loader.ClasspathLoader;
import net.cactusthorn.config.extras.hjson.util.HjsonToMapParser;
public class ClasspathHjsonLoader extends ClasspathLoader {
private static final String EXTENSION = ".hjson";
private static final HjsonToMapParser PARSER = new HjsonToMapParser();
@Override public boolean accept(URI uri) {
return accept(uri, EXTENSION);
}
@Override protected Map load(Reader reader) throws Exception {
return PARSER.parse(reader);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy