com.kero.security.lang.parsers.HasBlock 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;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import com.kero.security.lang.collections.TokenSequence;
import com.kero.security.lang.tokens.KeyWordToken;
public interface HasBlock {
public default List parseBlock(TokenSequence tokens) {
if(tokens.peek() != KeyWordToken.OPEN_BLOCK) return Collections.emptyList();
tokens.poll(); // OPEN_BLOCK
List units = new LinkedList<>();
while(tokens.peek() != KeyWordToken.CLOSE_BLOCK) {
units.add(parseBlockUnit(tokens));
}
tokens.poll(); // CLOSE_BLOCK
return units;
}
public U parseBlockUnit(TokenSequence tokens);
}