Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Replace explicit type argument with diamond operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed Sep 27, 2022
1 parent 0e83402 commit 3359b6c
Show file tree
Hide file tree
Showing 31 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion grails-gsp/src/main/groovy/org/grails/gsp/GroovyPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public abstract class GroovyPage extends Script {

private Encoder rawEncoder;

private final List<Closure<?>> bodyClosures = new ArrayList<Closure<?>>(15);
private final List<Closure<?>> bodyClosures = new ArrayList<>(15);

public GroovyPage() {
init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class GroovyPageMetaInfo implements GrailsApplicationAware {

private boolean initialized = false;

private CacheEntry<Resource> shouldReloadCacheEntry = new CacheEntry<Resource>();
private CacheEntry<Resource> shouldReloadCacheEntry = new CacheEntry<>();

public static String DEFAULT_PLUGIN_PATH = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class GroovyPagesTemplateEngine extends ResourceAwareTemplateEngine

private static File dumpLineNumbersTo;

private ConcurrentMap<String, CacheEntry<GroovyPageMetaInfo>> pageCache = new ConcurrentHashMap<String, CacheEntry<GroovyPageMetaInfo>>();
private ConcurrentMap<String, CacheEntry<GroovyPageMetaInfo>> pageCache = new ConcurrentHashMap<>();

private ClassLoader classLoader;

Expand All @@ -126,7 +126,7 @@ public class GroovyPagesTemplateEngine extends ResourceAwareTemplateEngine

private Map<String, Class<?>> cachedDomainsWithoutPackage;

private List<GroovyPageSourceDecorator> groovyPageSourceDecorators = new ArrayList();
private List<GroovyPageSourceDecorator> groovyPageSourceDecorators = new ArrayList<>();

static {
String dirPath = System.getProperty("grails.dump.gsp.line.numbers.to.dir");
Expand Down Expand Up @@ -778,7 +778,7 @@ public Map<String, Class<?>> getDomainClassMap() {
* to prevent using the static cache that was used previously.
*/
private Map<String, Class<?>> createDomainClassMap() {
Map<String, Class<?>> domainsWithoutPackage = new HashMap<String, Class<?>>();
Map<String, Class<?>> domainsWithoutPackage = new HashMap<>();
if (this.grailsApplication != null) {
GrailsClass[] domainClasses = this.grailsApplication.getArtefacts(DomainClassArtefactHandler.TYPE);
for (GrailsClass domainClass : domainClasses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private enum ParsingState {

char nextTerminationChar;

Stack<ParsingState> parsingStateStack = new Stack<ParsingState>();
Stack<ParsingState> parsingStateStack = new Stack<>();

boolean containsGstrings = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ public class GroovyPageParser implements Tokens {

private Map<Object, Object> tagContext;

private Stack<TagMeta> tagMetaStack = new Stack<TagMeta>();
private Stack<TagMeta> tagMetaStack = new Stack<>();

private GrailsTagRegistry tagRegistry = GrailsTagRegistry.getInstance();

private Environment environment;

private List<String> htmlParts = new ArrayList<String>();
private List<String> htmlParts = new ArrayList<>();

private static SitemeshPreprocessor sitemeshPreprocessor = new SitemeshPreprocessor();

Set<Integer> bodyVarsDefined = new HashSet<Integer>();
Set<Integer> bodyVarsDefined = new HashSet<>();

Map<Integer, String> attrsVarsMapDefinition = new HashMap<Integer, String>();
Map<Integer, String> attrsVarsMapDefinition = new HashMap<>();

int closureLevel = 0;

Expand Down Expand Up @@ -183,7 +183,7 @@ public class GroovyPageParser implements Tokens {

private int constantCount = 0;

private Map<String, Integer> constantsToNumbers = new HashMap<String, Integer>();
private Map<String, Integer> constantsToNumbers = new HashMap<>();

private final String pageName;

Expand Down Expand Up @@ -233,7 +233,7 @@ public class GroovyPageParser implements Tokens {

public static final String GROOVY_SOURCE_CHAR_ENCODING = "UTF-8";

private Map<String, String> jspTags = new HashMap<String, String>();
private Map<String, String> jspTags = new HashMap<>();

private long lastModified;

Expand Down Expand Up @@ -370,7 +370,7 @@ else if (keepDirObj != null) {
}

private Map<String, String> parseDirectives(String gspSource) {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<>();
// strip gsp comments
String input = PRESCAN_COMMENT_PATTERN.matcher(gspSource).replaceAll("");
// find page directives
Expand Down Expand Up @@ -598,7 +598,7 @@ private void directPage(String text) {
private void directJspTagLib(String text) {

text = text.substring(TAGLIB_DIRECTIVE.length() + 1, text.length());
Map<String, String> attrs = new LinkedHashMap<String, String>();
Map<String, String> attrs = new LinkedHashMap<>();
populateMapWithAttributes(attrs, text);

String prefix = attrs.get("\"prefix\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GroovyPageScanner implements Tokens {

// add line starting positions to array
private void resolveLineNumberPositions() {
this.lineNumberPositions = new ArrayList<Integer>();
this.lineNumberPositions = new ArrayList<>();
// first line starts at 0
this.lineNumberPositions.add(0);
for (int i = 0; i < this.len; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class GrailsTagRegistry {

private static GrailsTagRegistry instance = new GrailsTagRegistry();

private static Map<String, Class<?>> tagRegistry = new ConcurrentHashMap<String, Class<?>>();
private static Map<String, Class<?>> tagRegistry = new ConcurrentHashMap<>();

static {
instance.registerTag(GroovyEachTag.TAG_NAME, GroovyEachTag.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public abstract class GroovySyntaxTag implements GrailsTag {

protected PrintWriter out;

protected Map<String, String> attributes = new HashMap<String, String>();
protected Map<String, String> attributes = new HashMap<>();

protected GroovyPageParser parser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void call(SourceUnit source, GeneratorContext context, ClassNode classNod

private GroovyPageInjector[] getGroovyPageInjectors() {
if (this.groovyPageInjectors == null) {
List<GroovyPageInjector> injectors = new ArrayList<GroovyPageInjector>();
List<GroovyPageInjector> injectors = new ArrayList<>();
for (ClassInjector ci : getClassInjectors()) {
if (ci instanceof GroovyPageInjector) {
injectors.add((GroovyPageInjector) ci);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GroovyPageOptimizerVisitor extends CodeVisitorSupport {

private static final String EXPRESSIONOUT_RECEIVER = "expressionOut";

private Stack<ClosureExpression> innerClosures = new Stack<ClosureExpression>();
private Stack<ClosureExpression> innerClosures = new Stack<>();

private ClassNode targetGroovyPageNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ AnnotationNode findAnnotation(ClassNode clazz) {
int[] extractLineNumberArray(AnnotationNode node) {
ListExpression lineNumberArray = (ListExpression) node.getMember("lines");
// make assumption that this is a simple array of constants
List<Integer> numbers = new ArrayList<Integer>();
List<Integer> numbers = new ArrayList<>();
for (Expression e : lineNumberArray.getExpressions()) {
if (e instanceof ConstantExpression) {
numbers.add((Integer) ((ConstantExpression) e).getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class CachingGroovyPageStaticResourceLocator extends GroovyPageStaticResourceLocator {

private ConcurrentMap<String, CacheEntry<Resource>> uriResolveCache = new ConcurrentHashMap<String, CacheEntry<Resource>>();
private ConcurrentMap<String, CacheEntry<Resource>> uriResolveCache = new ConcurrentHashMap<>();

private long cacheTimeout = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class DefaultGroovyPageLocator implements GroovyPageLocator, ResourceLoad

private static final String BLANK = "";

protected Collection<ResourceLoader> resourceLoaders = new ConcurrentLinkedQueue<ResourceLoader>();
protected Collection<ResourceLoader> resourceLoaders = new ConcurrentLinkedQueue<>();

protected GrailsPluginManager pluginManager;

Expand All @@ -79,7 +79,7 @@ public class DefaultGroovyPageLocator implements GroovyPageLocator, ResourceLoad

protected boolean reloadEnabled = !this.warDeployed;

private Set<String> reloadedPrecompiledGspClassNames = new CopyOnWriteArraySet<String>();
private Set<String> reloadedPrecompiledGspClassNames = new CopyOnWriteArraySet<>();

public void setResourceLoader(ResourceLoader resourceLoader) {
addResourceLoader(resourceLoader);
Expand All @@ -96,7 +96,7 @@ public void setPrecompiledGspMap(Map<String, String> precompiledGspMap) {
this.precompiledGspMap = null;
}
else {
this.precompiledGspMap = new ConcurrentHashMap<String, String>(precompiledGspMap);
this.precompiledGspMap = new ConcurrentHashMap<>(precompiledGspMap);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class TagLibArtefactHandler extends ArtefactHandlerAdapter {

public static final String TYPE = "TagLib";

private Map<String, GrailsTagLibClass> tag2libMap = new HashMap<String, GrailsTagLibClass>();
private Map<String, GrailsTagLibClass> tag2libMap = new HashMap<>();

private Map<String, GrailsTagLibClass> namespace2tagLibMap = new HashMap<String, GrailsTagLibClass>();
private Map<String, GrailsTagLibClass> namespace2tagLibMap = new HashMap<>();

public TagLibArtefactHandler() {
super(TYPE, GrailsTagLibClass.class, DefaultGrailsTagLibClass.class, TYPE);
Expand All @@ -60,7 +60,7 @@ public String getPluginName() {
*/
@Override
public void initialize(ArtefactInfo artefacts) {
this.tag2libMap = new HashMap<String, GrailsTagLibClass>();
this.tag2libMap = new HashMap<>();
for (GrailsClass aClass : artefacts.getGrailsClasses()) {
GrailsTagLibClass taglibClass = (GrailsTagLibClass) aClass;
String namespace = taglibClass.getNamespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public class DefaultGrailsTagLibClass extends org.grails.core.DefaultGrailsTagLi

protected static final String TAG_LIB = TagLibArtefactHandler.TYPE;

private Set<String> tags = new HashSet<String>();
private Set<String> tags = new HashSet<>();

private String namespace = GrailsTagLibClass.DEFAULT_NAMESPACE;

private Set<String> returnObjectForTagsSet = new HashSet<String>();
private Set<String> returnObjectForTagsSet = new HashSet<>();

private Object defaultEncodeAs = null;

private Map<String, Object> encodeAsForTags = new HashMap<String, Object>();
private Map<String, Object> encodeAsForTags = new HashMap<>();

/**
* Default contructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void restoreItVariable(Binding currentBinding, Object originalIt) {
*/
@SuppressWarnings("unchecked")
private Map<String, Object> addAndSaveVariables(Binding binding, Map args) {
Map<String, Object> savedVariablesMap = new LinkedHashMap<String, Object>();
Map<String, Object> savedVariablesMap = new LinkedHashMap<>();
for (Iterator<Object> i = args.keySet().iterator(); i.hasNext(); ) {
String varname = String.valueOf(i.next());
savedVariablesMap.put(varname, binding.getVariable(varname));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class TagLibraryLookup implements ApplicationContextAware, GrailsApplicat

protected Map<String, NamespacedTagDispatcher> namespaceDispatchers = new HashMap<>();

protected Map<String, Set<String>> tagsThatReturnObjectForNamespace = new HashMap<String, Set<String>>();
protected Map<String, Set<String>> tagsThatReturnObjectForNamespace = new HashMap<>();

protected Map<String, Map<String, Map<String, Object>>> encodeAsForTagNamespaces = new HashMap<String, Map<String, Map<String, Object>>>();
protected Map<String, Map<String, Map<String, Object>>> encodeAsForTagNamespaces = new HashMap<>();

@Override
public void afterPropertiesSet() throws Exception {
Expand Down Expand Up @@ -119,7 +119,7 @@ private void registerTagLib(GrailsTagLibClass taglib, boolean isInitialization)
}
Set<String> tagsThatReturnObject = this.tagsThatReturnObjectForNamespace.get(namespace);
if (tagsThatReturnObject == null) {
tagsThatReturnObject = new HashSet<String>();
tagsThatReturnObject = new HashSet<>();
this.tagsThatReturnObjectForNamespace.put(namespace, tagsThatReturnObject);
}
Map<String, Object> tags = this.tagNamespaces.get(namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TemplateVariableBinding extends AbstractTemplateVariableBinding {

private Object owner;

private Set<String> cachedParentVariableNames = new HashSet<String>();
private Set<String> cachedParentVariableNames = new HashSet<>();

private boolean root;

Expand Down Expand Up @@ -196,7 +196,7 @@ public void setRoot(boolean root) {
@SuppressWarnings("unchecked")
@Override
public Set<String> getVariableNames() {
Set<String> variableNames = new HashSet<String>();
Set<String> variableNames = new HashSet<>();
if (this.parent != null) {
if (this.parent instanceof AbstractTemplateVariableBinding) {
variableNames.addAll(((AbstractTemplateVariableBinding) this.parent).getVariableNames());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private static OutputEncodingStack createNew(OutputEncodingStackAttributes attri
}

private static OutputEncodingStack lookupStack(OutputContext outputContext) {
OutputEncodingStack outputStack = (OutputEncodingStack) outputContext.getCurrentOutputEncodingStack();
OutputEncodingStack outputStack = outputContext.getCurrentOutputEncodingStack();
return outputStack;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void putTagLib(Map<String, Object> tags, String name, GrailsTagLibClas
}

public void setTagLibInstances(List<Object> tagLibInstances) {
this.tagLibInstancesSet = new LinkedHashSet<Object>();
this.tagLibInstancesSet = new LinkedHashSet<>();
this.tagLibInstancesSet.addAll(tagLibInstances);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class GroovyPagesTemplateRenderer implements InitializingBean {

private GroovyPagesTemplateEngine groovyPagesTemplateEngine;

private ConcurrentMap<String, CacheEntry<Template>> templateCache = new ConcurrentHashMap<String, CacheEntry<Template>>();
private ConcurrentMap<String, CacheEntry<Template>> templateCache = new ConcurrentHashMap<>();

private Object scaffoldingTemplateGenerator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected ServletRequestAttributes buildRequestAttributes(HttpServletRequest req
private GrailsPluginManager pluginManager;

@SuppressWarnings("rawtypes")
private Map<String, Class> binaryPluginViewsMap = new ConcurrentHashMap<String, Class>();
private Map<String, Class> binaryPluginViewsMap = new ConcurrentHashMap<>();

@Override
protected void initFrameworkServlet() throws BeansException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class GroovyPageViewResolver extends InternalResourceViewResolver impleme

protected GrailsConventionGroovyPageLocator groovyPageLocator;

private ConcurrentMap<String, CacheEntry<View>> viewCache = new ConcurrentHashMap<String, CacheEntry<View>>();
private ConcurrentMap<String, CacheEntry<View>> viewCache = new ConcurrentHashMap<>();

private boolean allowGrailsViewCaching = !GrailsUtil.isDevelopmentEnv();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GroovyPagesJspApplicationContext implements JspApplicationContext {

private static final ExpressionFactory expressionFactoryImpl = findExpressionFactoryImplementation();

private final LinkedList<ELContextListener> listeners = new LinkedList<ELContextListener>();
private final LinkedList<ELContextListener> listeners = new LinkedList<>();

private final CompositeELResolver elResolver = new CompositeELResolver();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public class JspInvokeGrailsTagLibTag extends BodyTagSupport implements DynamicA

private int invocationCount;

private List<Object> invocationArgs = new ArrayList<Object>();
private List<Object> invocationArgs = new ArrayList<>();

private List<String> invocationBodyContent = new ArrayList<String>();
private List<String> invocationBodyContent = new ArrayList<>();

private BeanWrapper bean;

protected Map<String, Object> attributes = new HashMap<String, Object>();
protected Map<String, Object> attributes = new HashMap<>();

private FastStringPrintWriter sw;

Expand Down Expand Up @@ -120,7 +120,7 @@ public final int doStartTag() throws JspException {
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
trimmed = trimmed.substring(1, trimmed.length() - 1);
Matcher m = ATTRIBUTE_MAP.matcher(trimmed);
Map<String, Object> attributeMap = new HashMap<String, Object>();
Map<String, Object> attributeMap = new HashMap<>();
while (m.find()) {
String attributeName = m.group(1);
String attributeValue = m.group(2);
Expand Down Expand Up @@ -337,7 +337,7 @@ public final void setDynamicAttribute(String uri, String localName, Object value
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
trimmed = trimmed.substring(1, trimmed.length() - 1);
Matcher m = ATTRIBUTE_MAP.matcher(trimmed);
Map<String, Object> attributeMap = new HashMap<String, Object>();
Map<String, Object> attributeMap = new HashMap<>();
while (m.find()) {
String attributeName = m.group(1);
String attributeValue = m.group(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
public final class FactoryHolder {

private static Holder<Factory> holder = new Holder<Factory>("factory");
private static Holder<Factory> holder = new Holder<>("factory");

private FactoryHolder() {
// static only
Expand Down
Loading

0 comments on commit 3359b6c

Please sign in to comment.