本文整理匯總了Java中com.google.gwt.core.ext.typeinfo.JClassType.getAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:Java JClassType.getAnnotation方法的具體用法?Java JClassType.getAnnotation怎麽用?Java JClassType.getAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.typeinfo.JClassType
的用法示例。
在下文中一共展示了JClassType.getAnnotation方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findLocalComponentsForComponent
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Register all locally declared components.
* @param localComponents The {@link LocalComponents} where we register our local components
* @param componentType The JClass type of the local component
* @param typeOracle Used to retrieve a {@link JClassType} in GWT Context
*/
private void findLocalComponentsForComponent(LocalComponents localComponents,
JClassType componentType, TypeOracle typeOracle)
{
Component componentAnnotation = componentType.getAnnotation(Component.class);
if (componentAnnotation == null)
return;
Arrays
.stream(componentAnnotation.components())
.map(Class::getCanonicalName)
.map(typeOracle::findType)
.forEach(childType -> processLocalComponentClass(localComponents, childType));
findLocalComponentsForComponent(localComponents, componentType.getSuperclass(), typeOracle);
}
示例2: processLocalComponentClass
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Register the local component and all of its {@link Prop}.
* This will be used for type validation.
* @param localComponents The {@link LocalComponents} object where we should register our {@link LocalComponent}
* @param localComponentType The {@link JClassType} of the {@link LocalComponent}
*/
private void processLocalComponentClass(LocalComponents localComponents,
JClassType localComponentType)
{
Component componentAnnotation = localComponentType.getAnnotation(Component.class);
String localComponentTagName =
componentToTagName(localComponentType.getName(), componentAnnotation);
if (localComponents.hasLocalComponent(localComponentTagName))
return;
LocalComponent localComponent = localComponents.addLocalComponent(localComponentTagName);
Arrays.stream(localComponentType.getFields()).forEach(field -> {
Prop propAnnotation = field.getAnnotation(Prop.class);
if (propAnnotation != null)
{
localComponent.addProp(field.getName(),
stringTypeToTypeName(field.getType().getQualifiedSourceName()),
propAnnotation.required());
}
});
}
示例3: loadDebug
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void loadDebug(JClassType c,
Events annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
Debug debug = c.getAnnotation(Debug.class);
if (debug != null) {
Class<? extends Mvp4gLogger> loggerClass = debug.logger();
DebugElement debugElem = new DebugElement();
debugElem.setLogger(loggerClass.getCanonicalName());
debugElem.setLogLevel(debug.logLevel()
.name());
configuration.setDebug(debugElem);
}
}
示例4: loadHistoryConfiguration
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void loadHistoryConfiguration(JClassType c,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
PlaceService historyConfig = c.getAnnotation(PlaceService.class);
if (historyConfig != null) {
HistoryElement history = configuration.getHistory();
if (history == null) {
history = new HistoryElement();
configuration.setHistory(history);
}
history.setPlaceServiceClass(historyConfig.value()
.getCanonicalName());
}
}
示例5: isNiceMock
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private boolean isNiceMock(JMethod method, JClassType mockControlInterface) {
boolean isNice = false; //default
Nice interfaceAnnotation = mockControlInterface.getAnnotation(Nice.class);
if (interfaceAnnotation != null) {
isNice = interfaceAnnotation.value();
}
Nice methodAnotation = method.getAnnotation(Nice.class);
if (methodAnotation != null) {
isNice = methodAnotation.value();
}
return isNice;
}
示例6: getClassTypeAnnotation
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Return annotation instance of classType which match annotation class.
* NOTE: this function will check classType and all it's parent to see if annotation class exists
* @param <T> the type of annotation
* @param classType
* @param annotationClass
* @return
*/
public static <T extends Annotation> T getClassTypeAnnotation(JClassType classType, Class<T> annotationClass){
JClassType parent = classType;
while (parent != null){
if (parent.getAnnotation(annotationClass) != null)
return parent.getAnnotation(annotationClass);
parent = parent.getSuperclass();
}
return null;
}
示例7: getAllAnnotations
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Get All annotations from classType
* NOTE: This is ordered by ParentClass to DevidedClass
* The parentclass's annotation comes first
* @param <T>
* @param classType
* @param annotationClass
* @return
*/
public static <T extends Annotation> Map<Object, T> getAllAnnotations(JClassType classType, Class<T> annotationClass){
Map<Object, T> results = new HashMap<Object, T>();
JClassType parent = classType.getSuperclass();
if (parent != null){
results.putAll(getAllAnnotations(parent, annotationClass));
}
T a = classType.getAnnotation(annotationClass);
if (a != null){
results.put(classType, a);
}
for (JField field : classType.getFields()){
a = field.getAnnotation(annotationClass);
if (a != null)
results.put(field, a);
}
for (JMethod method : classType.getMethods()){
a = method.getAnnotation(annotationClass);
if (a != null)
results.put(method, a);
}
return results;
}
示例8: loadHandler
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
@Override
protected EventHandlerElement loadHandler(JClassType c,
EventHandler annotation,
Mvp4gConfiguration configuration)
throws Mvp4gAnnotationException {
if (c.getAnnotation(Presenter.class) != null) {
String err = "You can't annotate a class with @Presenter and @EventHandler.";
throw new Mvp4gAnnotationException(c.getQualifiedSourceName(),
null,
err);
}
return new EventHandlerElement();
}
示例9: getDefaultSettings
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
public static Reflectable getDefaultSettings(TypeOracle typeOracle){
JClassType type = typeOracle.findType(Reflect_Full.class.getCanonicalName());
return type.getAnnotation(Reflectable.class);
}
示例10: getFullSettings
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
public static Reflectable getFullSettings(TypeOracle typeOracle){
JClassType type = typeOracle.findType(Reflect_Full.class.getCanonicalName());
return type.getAnnotation(Reflectable.class);
}
示例11: generateConstructor
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
/**
* Generate constructor with dependencies added into field
*
* @param className
* @param extensions
* @param sw
* @throws UnableToCompleteException
*/
private void generateConstructor(String className, List<JClassType> extensions, SourceWriter sw)
throws UnableToCompleteException {
// constructor
sw.indent();
sw.print("public %s()", className);
sw.println("{");
sw.indent();
{
for (JClassType extension : extensions) {
sw.println("{");
sw.indent();
/*
Array<DependencyDescription> deps = Collections.<DependencyDescription> createArray();
*/
generateDependenciesForExtension(sw, extension);
Extension annotation = extension.getAnnotation(Extension.class);
/*
extensions.put("ide.ext.demo", new ExtensionDescription("ide.ext.demo", "1.0.0", "Demo extension", deps,
demoExtProvider));
*/
// the class's fqn
String extensionId = extension.getQualifiedSourceName();
sw.println(
"extensions.put(\"%s\", new ExtensionDescription(\"%s\",\"%s\",\"%s\",\"%s\",deps));",
escape(extensionId),
escape(extensionId),
escape(annotation.version()),
escape(annotation.title()),
escape(annotation.description()));
sw.outdent();
sw.println("}");
}
}
sw.outdent();
sw.println("}");
}
示例12: generateClass
import com.google.gwt.core.ext.typeinfo.JClassType; //導入方法依賴的package包/類
private void generateClass(TreeLogger logger, GeneratorContext context, String packageName, String className,
List<JClassType> componentExtensionClasses) {
PrintWriter pw = context.tryCreate(logger, packageName, className);
if (pw == null) {
return;
}
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
// imports
composerFactory.addImport(HashMap.class.getCanonicalName());
composerFactory.addImport(Map.class.getCanonicalName());
composerFactory.addImport(ComponentProvider.class.getCanonicalName());
composerFactory.addImport(ComponentExtensionManager.class.getCanonicalName());
composerFactory.addImport(ComponentProviderProxyImpl.class.getCanonicalName());
composerFactory.addImport(GWT.class.getCanonicalName());
composerFactory.addImport(Inject.class.getCanonicalName());
// interface
composerFactory.addImplementedInterface(ComponentExtensionManager.class.getCanonicalName());
SourceWriter sw = composerFactory.createSourceWriter(context, pw);
// fields
sw.println("private Map<String, ComponentProviderProxy> _providers = new HashMap<String, ComponentProviderProxy>();");
sw.println("private Map<String, String> _typeToName = new HashMap<String, String>();");
// constructor
sw.println("public " + className + "() {");
sw.indent();
for (JClassType extensionClass : componentExtensionClasses) {
ComponentExtension extensionAnnotation = extensionClass.getAnnotation(ComponentExtension.class);
sw.println("_providers.put(\"" + extensionAnnotation.componentName()
+ "\", new ComponentProviderProxyImpl(\"" + extensionAnnotation.displayName() + "\") {");
sw.indent();
sw.println("public ComponentProvider instantiate() {");
sw.indentln("return GWT.create(" + extensionClass.getQualifiedSourceName() + ".class);");
sw.println("}");
sw.outdent();
sw.println("});");
for (String type : extensionAnnotation.activationTypes()) {
sw.println("_typeToName.put(\"" + type + "\", \"" + extensionAnnotation.componentName() + "\");");
}
}
sw.outdent();
sw.println("}");
// methods
// getExtensionProviders
sw.println("public Map<String, ComponentProviderProxy> getExtensionProviders() {");
sw.indentln("return _providers;");
sw.println("}");
// getExtensionProviderByComponentName
sw.println("public ComponentProviderProxy getExtensionProviderByComponentName(String componentName) {");
sw.indent();
sw.println("if (_providers.containsKey(componentName)) {");
sw.indentln("return _providers.get(componentName);");
sw.println("}");
sw.println("return null;");
sw.outdent();
sw.println("}");
// getExtensionProviderByTypeName
sw.println("public ComponentProviderProxy getExtensionProviderByTypeName(String typeName) {");
sw.indent();
sw.println("if (_typeToName.containsKey(typeName)) {");
sw.indentln("return getExtensionProviderByComponentName(_typeToName.get(typeName));");
sw.println("}");
sw.println("return null;");
sw.outdent();
sw.println("}");
// close it out
sw.outdent();
sw.println("}");
context.commit(logger, pw);
}