
org.basinmc.plunger.mapping.mcp.parser.SRGParameterNameMappingParser Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2018 Johannes Donath
* and other copyright owners as documented in the project's IP log.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.basinmc.plunger.mapping.mcp.parser;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import org.basinmc.plunger.mapping.ParameterNameMapping;
/**
* @author Johannes Donath
*/
public class SRGParameterNameMappingParser {
@NonNull
public ParameterNameMapping parse(@NonNull InputStream inputStream) throws IOException {
Properties properties = new Properties();
properties.load(inputStream);
return this.parse(properties);
}
@NonNull
public ParameterNameMapping parse(@NonNull Path path) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(path)) {
return this.parse(reader);
}
}
@NonNull
public ParameterNameMapping parse(@NonNull Reader reader) throws IOException {
Properties properties = new Properties();
properties.load(reader);
return this.parse(properties);
}
@NonNull
private ParameterNameMapping parse(@NonNull Properties properties) throws IOException {
ParameterNameMappingImpl mapping = new ParameterNameMappingImpl();
for (Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy