1package com.github.javaparser.ast.validator; 2 3import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; 4import com.github.javaparser.ast.validator.chunks.ModifierValidator; 5 6/** 7 * This validator validates according to Java 7 syntax rules. 8 */ 9public class Java8Validator extends Java7Validator { 10 protected final Validator modifiersWithoutPrivateInterfaceMethods = new ModifierValidator(true, true, false); 11 protected final Validator defaultMethodsInInterface = new SingleNodeTypeValidator<>(ClassOrInterfaceDeclaration.class, 12 (n, reporter) -> { 13 if (n.isInterface()) { 14 n.getMethods().forEach(m -> { 15 if (m.isDefault() && !m.getBody().isPresent()) { 16 reporter.report(m, "'default' methods must have a body."); 17 } 18 }); 19 } 20 } 21 ); 22 23 public Java8Validator() { 24 super(); 25 replace(modifiersWithoutDefaultAndStaticInterfaceMethodsAndPrivateInterfaceMethods, modifiersWithoutPrivateInterfaceMethods); 26 add(defaultMethodsInInterface); 27 remove(noLambdas); 28 29 // TODO validate more annotation locations http://openjdk.java.net/jeps/104 30 // TODO validate repeating annotations http://openjdk.java.net/jeps/120 31 } 32} 33