Examples of ReflectionHelper


Examples of com.gwtplatform.dispatch.annotation.helper.ReflectionHelper

    @Override
    public void process(Element dtoElement) {
        BuilderGenerationHelper writer = null;
        try {
            ReflectionHelper reflection = new ReflectionHelper(getEnvironment(), (TypeElement) dtoElement);
            String dtoElementSimpleName = reflection.getSimpleClassName();
            String dtoSimpleName = dtoElementSimpleName + "Dto";
            String dtoClassName = reflection.getClassName() + "Dto";

            printMessage("Generating '" + dtoClassName + "' from '" + dtoElementSimpleName + "'.");

            @SuppressWarnings("resource")
            Writer sourceWriter = getEnvironment().getFiler().createSourceFile(dtoClassName, dtoElement).openWriter();
            writer = new BuilderGenerationHelper(sourceWriter);

            Collection<VariableElement> orderedElementFields = reflection.getOrderedFields();
            Collection<VariableElement> allFields = reflection.getNonConstantFields();
            Collection<VariableElement> optionalFields = reflection.getOptionalFields();
            Collection<VariableElement> requiredFields = reflection.getNonConstantFields();
            requiredFields.removeAll(optionalFields);

            writer.generatePackageDeclaration(reflection.getPackageName());
            writer.generateImports("com.google.gwt.user.client.rpc.IsSerializable");
            writer.generateClassHeader(dtoSimpleName, null, reflection.getClassRepresenter().getModifiers(),
                    "IsSerializable");
            writer.generateFieldDeclarations(orderedElementFields);

            if (!optionalFields.isEmpty()) { // has optional fields.
                writer.setWhitespaces(2);
View Full Code Here

Examples of com.gwtplatform.dispatch.annotation.helper.ReflectionHelper

    protected void generateProxy(Element proxyElement, String targetPackage, String[] filterSetter,
            String[] filterGetter, boolean isEmbeddedType, TypeMirror locatorType) {
        InterfaceGenerationHelper writer = null;
        try {
            ReflectionHelper reflection = new ReflectionHelper(getEnvironment(), (TypeElement) proxyElement);
            String proxyElementSimpleName = reflection.getSimpleClassName();
            String proxyElementClassName = reflection.getClassName();
            String proxyElementPackage = reflection.getPackageName();

            // Magic: By default proxies should be available for client and server side.
            String preparedProxyElementClassName = proxyElementClassName.replace(".server", ".shared");
            String preparedProxyElementPackage = proxyElementPackage.replace(".server", ".shared");

            if (targetPackage != null && !targetPackage.isEmpty()) {
                // Prepare user defined proxy target package and do not replace server with shared.
                preparedProxyElementClassName = targetPackage + "." + proxyElementSimpleName;
                preparedProxyElementPackage = targetPackage;
            }

            String proxySimpleName = proxyElementSimpleName + "Proxy";
            String proxyClassName = preparedProxyElementClassName + "Proxy";

            @SuppressWarnings("resource")
            Writer sourceWriter = getEnvironment().getFiler().createSourceFile(proxyClassName,
                    proxyElement).openWriter();
            writer = new InterfaceGenerationHelper(sourceWriter);
            writer.generatePackageDeclaration(preparedProxyElementPackage);

            if (isEmbeddedType) {
                generateValueProxyHeader(writer, reflection, proxyElementClassName, proxySimpleName);
            } else {
                generateEntityProxyHeader(writer, reflection, proxyElementClassName, proxySimpleName, locatorType);
            }

            writer.println();

            Collection<VariableElement> allFields = reflection.getNonConstantFields();

            // Generate getters.
            Collection<VariableElement> getterFields = reflection.filterFields(allFields, filterGetter);
            for (VariableElement getterField : getterFields) {
                generateGetter(writer, getterField);
            }

            // Generate setters.
            Collection<VariableElement> setterFields = reflection.filterFields(allFields, filterSetter);
            for (VariableElement setterField : setterFields) {
                generateSetter(writer, setterField);
            }

            writer.println();
View Full Code Here

Examples of com.gwtplatform.dispatch.annotation.helper.ReflectionHelper

    @Override
    public void process(Element eventElement) {
        BuilderGenerationHelper writer = null;
        try {
            ReflectionHelper reflection = new ReflectionHelper(getEnvironment(), (TypeElement) eventElement);
            String eventElementSimpleName = reflection.getSimpleClassName();
            String eventSimpleName = eventElementSimpleName + "Event";
            String eventClassName = reflection.getClassName() + "Event";

            @SuppressWarnings("resource")
            Writer sourceWriter = getEnvironment().getFiler().createSourceFile(eventClassName,
                    eventElement).openWriter();
            writer = new BuilderGenerationHelper(sourceWriter);

            Collection<VariableElement> orderedElementFields = reflection.getOrderedFields();
            Collection<VariableElement> allFields = reflection.getNonConstantFields();
            Collection<VariableElement> optionalFields = reflection.getOptionalFields();
            Collection<VariableElement> requiredFields = reflection.getNonConstantFields();
            requiredFields.removeAll(optionalFields);

            writer.generatePackageDeclaration(reflection.getPackageName());
            writer.generateImports(
                    "com.google.gwt.event.shared.EventHandler",
                    "com.google.gwt.event.shared.GwtEvent",
                    "com.google.web.bindery.event.shared.HandlerRegistration",
                    null,
                    "com.google.gwt.event.shared.HasHandlers"
            );

            writer.generateClassHeader(eventSimpleName,
                    "GwtEvent<" + eventSimpleName + "." + eventElementSimpleName + "Handler>",
                    reflection.getClassRepresenter().getModifiers()
            );
            writer.generateFieldDeclarations(orderedElementFields);

            if (!optionalFields.isEmpty()) { // has optional fields.
                writer.setWhitespaces(2);
View Full Code Here

Examples of com.gwtplatform.dispatch.annotation.helper.ReflectionHelper

    protected void generateAction(Element dispatchElement, boolean isSecure, String serviceName,
            String extraActionInterfaces) {
        BuilderGenerationHelper writer = null;
        try {
            ReflectionHelper reflection = new ReflectionHelper(getEnvironment(), (TypeElement) dispatchElement);
            String dispatchElementSimpleName = reflection.getSimpleClassName();
            String dispatchActionSimpleName = dispatchElementSimpleName + "Action";
            String dispatchActionClassName = reflection.getClassName() + "Action";

            printMessage("Generating '" + dispatchActionClassName + "' from '" + dispatchElementSimpleName + "'.");

            @SuppressWarnings("resource")
            Writer sourceWriter = getEnvironment().getFiler().createSourceFile(dispatchActionClassName,
                    dispatchElement).openWriter();
            writer = new BuilderGenerationHelper(sourceWriter);

            Collection<VariableElement> annotatedInFields = reflection.getInFields();
            Collection<VariableElement> allFields = reflection.filterConstantFields(reflection.getInFields());
            Collection<VariableElement> optionalFields = reflection.sortFields(In.class,
                    reflection.getOptionalFields(In.class));
            Collection<VariableElement> requiredFields = reflection.filterConstantFields(reflection.getInFields());
            requiredFields.removeAll(optionalFields);

            writer.generatePackageDeclaration(reflection.getPackageName());
            writer.generateImports(RPC_DISPATCH_PACKAGE + ".Action");

            String actionInterface = "Action<" + dispatchElementSimpleName + "Result>";
            writer.generateClassHeader(dispatchActionSimpleName, null,
                    reflection.getClassRepresenter().getModifiers(),
                    actionInterface, extraActionInterfaces
            );
            writer.generateFieldDeclarations(annotatedInFields);

            if (!optionalFields.isEmpty()) { // has optional fields.
View Full Code Here

Examples of com.gwtplatform.dispatch.annotation.helper.ReflectionHelper

    }

    protected void generateResult(Element dispatchElement, String extraResultInterfaces) {
        BuilderGenerationHelper writer = null;
        try {
            ReflectionHelper reflection = new ReflectionHelper(getEnvironment(), (TypeElement) dispatchElement);
            String dispatchElementSimpleName = reflection.getSimpleClassName();
            String dispatchResultSimpleName = dispatchElementSimpleName + "Result";
            String dispatchResultClassName = reflection.getClassName() + "Result";

            printMessage("Generating '" + dispatchResultClassName + "' from '" + dispatchElementSimpleName + "'.");

            @SuppressWarnings("resource")
            Writer sourceWriter = getEnvironment().getFiler().createSourceFile(dispatchResultClassName,
                    dispatchElement).openWriter();
            writer = new BuilderGenerationHelper(sourceWriter);

            Collection<VariableElement> annotatedOutFields = reflection.getOutFields();
            Collection<VariableElement> allFields = reflection.filterConstantFields(reflection.getOutFields());
            Collection<VariableElement> optionalFields = reflection.sortFields(Out.class,
                    reflection.getOptionalFields(Out.class));
            Collection<VariableElement> requiredFields = reflection.filterConstantFields(reflection.getOutFields());
            requiredFields.removeAll(optionalFields);

            writer.generatePackageDeclaration(reflection.getPackageName());
            writer.generateImports(
                    reflection.hasOptionalFields() ? IsSerializable.class.getName() : null,
                    null,
                    RPC_DISPATCH_PACKAGE + ".Result"
            );

            String resultInterface = "Result";
            writer.generateClassHeader(dispatchResultSimpleName, null,
                    reflection.getClassRepresenter().getModifiers(),
                    resultInterface, extraResultInterfaces
            );
            writer.generateFieldDeclarations(annotatedOutFields);

            if (!optionalFields.isEmpty()) {
View Full Code Here

Examples of honeycrm.server.ReflectionHelper

public class RelatesToTest extends TestCase {
  public void testRelatesToIsSet() {
    try {
      boolean failed = false;

      final ReflectionHelper reflectionHelper = new CachingReflectionHelper();

      for (final Class<? extends AbstractEntity> clazz : ReflectionHelper.getClasses("honeycrm.server.domain")) {
        if (Modifier.isAbstract(clazz.getModifiers())) {
          continue;
        }

        for (final Field field : reflectionHelper.getAllFields(clazz)) {
          final boolean isLong = Long.class.equals(field.getType()) || long.class.equals(field.getType());
          final boolean hasCorrectName = field.getName().toLowerCase().contains("id");
          final boolean isAnnotated = field.isAnnotationPresent(FieldRelateAnnotation.class);

          if (isLong && hasCorrectName && !isAnnotated) {
View Full Code Here

Examples of org.gridkit.coherence.utils.pof.ReflectionHelper

    }
   
    @Test
    public void helperTest() {
       
        ReflectionHelper helper = new ReflectionHelper("count");
       
        Assert.assertEquals(3, helper.extract("ABC"));
       
        @SuppressWarnings("unused")
        class TT {
      String a = "ABC";
            String[] b = {"A", "B", "C"};
        }
       
        TT t = new TT();
       
        helper = new ReflectionHelper("a");
        Assert.assertEquals("ABC", helper.extract(t));
        helper = new ReflectionHelper("a.count");
        Assert.assertEquals(3, helper.extract(t));
        helper = new ReflectionHelper("b.length");
        Assert.assertEquals(3, helper.extract(t));
    }
View Full Code Here

Examples of org.teiid.core.util.ReflectionHelper

    }
    return cs;
  }

  public <T> void registerClientService(Class<T> iface, T instance, String loggingContext) {
    this.clientServices.put(iface.getName(), new ClientService(instance, loggingContext, new ReflectionHelper(iface)));
 
View Full Code Here

Examples of org.teiid.core.util.ReflectionHelper

        boolean requiresContext = false;
        // Defect 20007 - Ignore the invocation method if pushdown is not required.
        if (validateClass && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) {
            try {
                Class<?> methodClass = source.getInvocationClass(method.getInvocationClass());
                ReflectionHelper helper = new ReflectionHelper(methodClass);
                try {
                  invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
                } catch (NoSuchMethodException e) {
                    inputTypes.add(0, CommandContext.class);
                  invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
                  requiresContext = true;
                }
            } catch (ClassNotFoundException e) {
              throw new TeiidRuntimeException(e, "ERR.015.001.0047", QueryPlugin.Util.getString("FunctionTree.no_class", method.getName(), method.getInvocationClass())); //$NON-NLS-1$ //$NON-NLS-2$
            } catch (NoSuchMethodException e) {
View Full Code Here

Examples of refutils.ReflectionHelper

                    return new UnsortedWrapper<T>(content);
                }

            };
        } else {
            new ReflectionHelper(wrapperFactory).setField(fileUtil);
        }
        new ReflectionHelper(xmlProcessor).setField(wrapperFactory);
        xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(UTF_8)));
        return xmlProcessor;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.