com.kero.security.lang.parsers.metaline.HasMetalines Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kero-security Show documentation
Show all versions of kero-security Show documentation
Kero-Security is a library for statically controlling access to properties of objects / classes.
package com.kero.security.lang.parsers.metaline;
import java.util.LinkedList;
import java.util.List;
import com.kero.security.lang.collections.TokenSequence;
import com.kero.security.lang.nodes.metaline.MetalineNode;
import com.kero.security.lang.parsers.exceptions.ParserNotFoundException;
import com.kero.security.lang.tokens.KeyWordToken;
public interface HasMetalines {
public default List parseMetalines(TokenSequence tokens) {
List metalines = new LinkedList<>();
while(tokens.peek() == KeyWordToken.METALINE) {
metalines.add(parseLine(tokens));
}
return metalines;
}
public default N parseLine(TokenSequence tokens) {
List extends MetalineParser extends N>> parsers = getMetalineParsers();
for(MetalineParser extends N> parser : parsers) {
if(parser.isMatch(tokens)) {
return parser.parse(tokens);
}
}
throw new ParserNotFoundException("Can't find parser for metaline!");
}
public List extends MetalineParser extends N>> getMetalineParsers();
}