kz.greetgo.logging.structure.parser.model.TopInstruction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greetgo-logging-structure Show documentation
Show all versions of greetgo-logging-structure Show documentation
Logging mechanism using in greetgo!
package kz.greetgo.logging.structure.parser.model;
import lombok.RequiredArgsConstructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequiredArgsConstructor
public class TopInstruction implements InstructionPartOwner {
public final int line;
public final boolean enabled;
public final InstructionPartList header = new InstructionPartList(this);
public final List subList = new ArrayList<>();
public void addSubInstruction(SubInstruction subInstruction) {
subList.add(subInstruction);
}
private Map _subMap = null;
public SubInstruction byFirstWord(String firstWord) {
if (_subMap == null) {
Map subMap = new HashMap<>();
for (SubInstruction subInstruction : subList) {
subMap.put(subInstruction.first(), subInstruction);
}
_subMap = subMap;
}
return _subMap.get(firstWord);
}
@Override
public int lineNo() {
return line;
}
public TopInstruction addSubInstruction(String line) {
subList.add(new SubInstruction(0).addPart(line));
return this;
}
}