com.google.gwt.core.ext.TreeLogger Java Examples
The following examples show how to use
com.google.gwt.core.ext.TreeLogger.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectMapperCreator.java From gwt-jackson with Apache License 2.0 | 6 votes |
/** * Extract the type to map from the interface. * * @param interfaceClass the interface * * @return the extracted type to map * @throws UnableToCompleteException if we don't find the type */ private JClassType extractMappedType( JClassType interfaceClass ) throws UnableToCompleteException { JClassType intf = interfaceClass.isInterface(); if ( intf == null ) { logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to be an interface." ); throw new UnableToCompleteException(); } JClassType[] intfs = intf.getImplementedInterfaces(); for ( JClassType t : intfs ) { if ( t.getQualifiedSourceName().equals( OBJECT_MAPPER_CLASS ) ) { return extractParameterizedType( OBJECT_MAPPER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_READER_CLASS ) ) { return extractParameterizedType( OBJECT_READER_CLASS, t.isParameterized() ); } else if ( t.getQualifiedSourceName().equals( OBJECT_WRITER_CLASS ) ) { return extractParameterizedType( OBJECT_WRITER_CLASS, t.isParameterized() ); } } logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to extend one of the following interface : " + OBJECT_MAPPER_CLASS + ", " + OBJECT_READER_CLASS + " or " + OBJECT_WRITER_CLASS ); throw new UnableToCompleteException(); }
Example #2
Source File: AppcacheLinkerTest.java From gwt-appcache with Apache License 2.0 | 6 votes |
@Test public void parseFallbackResources() throws Exception { final AppcacheLinker linker = new AppcacheLinker(); final HashSet<String> fallbackResources = new HashSet<>(); fallbackResources.add( "a b" ); fallbackResources.add( "c d" ); fallbackResources.add( " e f" ); fallbackResources.add( "g h " ); final Map<String, String> map = linker.parseFallbackResources( TreeLogger.NULL, fallbackResources ); assertEquals( map.get( "a" ), "b" ); assertEquals( map.get( "c" ), "d" ); assertEquals( map.get( "e" ), "f" ); assertEquals( map.get( "g" ), "h" ); }
Example #3
Source File: ServiceBinderCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
public String create(TreeLogger logger, GeneratorContext context) throws UnableToCompleteException, NotFoundException { PrintWriter printWriter = this.getPrintWriter(logger, context); if (printWriter == null) { return this.proxyModelQualifiedName; } this.serializerTypeName = this.createSerializer(logger, context); this.collectImports(); SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); srcWriter.println(); this.generateSerializer(srcWriter); srcWriter.println(); this.generateServiceImplementation(logger, srcWriter); this.generateServiceImplementationWithCallback(logger, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyModelQualifiedName; }
Example #4
Source File: ProxyViewCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter printWriter = context.tryCreate(logger, this.packageName, this.viewProxySimpleName); if (printWriter == null) { return this.viewProxyQualifiedName; } SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); this.generateProxy(logger, srcWriter); srcWriter.println(); this.generateTokenPrefixes(logger, srcWriter); srcWriter.println(); if (this.placeTokenizerClass == null) { this.generateInternalTokenizer(logger, srcWriter); } else { this.generateDelegateTokenizer(logger, srcWriter); } this.generateActivityFactory(logger, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.viewProxyQualifiedName; }
Example #5
Source File: JacksonTypeOracle.java From gwt-jackson with Apache License 2.0 | 6 votes |
/** * <p>Constructor for JacksonTypeOracle.</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param typeOracle a {@link com.google.gwt.core.ext.typeinfo.TypeOracle} object. */ public JacksonTypeOracle( TreeLogger logger, TypeOracle typeOracle ) { this.logger = logger; this.typeOracle = typeOracle; this.objectReaderType = typeOracle.findType( ObjectReader.class.getCanonicalName() ); this.objectWriterType = typeOracle.findType( ObjectWriter.class.getCanonicalName() ); this.keySerializerType = typeOracle.findType( KeySerializer.class.getCanonicalName() ); this.keyDeserializerType = typeOracle.findType( KeyDeserializer.class.getCanonicalName() ); this.jsonSerializerType = typeOracle.findType( JsonSerializer.class.getCanonicalName() ); this.jsonDeserializerType = typeOracle.findType( JsonDeserializer.class.getCanonicalName() ); this.mapType = typeOracle.findType( Map.class.getCanonicalName() ); this.iterableType = typeOracle.findType( Iterable.class.getCanonicalName() ); this.jsoType = typeOracle.findType( JavaScriptObject.class.getCanonicalName() ); this.enumType = typeOracle.findType( Enum.class.getCanonicalName() ); this.stringType = typeOracle.findType( String.class.getCanonicalName() ); }
Example #6
Source File: WorkerLinker.java From ThinkMap with Apache License 2.0 | 6 votes |
@Override protected EmittedArtifact emitSelectionScript(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException { Set<WorkerScript> scripts = artifacts.find(WorkerScript.class); if (scripts.size() != 1) { logger.branch(TreeLogger.ERROR, "Too many scripts"); throw new UnableToCompleteException(); } WorkerScript script = scripts.iterator().next(); DefaultTextOutput output = new DefaultTextOutput(true); output.print(context.optimizeJavaScript(logger, generateSelectionScript(logger, context, artifacts))); output.newlineOpt(); output.print(script.javascript); output.newlineOpt(); output.print("gwtOnLoad(null, \"__MODULE_NAME__\", null);"); return emitString(logger, output.toString(), context.getModuleName() + ".worker.js"); }
Example #7
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
private void writeMethods(TreeLogger logger, ResourceContext context, JMethod method, SourceWriter sw, ConstantDefinitions constantDefinitions, Map<String, String> originalConstantNameMapping, Map<String, String> substitutionMap) throws UnableToCompleteException { JClassType gssResource = method.getReturnType().isInterface(); boolean success = true; for (JMethod toImplement : gssResource.getOverridableMethods()) { if (toImplement == getTextMethod) { writeGetText(logger, context, method, sw); } else if (toImplement == ensuredInjectedMethod) { writeEnsureInjected(sw); } else if (toImplement == getNameMethod) { writeGetName(method, sw); } else { success &= writeUserMethod(logger, toImplement, sw, constantDefinitions, originalConstantNameMapping, substitutionMap); } } if (!success) { throw new UnableToCompleteException(); } }
Example #8
Source File: BeanProcessor.java From gwt-jackson with Apache License 2.0 | 6 votes |
/** * Process the properties of the bean to find additionnal informations like @JsonValue. * * @param configuration the configuration * @param logger the logger * @param typeOracle the oracle * @param beanInfo the previous bean information * @param properties the properties of the bean * @return the new informations about the bean and its properties */ public static BeanInfo processProperties( RebindConfiguration configuration, TreeLogger logger, JacksonTypeOracle typeOracle, BeanInfo beanInfo, PropertiesContainer properties ) { if ( !properties.getValuePropertyInfo().isPresent() && !properties.getAnyGetterPropertyInfo().isPresent() && !properties .getAnySetterPropertyInfo().isPresent() ) { return beanInfo; } BeanInfoBuilder builder = new BeanInfoBuilder( beanInfo ); builder.setValuePropertyInfo( properties.getValuePropertyInfo() ); if ( properties.getValuePropertyInfo().isPresent() && beanInfo.getTypeInfo().isPresent() && As.PROPERTY.equals( beanInfo .getTypeInfo().get().getInclude() ) ) { // if the bean has type info on property with @JsonValue, we change it to WRAPPER_ARRAY because the value may not be an object BeanTypeInfo typeInfo = beanInfo.getTypeInfo().get(); builder.setTypeInfo( Optional.of( new BeanTypeInfo( typeInfo.getUse(), As.WRAPPER_ARRAY, typeInfo .getPropertyName(), typeInfo.getMapTypeToSerializationMetadata(), typeInfo.getMapTypeToDeserializationMetadata() ) ) ); } builder.setAnyGetterPropertyInfo( properties.getAnyGetterPropertyInfo() ); builder.setAnySetterPropertyInfo( properties.getAnySetterPropertyInfo() ); return builder.build(); }
Example #9
Source File: ModelCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
private void createSubModels(TreeLogger logger, GeneratorContext context) { for (JType jType : this.imports) { if (jType == null) { continue; } if (jType.isEnum() != null) { continue; } if (ModelCreator.DISCARD_MODEL_TYPES.contains(jType.getQualifiedSourceName())) { continue; } if (jType instanceof JClassType) { ModelCreator creator = new ModelCreator((JClassType) jType); String subModelType = creator.create(logger, context); this.subModels.put(jType, subModelType); } } }
Example #10
Source File: PropertyParser.java From gwt-jackson with Apache License 2.0 | 6 votes |
private static void parseFields( TreeLogger logger, JClassType type, Map<String, PropertyAccessorsBuilder> propertiesMap, boolean mixin ) { if ( type.getQualifiedSourceName().equals( "java.lang.Object" ) ) { return; } for ( JField field : type.getFields() ) { if ( field.isStatic() ) { continue; } String fieldName = field.getName(); PropertyAccessorsBuilder property = propertiesMap.get( fieldName ); if ( null == property ) { property = new PropertyAccessorsBuilder( fieldName ); propertiesMap.put( fieldName, property ); } if ( property.getField().isPresent() && !mixin ) { // we found an other field with the same name on a superclass. we ignore it logger.log( Type.INFO, "A field with the same name as '" + field .getName() + "' has already been found on child class" ); } else { property.addField( field, mixin ); } } }
Example #11
Source File: ProductConfigGenerator.java From core with GNU Lesser General Public License v2.1 | 6 votes |
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { TypeOracle typeOracle = context.getTypeOracle(); try { // get classType and save instance variables JClassType classType = typeOracle.getType(typeName); packageName = classType.getPackage().getName(); className = classType.getSimpleSourceName() + "Impl"; // Generate class source code generateClass(logger, context); } catch (Throwable e) { // record to logger that Map generation threw an exception e.printStackTrace(System.out); logger.log(TreeLogger.ERROR, "Failed to generate product config", e); } // return the fully qualified name of the class generated return packageName + "." + className; }
Example #12
Source File: AppcacheLinker.java From gwt-appcache with Apache License 2.0 | 6 votes |
@Override public ArtifactSet link( @Nonnull final TreeLogger logger, @Nonnull final LinkerContext context, @Nonnull final ArtifactSet artifacts, final boolean onePermutation ) throws UnableToCompleteException { if ( onePermutation ) { return perPermutationLink( logger, context, artifacts ); } else { return perCompileLink( logger, context, artifacts ); } }
Example #13
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
private void validateExternalClasses(Set<String> externalClasses, Set<String> externalClassCandidates, JMethod method, TreeLogger logger) throws UnableToCompleteException { if (!isStrictResource(method)) { return; } boolean hasError = false; for (String candidate : externalClassCandidates) { if (!externalClasses.contains(candidate)) { logger.log(Type.ERROR, "The following non-obfuscated class is present in a strict " + "CssResource: " + candidate); hasError = true; } } if (hasError) { throw new UnableToCompleteException(); } }
Example #14
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
private String concatCssFiles(List<URL> resources, TreeLogger logger) throws UnableToCompleteException { StringBuffer buffer = new StringBuffer(); for (URL stylesheet : resources) { try { String fileContent = Resources.asByteSource(stylesheet).asCharSource(Charsets.UTF_8) .read(); buffer.append(fileContent); buffer.append("\n"); } catch (IOException e) { logger.log(TreeLogger.ERROR, "Unable to parse CSS", e); throw new UnableToCompleteException(); } } return buffer.toString(); }
Example #15
Source File: AbstractInjectorCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter writer = context.tryCreate(logger, this.packageName, this.proxyName); if (writer == null) { return this.proxyQualifiedName; } SourceWriter srcWriter = this.getSourceWriter(writer, context); srcWriter.indent(); this.doCreate(logger, context, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyQualifiedName; }
Example #16
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
@Override protected String getCssExpression(TreeLogger logger, ResourceContext context, JMethod method) throws UnableToCompleteException { CssTree cssTree = cssTreeMap.get(method).tree; String standard = printCssTree(cssTree); // TODO add configuration properties for swapLtrRtlInUrl, swapLeftRightInUrl and // shouldFlipConstantReferences booleans RecordingBidiFlipper recordingBidiFlipper = new RecordingBidiFlipper(cssTree.getMutatingVisitController(), false, false, true); recordingBidiFlipper.runPass(); if (recordingBidiFlipper.nodeFlipped()) { String reversed = printCssTree(cssTree); return LocaleInfo.class.getName() + ".getCurrentLocale().isRTL() ? " + reversed + " : " + standard; } else { return standard; } }
Example #17
Source File: RestServiceBinderCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter printWriter = this.getPrintWriter(logger, context); if (printWriter == null) { return this.proxyModelQualifiedName; } this.collectImports(); SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); srcWriter.println(); this.generateCreateService(srcWriter); srcWriter.println(); this.generateServiceImplementation(logger, srcWriter); this.generateServiceImplementationWithCallback(srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyModelQualifiedName; }
Example #18
Source File: GssGenerationVisitor.java From gss.gwt with Apache License 2.0 | 5 votes |
public GssGenerationVisitor(TextOutput out, Map<String, String> defKeyMapping, boolean lenient, TreeLogger treeLogger) { this.defKeyMapping = defKeyMapping; this.out = out; this.lenient = lenient; this.treeLogger = treeLogger; newLine = true; wrongExternalNodes = new ArrayList<CssExternalSelectors>(); wrongDefNodes = new ArrayList<CssDef>(); }
Example #19
Source File: ProxyViewGenerator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { TypeOracle typeOracle = context.getTypeOracle(); assert typeOracle != null; JClassType placeType = typeOracle.findType(typeName); if (placeType == null) { logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null); throw new UnableToCompleteException(); } ProxyViewCreator proxyCreator = new ProxyViewCreator(placeType); return proxyCreator.create(logger, context); }
Example #20
Source File: ModelCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void generateSingleton(TreeLogger logger, SourceWriter srcWriter) { String className = this.proxyModelQualifiedName.indexOf('.') == -1 ? this.proxyModelQualifiedName : this.proxyModelQualifiedName.substring(this.proxyModelQualifiedName.lastIndexOf('.') + 1, this.proxyModelQualifiedName.length()); srcWriter.println("public static final %s INSTANCE = new %s();", className, className); }
Example #21
Source File: ModelGenerator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String generate(TreeLogger logger, GeneratorContext context, String modelClass) throws UnableToCompleteException { TypeOracle typeOracle = context.getTypeOracle(); assert typeOracle != null; JClassType modelType = typeOracle.findType(modelClass); if (modelType == null) { logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + modelClass + "'", null); throw new UnableToCompleteException(); } JClassType beanType = null; for (JClassType interfaceType : modelType.getImplementedInterfaces()) { if (interfaceType.getQualifiedSourceName().equals(Model.class.getCanonicalName()) && interfaceType instanceof JParameterizedType) { JParameterizedType paramType = (JParameterizedType) interfaceType; beanType = paramType.getTypeArgs()[0]; } } if (beanType == null) { logger.log(TreeLogger.ERROR, modelType.getQualifiedSourceName() + " must implement " + Model.class.getCanonicalName(), null); throw new UnableToCompleteException(); } ModelCreator modelCreator = new ModelCreator(beanType); return modelCreator.create(logger, context); }
Example #22
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 5 votes |
@Override public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method) throws UnableToCompleteException { ExtendedCssTree extendedCssTree = cssTreeMap.get(method); RenamingResult renamingResult = doClassRenaming(extendedCssTree.tree, method, logger, context); // TODO : Should we foresee configuration properties for simplifyCss and eliminateDeadCode // booleans ? ConstantDefinitions constantDefinitions = optimize(extendedCssTree, context, true, true); checkErrors(); Set<String> externalClasses = revertRenamingOfExternalClasses(extendedCssTree.tree, renamingResult.mapping); // Validate that classes not assigned to one of the interface methods are external validateExternalClasses(externalClasses, renamingResult.externalClassCandidate, method, logger); SourceWriter sw = new StringSourceWriter(); sw.println("new " + method.getReturnType().getQualifiedSourceName() + "() {"); sw.indent(); writeMethods(logger, context, method, sw, constantDefinitions, extendedCssTree.originalConstantNameMapping, renamingResult.mapping); sw.outdent(); sw.println("}"); return sw.toString(); }
Example #23
Source File: ModelCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void generateInternalSet(TreeLogger logger, SourceWriter srcWriter) { srcWriter.println("protected <P> void internalSet(%s bean, String fieldName, P value){", this.beanType.getSimpleSourceName()); srcWriter.indent(); for (String propertyName : this.propertyTypes.keySet()) { JType propertyType = this.propertyTypes.get(propertyName); JPrimitiveType primitiveType = propertyType.isPrimitive(); JMethod setter = this.setters.get(propertyName); if (setter != null) { if (primitiveType != null) { srcWriter.println( "if(\"%s\".equals(fieldName)){ bean.%s((%s) PrimitiveUtils.asPrimitive((%s)value)); }", propertyName, setter.getName(), propertyType.getSimpleSourceName(), primitiveType.getQualifiedBoxedSourceName()); } else { srcWriter.println("if(\"%s\".equals(fieldName)){ bean.%s((%s) value); }", propertyName, setter.getName(), propertyType.getSimpleSourceName()); } } else if (this.publicFields.containsKey(propertyName)) { if (primitiveType != null) { srcWriter .println("if(\"%s\".equals(fieldName)){ bean.%s = PrimitiveUtils.asPrimitive((%s) value); }", propertyName, propertyName, primitiveType.getQualifiedBoxedSourceName()); } else { srcWriter .println("if(\"%s\".equals(fieldName)){ bean.%s = (%s) value; }", propertyName, propertyName, propertyType.getSimpleSourceName()); } } } srcWriter.outdent(); srcWriter.println("}"); }
Example #24
Source File: Mvp4gConfiguration.java From mvp4g with Apache License 2.0 | 5 votes |
/** * Remove all elements of the useless set from the set * * @param <T> type of the elements to remove * @param set set where elements need to be removed * @param toRemove set of elements to remove */ private <T extends Mvp4gElement> void removeUselessElements(Set<T> set, Set<T> toRemove) { for (T e : toRemove) { set.remove(e); logger.log(TreeLogger.DEBUG, String.format(REMOVE_OBJ, e.getTagName(), e.getUniqueIdentifier())); } }
Example #25
Source File: ProxyViewCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void generateActivityFactory(TreeLogger logger, SourceWriter srcWriter) { srcWriter.println("@Override"); srcWriter.println("public Activity createActivity(Place place) {"); srcWriter.indent(); srcWriter.println("return new ViewActivity(this, place);"); srcWriter.outdent(); srcWriter.println("}"); }
Example #26
Source File: ServiceBinderCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void generateServiceImplementation(TreeLogger logger, SourceWriter srcWriter) throws UnableToCompleteException { Set<String> addedMethods = Sets.newHashSet(); for (JMethod method : this.serviceType.getOverridableMethods()) { if (!addedMethods.contains(method.getName())) { addedMethods.add(method.getName()); this.writeStartMethod(srcWriter, method); this.writeCommandDefinition(logger, srcWriter, method, null); this.writeCommandParam(srcWriter, method, this.listCallbackMethods(logger, method), null); this.writeEndMethod(srcWriter, method); } } }
Example #27
Source File: Mvp4gConfiguration.java From mvp4g with Apache License 2.0 | 5 votes |
/** * Contruct a Mvp4gConfiguration object * * @param logger logger of the GWT compiler * @param context context of the GWT compiler */ public Mvp4gConfiguration(TreeLogger logger, GeneratorContext context) { this.logger = logger; this.oracle = context.getTypeOracle(); this.propertyOracle = context.getPropertyOracle(); }
Example #28
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 5 votes |
private boolean writeClassMethod(TreeLogger logger, JMethod userMethod, Map<String, String> substitutionMap, SourceWriter sw) throws UnableToCompleteException { if (!isReturnTypeString(userMethod.getReturnType().isClass())) { logger.log(Type.ERROR, "The return type of the method [" + userMethod.getName() + "] must " + "be java.lang.String."); throw new UnableToCompleteException(); } if (userMethod.getParameters().length > 0) { logger.log(Type.ERROR, "The method [" + userMethod.getName() + "] shouldn't contain any " + "parameters"); throw new UnableToCompleteException(); } String name = getClassName(userMethod); String value = substitutionMap.get(name); if (value == null) { logger.log(Type.ERROR, "The following style class [" + name + "] is missing from the source" + " CSS file"); return false; } else { writeSimpleGetter(userMethod, "\"" + value + "\"", sw); } return true; }
Example #29
Source File: InjectorModuleCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void doCreate(TreeLogger logger, GeneratorContext context, SourceWriter srcWriter) { super.doCreate(logger, context, srcWriter); srcWriter.println("@Override public void onModuleLoad() {"); srcWriter.indent(); try { if (this.injectableType.getMethod("onModuleLoad", new JType[] {}) != null) { srcWriter.println("super.onModuleLoad();"); } } catch (NotFoundException e) { srcWriter.println(""); } for (InjectorWritterEntryPoint delegate : Iterables.filter(this.delegates, InjectorWritterEntryPoint.class)) { delegate.writeEntryPoint(srcWriter); srcWriter.println(); } for (JMethod method : InjectCreatorUtil.listMethod(this.injectableType, EntryPointHandler.class)) { srcWriter.println("super.%s();", method.getName()); } srcWriter.println(); MvpDescription mvpAnnotation = this.injectableType.getAnnotation(MvpDescription.class); if (mvpAnnotation != null && mvpAnnotation.handleCurrentHistory()) { srcWriter.println("MvpController.get().handleCurrentHistory();"); } srcWriter.outdent(); srcWriter.println("}"); }
Example #30
Source File: JacksonTypeOracle.java From gwt-jackson with Apache License 2.0 | 5 votes |
/** * <p>getClassFromJsonDeserializeAnnotation</p> * * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object. * @param annotation a {@link java.lang.annotation.Annotation} object. * @param name a {@link java.lang.String} object. * @return a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object. */ public Optional<JClassType> getClassFromJsonDeserializeAnnotation( TreeLogger logger, Annotation annotation, String name ) { try { Class asClass = (Class) annotation.getClass().getDeclaredMethod( name ).invoke( annotation ); if ( asClass != Void.class ) { return Optional.fromNullable( getType( asClass.getCanonicalName() ) ); } } catch ( Exception e ) { logger.log( Type.ERROR, "Cannot find method " + name + " on JsonDeserialize annotation", e ); } return Optional.absent(); }