Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License
*
* Copyright 2018 Tim Boudreau.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.mastfrog.graal.injection.processor;
import com.mastfrog.annotation.AnnotationUtils;
import com.mastfrog.graal.injection.processor.GraalEntryIndexFactory.GraalEntry;
import com.mastfrog.annotation.registries.AnnotationIndexFactory;
import com.mastfrog.annotation.registries.IndexEntry;
import com.mastfrog.util.fileformat.SimpleJSON;
import java.io.IOException;
import java.io.OutputStream;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
/**
*
* @author Tim Boudreau
*/
final class GraalEntryIndexFactory extends AnnotationIndexFactory {
@Override
protected AnnotationIndex newIndex(String path) {
return new GraalIndex();
}
static final class GraalIndex extends AnnotationIndex {
@Override
public void write(OutputStream out, ProcessingEnvironment processingEnv) throws IOException {
Map> m1 = new TreeMap<>();
Set alls = new HashSet<>();
// Group by class name
for (GraalEntry g : this) {
if (g.isAll()) {
alls.add(g.className);
}
List l = m1.get(g.className);
if (l == null) {
l = new ArrayList<>(2);
m1.put(g.className, l);
}
l.add(g);
}
// Build entries for all items where we are exposing all
// methods and constructors; consolidate any fields
// into such records, since there is no allDeclaredFields
// option
List