All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dagger.internal.codegen.writing.UnwrappedMapKeyGenerator Maven / Gradle / Ivy

There is a newer version: 2.52
Show newest version
/*
 * Copyright (C) 2016 The Dagger Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dagger.internal.codegen.writing;

import androidx.room.compiler.processing.XFiler;
import androidx.room.compiler.processing.XProcessingEnv;
import androidx.room.compiler.processing.XTypeElement;
import dagger.MapKey;
import java.util.Set;
import javax.inject.Inject;

/**
 * Generates classes that create annotation instances for an unwrapped {@link MapKey} annotation
 * type whose nested value is an annotation. The generated class will have a private empty
 * constructor and a static method that creates each annotation type that is nested in the top-level
 * annotation type.
 *
 * 

So for an example {@link MapKey} annotation: * *

 *   {@literal @MapKey}(unwrapValue = true)
 *   {@literal @interface} Foo {
 *     Bar bar();
 *   }
 *
 *   {@literal @interface} Bar {
 *     {@literal Class baz();}
 *   }
 * 
* * the generated class will look like: * *
 *   public final class FooCreator {
 *     private FooCreator() {}
 *
 *     public static Bar createBar({@literal Class baz}) { … }
 *   }
 * 
*/ public final class UnwrappedMapKeyGenerator extends AnnotationCreatorGenerator { @Inject UnwrappedMapKeyGenerator(XFiler filer, XProcessingEnv processingEnv) { super(filer, processingEnv); } @Override protected Set annotationsToCreate(XTypeElement annotationElement) { Set nestedAnnotationElements = super.annotationsToCreate(annotationElement); nestedAnnotationElements.remove(annotationElement); return nestedAnnotationElements; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy