Class SupplierInstructionParser
java.lang.Object
dev.zemco.codegame.compilation.parsing.AbstractNamedParametrizedInstructionParser
dev.zemco.codegame.compilation.parsing.SupplierInstructionParser
- All Implemented Interfaces:
IInstructionParser
Parses a named
instruction without parameters by requesting it from supplier.
The supplier cannot be modified after construction.- Author:
- Erik Zemčík
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSupplierInstructionParser(String instructionName, Supplier<IInstruction> instructionSupplier) Creates an instance ofSupplierInstructionParserthat parsesinstructionswith the given name by requesting them from the givensupplier. -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<IInstruction>parseInstructionFromParameters(String[] parameters) Parses the namedinstructionby retrieving it from thesupplier.Methods inherited from class dev.zemco.codegame.compilation.parsing.AbstractNamedParametrizedInstructionParser
checkParameterFixedCount, parseInstruction
-
Constructor Details
-
SupplierInstructionParser
public SupplierInstructionParser(String instructionName, Supplier<IInstruction> instructionSupplier) Creates an instance ofSupplierInstructionParserthat parsesinstructionswith the given name by requesting them from the givensupplier.- Parameters:
instructionName- name of the rawinstructioninstructionSupplier- source of parsedinstructions- Throws:
IllegalArgumentException- ifinstructionNameisnullor empty or ifinstructionSupplierisnull
-
-
Method Details
-
parseInstructionFromParameters
Parses the namedinstructionby retrieving it from thesupplier. Theparametersargument must be empty for allsupplierbackedinstructions.- Specified by:
parseInstructionFromParametersin classAbstractNamedParametrizedInstructionParser- Parameters:
parameters- raw instruction parameters- Returns:
instructionfrom thesupplier- Throws:
IllegalArgumentException- ifparametersarenullInstructionParseException- if length ofparametersis not zero
-