List of usage examples for com.google.gwt.user.rebind SourceWriter print
void print(String s);
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeGetConstraintsForClass(final SourceWriter sw, final BeanHelper bean) { // if (clazz.eqals(MyBean.class)) { sw.println("if (clazz.equals(" + bean.getTypeCanonicalName() + ".class)) {"); sw.indent();/*from w w w. jav a 2 s .c o m*/ // return MyBeanValidator.INSTANCE.getConstraints(getValidationGroupsMetadata()); sw.print("return "); sw.print(bean.getFullyQualifiedValidatorName()); sw.println(".INSTANCE.getConstraints(getValidationGroupsMetadata());"); // } sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeGwtValidate(final SourceWriter sw) { // public <T> Set<ConstraintViolation<T>> validate(GwtValidationContext<T> // context,/* w w w . j a v a2s .c o m*/ sw.print("public <T> Set<ConstraintViolation<T>> "); sw.println("validate(GwtValidationContext<T> context,"); sw.indent(); sw.indent(); // Object object, Class<?>... groups) { sw.println("Object object, Class<?>... groups) {"); sw.outdent(); sw.println("checkNotNull(context, \"context\");"); sw.println("checkNotNull(object, \"object\");"); sw.println("checkNotNull(groups, \"groups\");"); sw.println("checkGroups(groups);"); for (final BeanHelper bean : this.cache.getAllBeans()) { this.writeGwtValidate(sw, bean); } // TODO(nchalko) log warning instead. this.writeThrowIllegalArgumnet(sw, "object.getClass().getName()"); sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeGwtValidate(final SourceWriter sw, final BeanHelper bean) { this.writeIfInstanceofBeanType(sw, bean); sw.indent();/* ww w . j a v a2 s.c om*/ // return PersonValidator.INSTANCE sw.print("return "); sw.println(bean.getFullyQualifiedValidatorName() + ".INSTANCE"); sw.indent(); sw.indent(); // .validate(context, (<<MyBean>>) object, groups); sw.print(".validate(context, "); sw.print("(" + bean.getTypeCanonicalName() + ") object, "); sw.println("groups);"); sw.outdent(); sw.outdent(); // } sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeIfInstanceofBeanType(final SourceWriter sourceWriter, final BeanHelper bean) { // if (object instanceof MyBean) { sourceWriter.print("if (object instanceof "); sourceWriter.print(bean.getTypeCanonicalName()); sourceWriter.println(") {"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeThrowIllegalArgumnet(final SourceWriter sourceWriter, final String getClassName) { // throw new IllegalArgumentException("MyValidator can not validate ", sourceWriter.print("throw new IllegalArgumentException(\""); sourceWriter.print(this.validatorType.getName() + " can not validate \""); sourceWriter.indent();//from w w w . j a va 2s.c o m sourceWriter.indent(); // + object.getClass().getName() +". " sourceWriter.print("+ "); sourceWriter.print(getClassName); sourceWriter.println("+ \". \""); // + "Valid values are {Foo.clas, Bar.class} sourceWriter.print("+ \"Valid types are "); sourceWriter.print(this.beansToValidate.toString()); sourceWriter.println("\");"); sourceWriter.outdent(); sourceWriter.outdent(); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeValidate(final SourceWriter sw, final BeanHelper bean) { this.writeIfInstanceofBeanType(sw, bean); sw.indent();//ww w.j a v a 2 s . c om this.writeContext(sw, bean, "object"); // return PersonValidator.INSTANCE sw.print("return "); sw.println(bean.getFullyQualifiedValidatorName() + ".INSTANCE"); sw.indent(); sw.indent(); // .validate(context, (<<MyBean>>) object, groups); sw.print(".validate(context, "); sw.print("(" + bean.getTypeCanonicalName() + ") object, "); sw.println("groups);"); sw.outdent(); sw.outdent(); // } sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeValidateProperty(final SourceWriter sw, final BeanHelper bean) { this.writeIfInstanceofBeanType(sw, bean); sw.indent();/*from w w w . j av a 2 s.com*/ this.writeContext(sw, bean, "object"); // return PersonValidator.INSTANCE sw.print("return "); sw.println(bean.getFullyQualifiedValidatorName() + ".INSTANCE"); sw.indent(); sw.indent(); // .validateProperty(context, (MyBean) object, propertyName, groups); sw.print(".validateProperty(context, ("); sw.print(bean.getTypeCanonicalName()); sw.print(") object, propertyName, "); sw.println("groups);"); sw.outdent(); sw.outdent(); // } sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeValidateValue(final SourceWriter sw, final BeanHelper bean) { sw.println("if (beanType.equals(" + bean.getTypeCanonicalName() + ".class)) {"); sw.indent();//from w w w. ja v a 2 s. c o m this.writeContext(sw, bean, "null"); // return PersonValidator.INSTANCE sw.print("return "); sw.println(bean.getFullyQualifiedValidatorName() + ".INSTANCE"); sw.indent(); sw.indent(); // .validateValue(context, (Class<MyBean> beanType, propertyName, value, // groups); sw.print(".validateValue(context, (Class<"); sw.print(bean.getTypeCanonicalName()); sw.println(">)beanType, propertyName, value, groups);"); sw.outdent(); sw.outdent(); // } sw.outdent(); sw.println("}"); }
From source file:fr.putnami.pwt.core.inject.rebind.delegate.InjectSecuritedCreator.java
License:Open Source License
@Override public void writeBeforePresent(SourceWriter srcWriter) { if (this.securedAnnotation.value() != null) { srcWriter.print("SessionController.get().checkAuthorized(place"); for (String value : this.securedAnnotation.value()) { srcWriter.print(", \"%s\"", value); }/*from w w w.ja v a2s .c o m*/ srcWriter.println(");"); } }
From source file:fr.putnami.pwt.core.service.rebind.ServiceBinderCreator.java
License:Open Source License
private void writeCommandDefinition(TreeLogger logger, SourceWriter srcWriter, JMethod method, JParameter callbackParameter) throws UnableToCompleteException { srcWriter.print("CommandDefinition commandDefinition = new CommandDefinition("); srcWriter.print("\"%s\", ", this.serviceType.getQualifiedSourceName()); srcWriter.print("\"%s\", ", method.getName()); if (callbackParameter != null) { JParameterizedType parameterizedCallback = callbackParameter.getType().isParameterized(); if (parameterizedCallback != null) { srcWriter.print("\"%s\" ", parameterizedCallback.getTypeArgs()[0].getQualifiedSourceName()); } else {//from w w w.j av a2s .c o m logger.branch(TreeLogger.ERROR, "Callback argument type for method " + method.getName() + " is not parametrized", null); throw new UnableToCompleteException(); } } else { srcWriter.print("\"%s\" ", method.getReturnType().getQualifiedSourceName()); } for (JParameter parameter : method.getParameters()) { if (!parameter.equals(callbackParameter)) { srcWriter.print(", \"%s\"", parameter.getType().getQualifiedSourceName()); } } srcWriter.println(");"); }