List of usage examples for com.google.gwt.user.rebind SourceWriter outdent
void outdent();
From source file:de.knightsoftnet.validators.rebind.GwtSpecificValidatorCreator.java
License:Apache License
private void writeValidateValueGroups(final SourceWriter sw) throws UnableToCompleteException { // public <T> void validateValueGroups( sw.println("public <T> void validateValueGroups("); // GwtValidationContext<T> context, Class<Author> beanType, String propertyName, // Object value, Set<ConstraintViolation<T>> violations, Class<?>... groups) { sw.indent();// w w w . j ava 2s . c o m sw.indent(); sw.println("GwtValidationContext<T> context,"); sw.println("Class<" + this.beanHelper.getTypeCanonicalName() + "> beanType,"); sw.println("String propertyName,"); sw.println("Object value,"); sw.println("Set<ConstraintViolation<T>> violations,"); sw.println("Class<?>... groups) {"); sw.outdent(); for (final PropertyDescriptor property : this.beanHelper.getBeanDescriptor().getConstrainedProperties()) { // if (propertyName.equals(myPropety)) { sw.print("if (propertyName.equals(\""); sw.print(property.getPropertyName()); sw.println("\")) {"); sw.indent(); if (!isIterableOrMap(property.getElementClass())) { this.writeValidatePropertyCall(sw, property, true, false); } // validate all super classes and interfaces this.writeValidateInheritance(sw, this.beanHelper.getClazz(), Stage.VALUE, property); // } sw.outdent(); sw.print("} else "); } this.writeIfPropertyNameNotFound(sw); sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeConstructor(final SourceWriter sw) { // public MyValidator() { sw.println("public " + this.getSimpleName() + "() {"); sw.indent();//from w w w .j a v a 2s.c o m // super(createValidationGroupsMetadata()); sw.println("super(createValidationGroupsMetadata());"); sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeContext(final SourceWriter sw, final BeanHelper bean, final String objectName) { // GwtValidationContext<MyBean> context = new GwtValidationContext<MyBean>( sw.print(GwtValidationContext.class.getSimpleName()); sw.print("<T> context = new "); sw.print(GwtValidationContext.class.getSimpleName()); sw.println("<T>("); sw.indent();/*from www .ja va2s.co m*/ sw.indent(); // (Class<T>) MyBean.class, sw.print("(Class<T>) "); sw.println(bean.getTypeCanonicalName() + ".class, "); // object, sw.println(objectName + ", "); // MyBeanValidator.INSTANCE.getConstraints(getValidationGroupsMetadata()), sw.print(bean.getFullyQualifiedValidatorName()); sw.println(".INSTANCE.getConstraints(getValidationGroupsMetadata()), "); // getMessageInterpolator(), sw.println("getMessageInterpolator(), "); // getTraversableResolver(), sw.println("getTraversableResolver(), "); // this); sw.println("this);"); sw.outdent(); sw.outdent(); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeCreateValidationGroupsMetadata(final SourceWriter sw) { // private static ValidationGroupsMetadata createValidationGroupsMetadata() { sw.println("private static ValidationGroupsMetadata createValidationGroupsMetadata() {"); sw.indent();/*from www . j ava2 s. c o m*/ // return ValidationGroupsMetadata.builder() sw.println("return ValidationGroupsMetadata.builder()"); sw.indent(); sw.indent(); for (final Class<?> group : this.gwtValidation.groups()) { final GroupSequence sequenceAnnotation = group.getAnnotation(GroupSequence.class); Class<?>[] groups; if (sequenceAnnotation == null) { // .addGroup(<<group>> sw.print(".addGroup("); sw.print(group.getCanonicalName() + ".class"); groups = group.getInterfaces(); } else { // .addSequence(<<sequence>> sw.print(".addSequence("); sw.print(group.getCanonicalName() + ".class"); groups = sequenceAnnotation.value(); } for (final Class<?> clazz : groups) { // , <<group class>> sw.print(", "); sw.print(clazz.getCanonicalName() + ".class"); } // ) sw.println(")"); } // .build(); sw.println(".build();"); sw.outdent(); sw.outdent(); // } sw.outdent(); sw.println("}"); }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
private void writeGetConstraintsForClass(final SourceWriter sw) { // public BeanDescriptor getConstraintsForClass(Class<?> clazz { sw.println("public BeanDescriptor getConstraintsForClass(Class<?> clazz) {"); sw.indent();//from ww w . j a va 2 s . c o m // checkNotNull(clazz, "clazz"); sw.println("checkNotNull(clazz, \"clazz\");"); for (final BeanHelper bean : this.beansToValidate) { this.writeGetConstraintsForClass(sw, bean); } this.writeThrowIllegalArgumnet(sw, "clazz.getName()"); // } sw.outdent(); sw.println("}"); }
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 www . ja va2 s .co 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,//from w ww .java2 s . 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();//w w w. j a v a 2s . c o m // 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 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();/* w w w . ja v a 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) { // public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... // groups) {/*from w w w . j a va 2 s . co m*/ sw.println("public <T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups) {"); sw.indent(); sw.println("checkNotNull(object, \"object\");"); sw.println("checkNotNull(groups, \"groups\");"); sw.println("checkGroups(groups);"); for (final BeanHelper bean : this.beansToValidate) { this.writeValidate(sw, bean); } this.writeThrowIllegalArgumnet(sw, "object.getClass().getName()"); sw.outdent(); sw.println("}"); }