Home | History | Annotate | Download | only in ast
      1 package com.github.javaparser.ast;
      2 
      3 import com.github.javaparser.JavaParser;
      4 import com.github.javaparser.ParseException;
      5 import com.github.javaparser.ast.CompilationUnit;
      6 
      7 import java.io.ByteArrayInputStream;
      8 import java.io.InputStream;
      9 import java.io.UnsupportedEncodingException;
     10 
     11 /**
     12  * Created by federico on 07/01/16.
     13  */
     14 public class Example {
     15 
     16     public static void main(String[] args) throws UnsupportedEncodingException, ParseException {
     17         String code = "interface A {\n" +
     18                 "    default Comparator<T> thenComparing(Comparator<? super T> other) {\n" +
     19                 "        Objects.requireNonNull(other);\n" +
     20                 "        return (Comparator<T> & Serializable) (c1, c2) -> { // this is the defaulting line\n" +
     21                 "            int res = compare(c1, c2);\n" +
     22                 "            return (res != 0) ? res : other.compare(c1, c2);\n" +
     23                 "        };\n" +
     24                 "    }\n" +
     25                 "}";
     26         InputStream stream = new ByteArrayInputStream(code.getBytes("UTF-8"));
     27         CompilationUnit cu = JavaParser.parse(stream);
     28 
     29     }
     30 
     31 }
     32