All Downloads are FREE. Search and download functionalities are using the official Maven repository.

openllet.OpenlletCmdOptions Maven / Gradle / Ivy

There is a newer version: 2.6.5
Show newest version
// Copyright (c) 2006 - 2008, Clark & Parsia, LLC. 
// This source code is available under the terms of the Affero General Public
// License v3.
//
// Please see LICENSE.txt for full license terms, including the availability of
// proprietary exceptions.
// Questions, comments, or requests for clarification: [email protected]

package openllet;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * 

* Description: Essentially a set of OpenlletCmdOption *

*

* Copyright: Copyright (c) 2008 *

*

* Company: Clark & Parsia, LLC. *

* * @author Markus Stocker */ public class OpenlletCmdOptions { private final Map options; private final Map shortOptions; private final Set mandatory; public OpenlletCmdOptions() { options = new LinkedHashMap<>(); shortOptions = new HashMap<>(); mandatory = new HashSet<>(); } public void add(final OpenlletCmdOption option) { final String shortOption = option.getShortOption(); final String longOption = option.getLongOption(); if (options.containsKey(longOption)) throw new OpenlletCmdException("Duplicate long option for command: " + longOption); else if (shortOption != null && shortOptions.containsKey(shortOption)) throw new OpenlletCmdException("Duplicate short option for command: " + shortOption); shortOptions.put(shortOption, option); options.put(longOption, option); if (option.isMandatory()) mandatory.add(option); } public OpenlletCmdOption getOption(final String key) { // If key is short option then this matches OpenlletCmdOption option = shortOptions.get(key); // Else, key is long option, retrieve its short option if (option == null) option = options.get(key); return option; } public Set getMandatoryOptions() { return mandatory; } public Collection getOptions() { return options.values(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy