Class FactorySingleParameterInstructionParser
java.lang.Object
dev.zemco.codegame.compilation.parsing.AbstractNamedParametrizedInstructionParser
dev.zemco.codegame.compilation.parsing.FactorySingleParameterInstructionParser
- All Implemented Interfaces:
IInstructionParser
- Direct Known Subclasses:
FactorySingleIntegerParameterInstructionParser
public class FactorySingleParameterInstructionParser
extends AbstractNamedParametrizedInstructionParser
Parses a named
instruction with a single parameter by requesting it
from a backing factory.
The backing factory cannot be modified after construction.- Author:
- Erik Zemčík
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceProducesinstructionsfrom a singlestringparameter. -
Constructor Summary
ConstructorsConstructorDescriptionFactorySingleParameterInstructionParser(String instructionName, FactorySingleParameterInstructionParser.IStringInstructionFactory instructionFactory) Creates an instance ofFactorySingleParameterInstructionParserthat parsesinstructionswith the given name by requesting them from the given backingfactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<IInstruction>parseInstructionFromParameters(String[] parameters) Parses the namedinstructionby requesting it from the backingfactory.Methods inherited from class dev.zemco.codegame.compilation.parsing.AbstractNamedParametrizedInstructionParser
checkParameterFixedCount, parseInstruction
-
Constructor Details
-
FactorySingleParameterInstructionParser
public FactorySingleParameterInstructionParser(String instructionName, FactorySingleParameterInstructionParser.IStringInstructionFactory instructionFactory) Creates an instance ofFactorySingleParameterInstructionParserthat parsesinstructionswith the given name by requesting them from the given backingfactory.- Parameters:
instructionName- name of the rawinstructioninstructionFactory- source of parsedinstructions- Throws:
IllegalArgumentException- ifinstructionNameisnullor empty or ifinstructionFactoryisnull
-
-
Method Details
-
parseInstructionFromParameters
Parses the namedinstructionby requesting it from the backingfactory. Theparametersargument contain a single parameter.- Specified by:
parseInstructionFromParametersin classAbstractNamedParametrizedInstructionParser- Parameters:
parameters- raw instruction parameters- Returns:
instructionfrom the backingfactory- Throws:
IllegalArgumentException- ifparametersarenullInstructionParseException- if length ofparametersis not zero or iffactoryfails to parse theinstruction
-