package bluej.stride.framedjava.convert;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import bluej.parser.lexer.LocatableToken;
import threadchecker.OnThread;
import threadchecker.Tag;


| A modifier. Might be a keyword (e.g. "public", "final") or an annotation |* e.g. "@Override", "@Test(true)" */ interface Modifier{ /** * Returns true if this is a keyword modifier equal to the given string */ public boolean isKeyword(String modifier); /** * Returns true if this is an annotation where the name matches the given name. public boolean isAnnotation(String annotation); LocatableToken getStart(); LocatableToken getEnd(); static class KeywordModifier implements Modifier { private final LocatableToken keyword; KeywordModifier(LocatableToken keyword) { this.keyword = keyword; } @Override public boolean isKeyword(String modifier) { return this.keyword.getText().equals(modifier); } @Override public boolean isAnnotation(String annotation) { return false; } @Override public LocatableToken getStart() { return keyword; } @Override public LocatableToken getEnd() { return keyword; } @Override public String toString() { return keyword.getText(); } } static class AnnotationModifier implements Modifier { private final String annotation; private final LocatableToken start; private final LocatableToken end; private List<Expression> params; public AnnotationModifier(List<LocatableToken> annotation) { this.annotation = annotation.stream().map(LocatableToken::getText).collect(Collectors.joining()); this.start = annotation.get(0); this.end = annotation.get(annotation.size() - 1); } public void setParams(List<Expression> params) { this.params = new ArrayList<>(params); } @Override public boolean isKeyword(String modifier) { return false; } @Override public boolean isAnnotation(String annotation) { if (annotation.startsWith("@")) return this.annotation.equals(annotation.substring(1)); else{ return this.annotation.equals(annotation); } } @Override public String toString() { return "@" + annotation + (params == null ? "" : params.stream().map(Expression::toString).collect(Collectors.joining(" , "))); } @Override public LocatableToken getEnd() { return end; } @Override public LocatableToken getStart() { return start; } } }

.   isAnnotation

top, use, map, class KeywordModifier

.   isKeyword
.   isAnnotation
.   getStart
.   getEnd
.   toString

top, use, map, class KeywordModifier . AnnotationModifier

.   AnnotationModifier
.   setParams
.   isKeyword
.   isAnnotation
.   toString
.   getEnd
.   getStart




135 neLoCode + 1 LoComm