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

net.sourceforge.javadpkg.control.impl.PackageVersionRelationOperatorParserImpl Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
/*
 * dpkg - Debian Package library and the Debian Package Maven plugin
 * (c) Copyright 2016 Gerrit Hohl
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package net.sourceforge.javadpkg.control.impl;

import java.util.Map;
import java.util.TreeMap;

import net.sourceforge.javadpkg.ParseException;
import net.sourceforge.javadpkg.control.PackageVersionRelationOperator;
import net.sourceforge.javadpkg.control.PackageVersionRelationOperatorParser;


/**
 * 

* A {@link PackageVersionRelationOperatorParser} implementation. *

* * @author Gerrit Hohl ([email protected]) * @version 1.0, 01.01.2016 by Gerrit Hohl */ public class PackageVersionRelationOperatorParserImpl implements PackageVersionRelationOperatorParser { /** The relational operators. */ private Map relationOperators; /** *

* Creates a parser. *

*/ public PackageVersionRelationOperatorParserImpl() { super(); this.relationOperators = new TreeMap<>(); this.addRelationOperator("<<"); this.addRelationOperator("<="); this.addRelationOperator("="); this.addRelationOperator(">="); this.addRelationOperator(">>"); } /** *

* Adds a relation operator to the internal map. *

* * @param text * The text. */ private void addRelationOperator(String text) { this.relationOperators.put(text, new PackageVersionRelationOperatorImpl(text)); } @Override public PackageVersionRelationOperator parsePackageVersionRelationOperator(String value) throws ParseException { PackageVersionRelationOperator relationOperator; if (value == null) throw new IllegalArgumentException("Argument value is null."); relationOperator = this.relationOperators.get(value); if (relationOperator == null) throw new ParseException("The relational operator |" + value + "| is not a supported relational operator."); return relationOperator; } /* ********************************************************************** * ********************************************************************** * ********************************************************************** * ********************************************************************** * ********************************************************************** */ /** *

* The {@link PackageVersionRelationOperator} implementation of this class. *

* * @author Gerrit Hohl ([email protected]) * @version 1.0, 01.01.2016 by Gerrit Hohl */ private class PackageVersionRelationOperatorImpl implements PackageVersionRelationOperator { /** The text. */ private String text; /** *

* Creates a relation operator. *

* * @param text * The text. */ public PackageVersionRelationOperatorImpl(String text) { super(); this.text = text; } @Override public String getText() { return this.text; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy