public static <T, V> Pair<T, V> make( T f, V s ) { return new Pair<>( f, s ); }
public Type put( TypeVariable tvType, Type type, boolean bReverse ) { Type existing = remove( tvType ); _map.put( tvType, type == null ? null : new Pair<>( type, bReverse ) ); return existing; }
public Type put( TypeVariable tvType, Type type, boolean bReverse ) { Type existing = remove( tvType ); _map.put( tvType, type == null ? null : new Pair<>( type, bReverse ) ); return existing; }
/** * Splits the original collection into pair of lists, * where <i>first</i> list contains elements for which {@code predicate} yielded {@code true}, * while <i>second</i> list contains elements for which {@code predicate} yielded {@code false}. */ public static <T> Pair<List<T>, List<T>> partition( @This Iterable<T> thiz, Predicate<T> predicate ) { ArrayList<T> first = new ArrayList<T>(); ArrayList<T> second = new ArrayList<T>(); for( T element : thiz ) { if( predicate.test( element ) ) { first.add( element ); } else { second.add( element ); } } return new Pair<>( first, second ); }
public void enterElement( XMLParser.ElementContext ctx ) { XmlElement parent = _elements.isEmpty() ? null : _elements.peek().getSecond(); XmlElement xmlElement = new XmlElement( ctx, parent ); if( parent != null ) { parent.addChild( xmlElement ); } _elements.push( new Pair<>( ctx, xmlElement ) ); if( _root == null ) { _root = xmlElement; } }
private Object makeTokensValue( Node keyNode, Node valueNode, Object value ) { Token keyToken = makeToken( keyNode ); if( keyToken != null ) { Token valueToken = makeToken( valueNode ); if( valueToken != null ) { value = new Pair<>( new Token[]{keyToken, valueToken}, value ); } } return value; }
private void parseMember( Bindings map ) { Token keyToken = _token; String key = _token.getString(); check( TokenType.STRING, "a string" ); check( TokenType.COLON, ":" ); Token valueToken = _token; Object val = parseValue(); map.put( key, _withTokens ? new Pair<>( new Token[] {keyToken, valueToken}, val ) : val ); }
@Override public Pair<JavaFileObject, String> findJavaSource( String fqn, DiagnosticListener<JavaFileObject> errorHandler ) { init(); if( _mfm == null ) { // short-circuit reentrancy during init() return null; } JavaFileObject fileObj = _mfm.getSourceFileForInput( StandardLocation.SOURCE_PATH, fqn, JavaFileObject.Kind.SOURCE, errorHandler ); if( fileObj == null ) { int iDot = fqn.lastIndexOf( '.' ); if( iDot > 0 ) { String enclosingFqn = fqn.substring( 0, iDot ); return findJavaSource( enclosingFqn, errorHandler ); } return null; } else { return new Pair<>( fileObj, fqn ); } }
private void addInputFile( TaskEvent e ) { if( !_initialized ) { CompilationUnitTree compilationUnit = e.getCompilationUnit(); ExpressionTree pkg = compilationUnit.getPackageName(); String packageQualifier = pkg == null ? "" : (pkg.toString() + '.'); for( Tree classDecl : compilationUnit.getTypeDecls() ) { if( classDecl instanceof JCTree.JCClassDecl ) { _javaInputFiles.add( new Pair<>( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName(), compilationUnit.getSourceFile() ) ); } } } }
return (index < 0) ? null : new Pair<>( index, string ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString );
return (index < 0) ? null : new Pair<>( index, string ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString ); if( matchingString != null ) return new Pair<>( index, matchingString );
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbol( Context ctx, Object moduleCtx, String fqn ) { Symbol.ClassSymbol typeElement = IDynamicJdk.instance().getTypeElement( ctx, moduleCtx, fqn ); if( typeElement == null ) { // For the case where the class is generated from a type manifold esp. from a IExtensionClassProducer return getClassSymbolForProducedClass( fqn, new BasicJavacTask[1] ); //## want this instead, but the typeElement is not complete in this case, investigate this // if( JavacPlugin.instance() != null ) // { // typeElement = IDynamicJdk.instance().getTypeElement( JavacPlugin.instance().getContext(), moduleCtx, fqn ); // typeElement.complete(); // } } JavacTrees trees = JavacTrees.instance( ctx ); TreePath path = trees.getPath( typeElement ); if( path != null ) { return new Pair<>( typeElement, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( typeElement, null ); } }
private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbolForProducedClass( String fqn, BasicJavacTask[] task ) { StringWriter errors = new StringWriter(); // need javac with ManifoldJavaFileManager because the produced class must come from manifold task[0] = getJavacTask_ManFileMgr(); Symbol.ClassSymbol e = IDynamicJdk.instance().getTypeElement( task[0].getContext(), null, fqn ); if( e != null && e.getSimpleName().contentEquals( ManClassUtil.getShortClassName( fqn ) ) ) { JavacTrees trees = JavacTrees.instance( task[0].getContext() ); TreePath path = trees.getPath( e ); if( path != null ) { return new Pair<>( e, (JCTree.JCCompilationUnit)path.getCompilationUnit() ); } else { // TreePath is only applicable to a source file; // if fqn is not a source file, there is no compilation unit available return new Pair<>( e, null ); } } StringBuffer errorText = errors.getBuffer(); if( errorText.length() > 0 ) { throw new RuntimeException( "Compile errors:\n" + errorText ); } return null; }
if( parent == null && enclosing != null ) JsonSchemaTransformerSession.instance().cacheBaseType( enclosing, new Pair<>( result, this ) );