signature:
public class TypeHelper { /** * see https : / / docs . oracle . com / javase / specs / jls / se8 / html / jls - 5 . html # jls - 5.3
 * @ param s
 * @ param t
 * @ return */
public static boolean isCompatibleInALooseInvocationContext ( ResolvedType s , ResolvedType t ) { } }

implementation:
// Loose invocation contexts allow a more permissive set of conversions , because they are only used for a
// particular invocation if no applicable declaration can be found using strict invocation contexts . Loose
// invocation contexts allow the use of one of the following :
// - an identity conversion ( § 5.1.1)
if ( s . equals ( t ) ) { return true ; } // - a widening primitive conversion ( § 5.1.2)
if ( s . isPrimitive ( ) && t . isPrimitive ( ) && areCompatibleThroughWideningPrimitiveConversion ( s , t ) ) { return true ; } // - a widening reference conversion ( § 5.1.5)
if ( s . isReferenceType ( ) && t . isReferenceType ( ) && areCompatibleThroughWideningReferenceConversion ( s , t ) ) { return true ; } // - a boxing conversion ( § 5.1.7 ) optionally followed by widening reference conversion
if ( s . isPrimitive ( ) && t . isReferenceType ( ) && areCompatibleThroughWideningReferenceConversion ( toBoxedType ( s . asPrimitive ( ) ) , t ) ) { return true ; } // - an unboxing conversion ( § 5.1.8 ) optionally followed by a widening primitive conversion
if ( isUnboxable ( s ) && s . isReferenceType ( ) && t . isPrimitive ( ) && areCompatibleThroughWideningPrimitiveConversion ( toUnboxedType ( s . asReferenceType ( ) ) , t ) ) { return true ; } // If , after the conversions listed for an invocation context have been applied , the resulting type is a raw
// type ( § 4.8 ) , an unchecked conversion ( § 5.1.9 ) may then be applied .
// A value of the null type ( the null reference is the only such value ) may be assigned to any reference type
if ( s . isNull ( ) && t . isReferenceType ( ) ) { return true ; } // throw new UnsupportedOperationException ( " isCompatibleInALooseInvocationContext unable to decide on s = " + s + " , t = " + t ) ;
// TODO FIXME
return t . isAssignableBy ( s ) ;


signature:
public class TypeHelper { /** * See JLS 4.10.4 . Least Upper Bound . */
public static ResolvedType leastUpperBound ( Set < ResolvedType > types ) { } }

implementation:
if ( types . size ( ) == 0 ) { throw new IllegalArgumentException ( ) ; } // The least upper bound , or " lub " , of a set of reference types is a shared supertype that is more specific than
// any other shared supertype ( that is , no other shared supertype is a subtype of the least upper bound ) .
// This type , lub ( U1 , . . . , Uk ) , is determined as follows .
// If k = 1 , then the lub is the type itself : lub ( U ) = U .
if ( types . size ( ) == 1 ) { return types . stream ( ) . findFirst ( ) . get ( ) ; } // Otherwise :
// For each Ui ( 1 ≤ i ≤ k ) :
// Let ST ( Ui ) be the set of supertypes of Ui .
// Let EST ( Ui ) , the set of erased supertypes of Ui , be :
// EST ( Ui ) = { | W | | W in ST ( Ui ) } where | W | is the erasure of W .
// The reason for computing the set of erased supertypes is to deal with situations where the set of types includes several distinct parameterizations of a generic type .
// For example , given List < String > and List < Object > , simply intersecting the sets ST ( List < String > ) = { List < String > , Collection < String > , Object } and ST ( List < Object > ) = { List < Object > , Collection < Object > , Object } would yield a set { Object } , and we would have lost track of the fact that the upper bound can safely be assumed to be a List .
// In contrast , intersecting EST ( List < String > ) = { List , Collection , Object } and EST ( List < Object > ) = { List , Collection , Object } yields { List , Collection , Object } , which will eventually enable us to produce List < ? > .
// Let EC , the erased candidate set for U1 . . . Uk , be the intersection of all the sets EST ( Ui ) ( 1 ≤ i ≤ k ) .
// Let MEC , the minimal erased candidate set for U1 . . . Uk , be :
// MEC = { V | V in EC , and for all W = ̸ V in EC , it is not the case that W < : V }
// Because we are seeking to infer more precise types , we wish to filter out any candidates that are supertypes of other candidates . This is what computing MEC accomplishes . In our running example , we had EC = { List , Collection , Object } , so MEC = { List } . The next step is to recover type arguments for the erased types in MEC .
// For any element G of MEC that is a generic type :
// Let the " relevant " parameterizations of G , Relevant ( G ) , be :
// Relevant ( G ) = { V | 1 ≤ i ≤ k : V in ST ( Ui ) and V = G < . . . > }
// In our running example , the only generic element of MEC is List , and Relevant ( List ) = { List < String > , List < Object > } . We will now seek to find a type argument for List that contains ( § 4.5.1 ) both String and Object .
// This is done by means of the least containing parameterization ( lcp ) operation defined below . The first line defines lcp ( ) on a set , such as Relevant ( List ) , as an operation on a list of the elements of the set . The next line defines the operation on such lists , as a pairwise reduction on the elements of the list . The third line is the definition of lcp ( ) on pairs of parameterized types , which in turn relies on the notion of least containing type argument ( lcta ) . lcta ( ) is defined for all possible cases .
// Let the " candidate " parameterization of G , Candidate ( G ) , be the most specific parameterization of the generic type G that contains all the relevant parameterizations of G :
// Candidate ( G ) = lcp ( Relevant ( G ) )
// where lcp ( ) , the least containing invocation , is :
// lcp ( S ) = lcp ( e1 , . . . , en ) where ei ( 1 ≤ i ≤ n ) in S
// lcp ( e1 , . . . , en ) = lcp ( lcp ( e1 , e2 ) , e3 , . . . , en )
// lcp ( G < X1 , . . . , Xn > , G < Y1 , . . . , Yn > ) = G < lcta ( X1 , Y1 ) , . . . , lcta ( Xn , Yn ) >
// lcp ( G < X1 , . . . , Xn > ) = G < lcta ( X1 ) , . . . , lcta ( Xn ) >
// and where lcta ( ) , the least containing type argument , is : ( assuming U and V are types )
// lcta ( U , V ) = U if U = V , otherwise ? extends lub ( U , V )
// lcta ( U , ? extends V ) = ? extends lub ( U , V )
// lcta ( U , ? super V ) = ? super glb ( U , V )
// lcta ( ? extends U , ? extends V ) = ? extends lub ( U , V )
// lcta ( ? extends U , ? super V ) = U if U = V , otherwise ?
// lcta ( ? super U , ? super V ) = ? super glb ( U , V )
// lcta ( U ) = ? if U ' s upper bound is Object , otherwise ? extends lub ( U , Object )
// and where glb ( ) is as defined in § 5.1.10.
// Let lub ( U1 . . . Uk ) be :
// Best ( W1 ) & . . . & Best ( Wr )
// where Wi ( 1 ≤ i ≤ r ) are the elements of MEC , the minimal erased candidate set of U1 . . . Uk ;
// and where , if any of these elements are generic , we use the candidate parameterization ( so as to recover type arguments ) :
// Best ( X ) = Candidate ( X ) if X is generic ; X otherwise .
// Strictly speaking , this lub ( ) function only approximates a least upper bound . Formally , there may exist some other type T such that all of U1 . . . Uk are subtypes of T and T is a subtype of lub ( U1 , . . . , Uk ) . However , a compiler for the Java programming language must implement lub ( ) as specified above .
// It is possible that the lub ( ) function yields an infinite type . This is permissible , and a compiler for the Java programming language must recognize such situations and represent them appropriately using cyclic data structures .
// The possibility of an infinite type stems from the recursive calls to lub ( ) . Readers familiar with recursive types should note that an infinite type is not the same as a recursive type
throw new UnsupportedOperationException ( ) ;


signature:
public class TypeHelper { /** * See JLS 15.27.3 . Type of a Lambda Expression
 * @ return */
public static Pair < ResolvedType , Boolean > groundTargetTypeOfLambda ( LambdaExpr lambdaExpr , ResolvedType T , TypeSolver typeSolver ) { } }

implementation:
// The ground target type is derived from T as follows :
boolean used18_5_3 = false ; boolean wildcardParameterized = T . asReferenceType ( ) . typeParametersValues ( ) . stream ( ) . anyMatch ( tp -> tp . isWildcard ( ) ) ; if ( wildcardParameterized ) { // - If T is a wildcard - parameterized functional interface type and the lambda expression is explicitly typed ,
// then the ground target type is inferred as described in § 18.5.3.
if ( ExpressionHelper . isExplicitlyTyped ( lambdaExpr ) ) { used18_5_3 = true ; throw new UnsupportedOperationException ( ) ; } // - If T is a wildcard - parameterized functional interface type and the lambda expression is implicitly typed ,
// then the ground target type is the non - wildcard parameterization ( § 9.9 ) of T .
else { return new Pair < > ( nonWildcardParameterizationOf ( T . asReferenceType ( ) , typeSolver ) , used18_5_3 ) ; } } // - Otherwise , the ground target type is T .
return new Pair < > ( T , used18_5_3 ) ;


signature:
public class TypeHelper { /** * See JLS 9.9 */
private static ResolvedReferenceType nonWildcardParameterizationOf ( ResolvedReferenceType originalType , TypeSolver typeSolver ) { } }

implementation:
List < ResolvedType > TIs = new LinkedList < > ( ) ; List < ResolvedType > AIs = originalType . typeParametersValues ( ) ; List < ResolvedTypeParameterDeclaration > TPs = originalType . getTypeDeclaration ( ) . getTypeParameters ( ) ; // Let P1 . . . Pn be the type parameters of I with corresponding bounds B1 . . . Bn . For all i ( 1 ≤ i ≤ n ) ,
// Ti is derived according to the form of Ai :
ResolvedReferenceType object = new ReferenceTypeImpl ( typeSolver . solveType ( Object . class . getCanonicalName ( ) ) , typeSolver ) ; for ( int i = 0 ; i < AIs . size ( ) ; i ++ ) { ResolvedType Ai = AIs . get ( i ) ; ResolvedType Ti = null ; // - If Ai is a type , then Ti = Ai .
if ( ! Ai . isWildcard ( ) ) { Ti = Ai ; } // - If Ai is a wildcard , and the corresponding type parameter ' s bound , Bi , mentions one of P1 . . . Pn , then
// Ti is undefined and there is no function type .
if ( Ti == null && Ai . isWildcard ( ) && Ai . asWildcard ( ) . mention ( originalType . getTypeDeclaration ( ) . getTypeParameters ( ) ) ) { throw new IllegalArgumentException ( ) ; } // - Otherwise :
if ( Ti == null ) { ResolvedType Bi = TPs . get ( i ) . hasLowerBound ( ) ? TPs . get ( i ) . getLowerBound ( ) : object ; // - If Ai is an unbound wildcard ? , then Ti = Bi .
if ( Ai . isWildcard ( ) && ! Ai . asWildcard ( ) . isBounded ( ) ) { Ti = Bi ; } // - If Ai is a upper - bounded wildcard ? extends Ui , then Ti = glb ( Ui , Bi ) ( § 5.1.10 ) .
else if ( Ai . isWildcard ( ) && Ai . asWildcard ( ) . isUpperBounded ( ) ) { ResolvedType Ui = Ai . asWildcard ( ) . getBoundedType ( ) ; Ti = glb ( new HashSet < > ( Arrays . asList ( Ui , Bi ) ) ) ; } // - If Ai is a lower - bounded wildcard ? super Li , then Ti = Li .
else if ( Ai . isWildcard ( ) && Ai . asWildcard ( ) . isLowerBounded ( ) ) { Ti = Ai . asWildcard ( ) . getBoundedType ( ) ; } else throw new RuntimeException ( "This should not happen" ) ; } TIs . add ( Ti ) ; } return new ReferenceTypeImpl ( originalType . getTypeDeclaration ( ) , TIs , typeSolver ) ;


signature:
public class TypeHelper { /** * See JLS 5.1.10 . Capture Conversion . */
public static ResolvedType glb ( Set < ResolvedType > types ) { } }

implementation: if ( types . size ( ) == 0 ) { throw new IllegalArgumentException ( ) ; } if ( types . size ( ) == 1 ) { return types . iterator ( ) . next ( ) ; } return new ResolvedIntersectionType ( types ) ;


signature:
public class TypeExtractor { /** * Java Parser can ' t differentiate between packages , internal types , and fields .
 * All three are lumped together into FieldAccessExpr . We need to differentiate them . */
private ResolvedType solveDotExpressionType ( ResolvedReferenceTypeDeclaration parentType , FieldAccessExpr node ) { } }

implementation:
// Fields and internal type declarations cannot have the same name .
// Thus , these checks will always be mutually exclusive .
if ( parentType . hasField ( node . getName ( ) . getId ( ) ) ) { return parentType . getField ( node . getName ( ) . getId ( ) ) . getType ( ) ; } else if ( parentType . hasInternalType ( node . getName ( ) . getId ( ) ) ) { return new ReferenceTypeImpl ( parentType . getInternalType ( node . getName ( ) . getId ( ) ) , typeSolver ) ; } else { throw new UnsolvedSymbolException ( node . getName ( ) . getId ( ) ) ; }


signature: public class LambdaExprContext { protected final Optional < Value > solveWithAsValue ( SymbolDeclarator symbolDeclarator , String name , TypeSolver typeSolver ) { } }

implementation: for ( ResolvedValueDeclaration decl : symbolDeclarator . getSymbolDeclarations ( ) ) { if ( decl . getName ( ) . equals ( name ) ) { throw new UnsupportedOperationException ( ) ; } } return Optional . empty ( ) ;


signature: public class LambdaExprContext { private int pos ( MethodCallExpr callExpr , Expression param ) { } }

implementation: int i = 0 ; for ( Expression p : callExpr . getArguments ( ) ) { if ( p == param ) { return i ; } i ++ ; } throw new IllegalArgumentException ( ) ;


signature:
public class JavaParserFacade { /** * Given a constructor call find out to which constructor declaration it corresponds . */
public SymbolReference < ResolvedConstructorDeclaration > solve ( ObjectCreationExpr objectCreationExpr , boolean solveLambdas ) { } }

implementation: List < ResolvedType > argumentTypes = new LinkedList < > ( ) ; List < LambdaArgumentTypePlaceholder > placeholders = new LinkedList < > ( ) ; solveArguments ( objectCreationExpr , objectCreationExpr . getArguments ( ) , solveLambdas , argumentTypes , placeholders ) ; ResolvedType classDecl = JavaParserFacade . get ( typeSolver ) . convert ( objectCreationExpr . getType ( ) , objectCreationExpr ) ; if ( ! classDecl . isReferenceType ( ) ) { return SymbolReference . unsolved ( ResolvedConstructorDeclaration . class ) ; } SymbolReference < ResolvedConstructorDeclaration > res = ConstructorResolutionLogic . findMostApplicable ( ( ( ResolvedClassDeclaration ) classDecl . asReferenceType ( ) . getTypeDeclaration ( ) ) . getConstructors ( ) , argumentTypes , typeSolver ) ; for ( LambdaArgumentTypePlaceholder placeholder : placeholders ) { placeholder . setMethod ( res ) ; } return res ;


signature:
public class JavaParserFacade { /** * Given a method call find out to which method declaration it corresponds . */
public SymbolReference < ResolvedMethodDeclaration > solve ( MethodCallExpr methodCallExpr , boolean solveLambdas ) { } }

implementation: List < ResolvedType > argumentTypes = new LinkedList < > ( ) ; List < LambdaArgumentTypePlaceholder > placeholders = new LinkedList < > ( ) ; solveArguments ( methodCallExpr , methodCallExpr . getArguments ( ) , solveLambdas , argumentTypes , placeholders ) ; SymbolReference < ResolvedMethodDeclaration > res = JavaParserFactory . getContext ( methodCallExpr , typeSolver ) . solveMethod ( methodCallExpr . getName ( ) . getId ( ) , argumentTypes , false , typeSolver ) ; for ( LambdaArgumentTypePlaceholder placeholder : placeholders ) { placeholder . setMethod ( res ) ; } return res ;


signature:
public class JavaParserFacade { /** * For some reasons LambdaExprs are duplicate and the equals method is not implemented correctly .
 * @ param map
 * @ return */
private Optional < ResolvedType > find ( Map < Node , ResolvedType > map , LambdaExpr lambdaExpr ) { } }

implementation: for ( Node key : map . keySet ( ) ) { if ( key instanceof LambdaExpr ) { LambdaExpr keyLambdaExpr = ( LambdaExpr ) key ; if ( keyLambdaExpr . toString ( ) . equals ( lambdaExpr . toString ( ) ) && getParentNode ( keyLambdaExpr ) == getParentNode ( lambdaExpr ) ) { return Optional . of ( map . get ( keyLambdaExpr ) ) ; } } } return Optional . empty ( ) ;


signature:
public class JavaParserFacade { /** * Should return more like a TypeApplication : a TypeDeclaration and possible typeParametersValues or array
 * modifiers .
 * @ return */
private ResolvedType getTypeConcrete ( Node node , boolean solveLambdas ) { } }

implementation: if ( node == null ) throw new IllegalArgumentException ( ) ; return node . accept ( typeExtractor , solveLambdas ) ;


signature:
public class JavaParserFacade { /** * This is an hack around an issue in JavaParser */
private String qName ( ClassOrInterfaceType classOrInterfaceType ) { } }

implementation: String name = classOrInterfaceType . getName ( ) . getId ( ) ; if ( classOrInterfaceType . getScope ( ) . isPresent ( ) ) { return qName ( classOrInterfaceType . getScope ( ) . get ( ) ) + "." + name ; } else { return name ; }


signature:
public class JavaParserFacade { /** * " this " inserted in the given point , which type would have ? */
public ResolvedType getTypeOfThisIn ( Node node ) { } }

implementation:
// TODO consider static methods
if ( node instanceof ClassOrInterfaceDeclaration ) { return new ReferenceTypeImpl ( getTypeDeclaration ( ( ClassOrInterfaceDeclaration ) node ) , typeSolver ) ; } else if ( node instanceof EnumDeclaration ) { JavaParserEnumDeclaration enumDeclaration = new JavaParserEnumDeclaration ( ( EnumDeclaration ) node , typeSolver ) ; return new ReferenceTypeImpl ( enumDeclaration , typeSolver ) ; } else if ( node instanceof ObjectCreationExpr && ( ( ObjectCreationExpr ) node ) . getAnonymousClassBody ( ) . isPresent ( ) ) { JavaParserAnonymousClassDeclaration anonymousDeclaration = new JavaParserAnonymousClassDeclaration ( ( ObjectCreationExpr ) node , typeSolver ) ; return new ReferenceTypeImpl ( anonymousDeclaration , typeSolver ) ; } else { return getTypeOfThisIn ( getParentNode ( node ) ) ; }


signature: public class MethodCallExprContext { @ Override public Optional < ResolvedType > solveGenericType ( String name , TypeSolver typeSolver ) { } }

implementation: if ( wrappedNode . getScope ( ) . isPresent ( ) ) { ResolvedType typeOfScope = JavaParserFacade . get ( typeSolver ) . getType ( wrappedNode . getScope ( ) . get ( ) ) ; Optional < ResolvedType > res = typeOfScope . asReferenceType ( ) . getGenericParameterByName ( name ) ; return res ; } else { return Optional . empty ( ) ; }


signature: public class MethodCallExprContext { private Optional < MethodUsage > solveMethodAsUsage ( ResolvedReferenceType refType , String name , List < ResolvedType > argumentsTypes , TypeSolver typeSolver , Context invokationContext ) { } }

implementation:
Optional < MethodUsage > ref = ContextHelper . solveMethodAsUsage ( refType . getTypeDeclaration ( ) , name , argumentsTypes , typeSolver , invokationContext , refType . typeParametersValues ( ) ) ; if ( ref . isPresent ( ) ) { MethodUsage methodUsage = ref . get ( ) ; methodUsage = resolveMethodTypeParametersFromExplicitList ( typeSolver , methodUsage ) ; // At this stage I should derive from the context and the value some information on the type parameters
// for example , when calling :
// myStream . collect ( Collectors . toList ( ) )
// I should be able to figure out that considering the type of the stream ( e . g . , Stream < String > )
// and considering that Stream has this method :
// < R , A > R collect ( Collector < ? super T , A , R > collector )
// and collector has this method :
// static < T > Collector < T , ? , List < T > > toList ( )
// In this case collect . R has to be equal to List < toList . T >
// And toList . T has to be equal to ? super Stream . T
// Therefore R has to be equal to List < ? super Stream . T > .
// In our example Stream . T equal to String , so the R ( and the result of the call to collect ) is
// List < ? super String >
Map < ResolvedTypeParameterDeclaration , ResolvedType > derivedValues = new HashMap < > ( ) ; for ( int i = 0 ; i < methodUsage . getParamTypes ( ) . size ( ) ; i ++ ) { ResolvedParameterDeclaration parameter = methodUsage . getDeclaration ( ) . getParam ( i ) ; ResolvedType parameterType = parameter . getType ( ) ; if ( parameter . isVariadic ( ) ) { parameterType = parameterType . asArrayType ( ) . getComponentType ( ) ; } inferTypes ( argumentsTypes . get ( i ) , parameterType , derivedValues ) ; } for ( Map . Entry < ResolvedTypeParameterDeclaration , ResolvedType > entry : derivedValues . entrySet ( ) ) { methodUsage = methodUsage . replaceTypeParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } ResolvedType returnType = refType . useThisTypeParametersOnTheGivenType ( methodUsage . returnType ( ) ) ; if ( returnType != methodUsage . returnType ( ) ) { methodUsage = methodUsage . replaceReturnType ( returnType ) ; } for ( int i = 0 ; i < methodUsage . getParamTypes ( ) . size ( ) ; i ++ ) { ResolvedType replaced = refType . useThisTypeParametersOnTheGivenType ( methodUsage . getParamTypes ( ) . get ( i ) ) ; methodUsage = methodUsage . replaceParamType ( i , replaced ) ; } return Optional . of ( methodUsage ) ; } else { return ref ; }


signature:
public class ControlFlowLogic { /** * A reachable break statement exits a statement if , within the break target , either there are no try statements
 * whose try blocks contain the break statement , or there are try statements whose try blocks contain the break
 * statement and all finally clauses of those try statements can complete normally . */
public boolean exitTheStatement ( BreakStmt breakStmt ) { } }

implementation: if ( ! isReachable ( breakStmt ) ) { return false ; } Statement breakTarget = breakTarget ( breakStmt ) ; for ( TryStmt tryStmt : containedTryStmts ( breakTarget ) ) { if ( contains ( tryStmt . getTryBlock ( ) , breakStmt ) ) { if ( ! tryStmt . getFinallyBlock ( ) . isPresent ( ) && ! canCompleteNormally ( tryStmt . getFinallyBlock ( ) . get ( ) ) ) { return false ; } } } return true ;


signature:
public class ControlFlowLogic { /** * See JLS 14.21 */
public boolean canCompleteNormally ( Statement statement ) { } }

implementation:
if ( ! isReachable ( statement ) ) { return false ; } GenericVisitor < Boolean , Void > visitor = new GenericVisitorAdapter < Boolean , Void > ( ) { @ Override public Boolean visit ( BlockStmt n , Void arg ) { // An empty block that is not a switch block can complete normally iff it is reachable
if ( n . isEmpty ( ) && ! parentIs ( statement , SwitchStmt . class ) ) { return isReachable ( statement ) ; } // A non - empty block that is not a switch block can complete normally iff the last statement in
// it can complete normally .
if ( ! n . isEmpty ( ) && ! parentIs ( statement , SwitchStmt . class ) ) { return canCompleteNormally ( n . getStatement ( n . getStatements ( ) . size ( ) - 1 ) ) ; } throw new UnsupportedOperationException ( ) ; } @ Override public Boolean visit ( LabeledStmt n , Void arg ) { // A labeled statement can complete normally if at least one of the following is true :
// – The contained statement can complete normally .
// – There is a reachable break statement that exits the labeled statement .
throw new UnsupportedOperationException ( ) ; } @ Override public Boolean visit ( EmptyStmt n , Void arg ) { // An empty statement can complete normally iff it is reachable .
return isReachable ( n ) ; } @ Override public Boolean visit ( LocalClassDeclarationStmt n , Void arg ) { // A local class declaration statement can complete normally iff it is reachable .
return isReachable ( n ) ; } @ Override public Boolean visit ( IfStmt n , Void arg ) { if ( n . getElseStmt ( ) . isPresent ( ) ) { // An if - then - else statement can complete normally iff the then - statement can
// complete normally or the else - statement can complete normally .
return canCompleteNormally ( n . getThenStmt ( ) ) || canCompleteNormally ( n . getElseStmt ( ) . get ( ) ) ; } else { // An if - then statement can complete normally iff it is reachable .
return isReachable ( n ) ; } } @ Override public Boolean visit ( AssertStmt n , Void arg ) { // An assert statement can complete normally iff it is reachable .
return isReachable ( n ) ; } @ Override public Boolean visit ( ExpressionStmt n , Void arg ) { // A local variable declaration statement can complete normally iff it is reachable .
if ( n . getExpression ( ) instanceof VariableDeclarationExpr ) { VariableDeclarationExpr expr = ( VariableDeclarationExpr ) n . getExpression ( ) ; return isReachable ( n ) ; } // An expression statement can complete normally iff it is reachable .
return isReachable ( n ) ; } } ; return statement . accept ( visitor , null ) ;


signature: public class JavaParserClassDeclaration { @ Override public List < ResolvedFieldDeclaration > getAllFields ( ) { } }

implementation: List < ResolvedFieldDeclaration > fields = javaParserTypeAdapter . getFieldsForDeclaredVariables ( ) ; getAncestors ( ) . forEach ( ancestor -> ancestor . getTypeDeclaration ( ) . getAllFields ( ) . forEach ( f -> { fields . add ( new ResolvedFieldDeclaration ( ) { @ Override public AccessSpecifier accessSpecifier ( ) { return f . accessSpecifier ( ) ; } @ Override public String getName ( ) { return f . getName ( ) ; } @ Override public ResolvedType getType ( ) { return ancestor . useThisTypeParametersOnTheGivenType ( f . getType ( ) ) ; } @ Override public boolean isStatic ( ) { return f . isStatic ( ) ; } @ Override public ResolvedTypeDeclaration declaringType ( ) { return f . declaringType ( ) ; } } ) ; } ) ) ; return fields ;


signature: public class JavaParserClassDeclaration { private ResolvedReferenceType toReferenceType ( ClassOrInterfaceType classOrInterfaceType ) { } }

implementation:
String className = classOrInterfaceType . getName ( ) . getId ( ) ; if ( classOrInterfaceType . getScope ( ) . isPresent ( ) ) { // look for the qualified name ( for example class of type Rectangle2D . Double )
className = classOrInterfaceType . getScope ( ) . get ( ) . toString ( ) + "." + className ; } SymbolReference < ResolvedTypeDeclaration > ref = solveType ( className , typeSolver ) ; if ( ! ref . isSolved ( ) ) { Optional < ClassOrInterfaceType > localScope = classOrInterfaceType . getScope ( ) ; if ( localScope . isPresent ( ) ) { String localName = localScope . get ( ) . getName ( ) . getId ( ) + "." + classOrInterfaceType . getName ( ) . getId ( ) ; ref = solveType ( localName , typeSolver ) ; } } if ( ! ref . isSolved ( ) ) { throw new UnsolvedSymbolException ( classOrInterfaceType . getName ( ) . getId ( ) ) ; } if ( ! classOrInterfaceType . getTypeArguments ( ) . isPresent ( ) ) { return new ReferenceTypeImpl ( ref . getCorrespondingDeclaration ( ) . asReferenceType ( ) , typeSolver ) ; } List < ResolvedType > superClassTypeParameters = classOrInterfaceType . getTypeArguments ( ) . get ( ) . stream ( ) . map ( ta -> new LazyType ( v -> JavaParserFacade . get ( typeSolver ) . convert ( ta , ta ) ) ) . collect ( Collectors . toList ( ) ) ; return new ReferenceTypeImpl ( ref . getCorrespondingDeclaration ( ) . asReferenceType ( ) , superClassTypeParameters , typeSolver ) ;


signature:
public class FunctionalInterfaceLogic { /** * Get the functional method defined by the type , if any . */
public static Optional < MethodUsage > getFunctionalMethod ( ResolvedType type ) { } }

implementation: if ( type . isReferenceType ( ) && type . asReferenceType ( ) . getTypeDeclaration ( ) . isInterface ( ) ) { return getFunctionalMethod ( type . asReferenceType ( ) . getTypeDeclaration ( ) ) ; } else { return Optional . empty ( ) ; }


signature:
public class FunctionalInterfaceLogic { /** * Get the functional method defined by the type , if any . */
public static Optional < MethodUsage > getFunctionalMethod ( ResolvedReferenceTypeDeclaration typeDeclaration ) { } }

implementation:
// We need to find all abstract methods
Set < MethodUsage > methods = typeDeclaration . getAllMethods ( ) . stream ( ) . filter ( m -> m . getDeclaration ( ) . isAbstract ( ) ) // Remove methods inherited by Object :
// Consider the case of Comparator which define equals . It would be considered a functional method .
. filter ( m -> ! declaredOnObject ( m ) ) . collect ( Collectors . toSet ( ) ) ; if ( methods . size ( ) == 1 ) { return Optional . of ( methods . iterator ( ) . next ( ) ) ; } else { return Optional . empty ( ) ; }


signature: public class CompilationUnitContext { @ Override public SymbolReference < ? extends ResolvedValueDeclaration > solveSymbol ( String name , TypeSolver typeSolver ) { } }

implementation:
// solve absolute references
String itName = name ; while ( itName . contains ( "." ) ) { String typeName = getType ( itName ) ; String memberName = getMember ( itName ) ; SymbolReference < ResolvedTypeDeclaration > type = this . solveType ( typeName , typeSolver ) ; if ( type . isSolved ( ) ) { return new SymbolSolver ( typeSolver ) . solveSymbolInType ( type . getCorrespondingDeclaration ( ) , memberName ) ; } else { itName = typeName ; } } // Look among statically imported values
if ( wrappedNode . getImports ( ) != null ) { for ( ImportDeclaration importDecl : wrappedNode . getImports ( ) ) { if ( importDecl . isStatic ( ) ) { if ( importDecl . isAsterisk ( ) ) { String qName = importDecl . getNameAsString ( ) ; ResolvedTypeDeclaration importedType = typeSolver . solveType ( qName ) ; SymbolReference < ? extends ResolvedValueDeclaration > ref = new SymbolSolver ( typeSolver ) . solveSymbolInType ( importedType , name ) ; if ( ref . isSolved ( ) ) { return ref ; } } else { String whole = importDecl . getNameAsString ( ) ; // split in field / method name and type name
String memberName = getMember ( whole ) ; String typeName = getType ( whole ) ; if ( memberName . equals ( name ) ) { ResolvedTypeDeclaration importedType = typeSolver . solveType ( typeName ) ; return new SymbolSolver ( typeSolver ) . solveSymbolInType ( importedType , memberName ) ; } } } } } return SymbolReference . unsolved ( ResolvedValueDeclaration . class ) ;


signature: public class CompilationUnitContext { private String getType ( String qName ) { } }

implementation: int index = qName . lastIndexOf ( '.' ) ; if ( index == - 1 ) { throw new UnsupportedOperationException ( ) ; } String typeName = qName . substring ( 0 , index ) ; return typeName ;


signature:
public class SymbolSolver { /** * Solve any possible visible symbols including : fields , internal types , type variables , the type itself or its
 * containers .
 * It should contain its own private fields but not inherited private fields . */
public SymbolReference < ? extends ResolvedValueDeclaration > solveSymbolInType ( ResolvedTypeDeclaration typeDeclaration , String name ) { } }

implementation: if ( typeDeclaration instanceof JavaParserClassDeclaration ) { Context ctx = ( ( JavaParserClassDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserInterfaceDeclaration ) { Context ctx = ( ( JavaParserInterfaceDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserEnumDeclaration ) { Context ctx = ( ( JavaParserEnumDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof ReflectionClassDeclaration ) { return ( ( ReflectionClassDeclaration ) typeDeclaration ) . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof ReflectionInterfaceDeclaration ) { return ( ( ReflectionInterfaceDeclaration ) typeDeclaration ) . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavassistClassDeclaration ) { return ( ( JavassistClassDeclaration ) typeDeclaration ) . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavassistEnumDeclaration ) { return ( ( JavassistEnumDeclaration ) typeDeclaration ) . solveSymbol ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavassistInterfaceDeclaration ) { return ( ( JavassistInterfaceDeclaration ) typeDeclaration ) . solveSymbol ( name , typeSolver ) ; } return SymbolReference . unsolved ( ResolvedValueDeclaration . class ) ;


signature:
public class SymbolSolver { /** * Try to solve a symbol just in the declaration , it does not delegate to the container . */
@ Deprecated public SymbolReference < ResolvedTypeDeclaration > solveTypeInType ( ResolvedTypeDeclaration typeDeclaration , String name ) { } }

implementation: if ( typeDeclaration instanceof JavaParserClassDeclaration ) { return ( ( JavaParserClassDeclaration ) typeDeclaration ) . solveType ( name , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserInterfaceDeclaration ) { return ( ( JavaParserInterfaceDeclaration ) typeDeclaration ) . solveType ( name , typeSolver ) ; } return SymbolReference . unsolved ( ResolvedReferenceTypeDeclaration . class ) ;


signature: public class JavaParserInterfaceDeclaration { private ResolvedReferenceType toReferenceType ( ClassOrInterfaceType classOrInterfaceType ) { } }

implementation: SymbolReference < ? extends ResolvedTypeDeclaration > ref = null ; if ( classOrInterfaceType . toString ( ) . indexOf ( '.' ) > - 1 ) { ref = typeSolver . tryToSolveType ( classOrInterfaceType . toString ( ) ) ; } if ( ref == null || ! ref . isSolved ( ) ) { ref = solveType ( classOrInterfaceType . toString ( ) , typeSolver ) ; } if ( ! ref . isSolved ( ) ) { ref = solveType ( classOrInterfaceType . getName ( ) . getId ( ) , typeSolver ) ; } if ( ! ref . isSolved ( ) ) { throw new UnsolvedSymbolException ( classOrInterfaceType . getName ( ) . getId ( ) ) ; } if ( ! classOrInterfaceType . getTypeArguments ( ) . isPresent ( ) ) { return new ReferenceTypeImpl ( ref . getCorrespondingDeclaration ( ) . asReferenceType ( ) , typeSolver ) ; } List < ResolvedType > superClassTypeParameters = classOrInterfaceType . getTypeArguments ( ) . get ( ) . stream ( ) . map ( ta -> new LazyType ( v -> JavaParserFacade . get ( typeSolver ) . convert ( ta , ta ) ) ) . collect ( Collectors . toList ( ) ) ; return new ReferenceTypeImpl ( ref . getCorrespondingDeclaration ( ) . asReferenceType ( ) , superClassTypeParameters , typeSolver ) ;


signature:
public class MethodResolutionLogic { /** * Replace TypeDeclaration . solveMethod
 * @ param typeDeclaration
 * @ param name
 * @ param argumentsTypes
 * @ param staticOnly
 * @ return */
public static SymbolReference < ResolvedMethodDeclaration > solveMethodInType ( ResolvedTypeDeclaration typeDeclaration , String name , List < ResolvedType > argumentsTypes , boolean staticOnly , TypeSolver typeSolver ) { } }

implementation: if ( typeDeclaration instanceof JavaParserClassDeclaration ) { Context ctx = ( ( JavaParserClassDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveMethod ( name , argumentsTypes , staticOnly , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserInterfaceDeclaration ) { Context ctx = ( ( JavaParserInterfaceDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveMethod ( name , argumentsTypes , staticOnly , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserEnumDeclaration ) { if ( name . equals ( "values" ) && argumentsTypes . isEmpty ( ) ) { return SymbolReference . solved ( new JavaParserEnumDeclaration . ValuesMethod ( ( JavaParserEnumDeclaration ) typeDeclaration , typeSolver ) ) ; } Context ctx = ( ( JavaParserEnumDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveMethod ( name , argumentsTypes , staticOnly , typeSolver ) ; } if ( typeDeclaration instanceof JavaParserAnonymousClassDeclaration ) { Context ctx = ( ( JavaParserAnonymousClassDeclaration ) typeDeclaration ) . getContext ( ) ; return ctx . solveMethod ( name , argumentsTypes , staticOnly , typeSolver ) ; } if ( typeDeclaration instanceof ReflectionClassDeclaration ) { return ( ( ReflectionClassDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } if ( typeDeclaration instanceof ReflectionInterfaceDeclaration ) { return ( ( ReflectionInterfaceDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } if ( typeDeclaration instanceof ReflectionEnumDeclaration ) { return ( ( ReflectionEnumDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } if ( typeDeclaration instanceof JavassistInterfaceDeclaration ) { return ( ( JavassistInterfaceDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } if ( typeDeclaration instanceof JavassistClassDeclaration ) { return ( ( JavassistClassDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } if ( typeDeclaration instanceof JavassistEnumDeclaration ) { return ( ( JavassistEnumDeclaration ) typeDeclaration ) . solveMethod ( name , argumentsTypes , staticOnly ) ; } throw new UnsupportedOperationException ( typeDeclaration . getClass ( ) . getCanonicalName ( ) ) ;


signature:
public class Value { /** * Create a Value from a ValueDeclaration . */
public static Value from ( ResolvedValueDeclaration decl ) { } }

implementation: ResolvedType type = decl . getType ( ) ; return new Value ( type , decl . getName ( ) ) ;


signature: public class TypeInference { public static MethodUsage toMethodUsage ( MethodCallExpr call , ResolvedMethodDeclaration methodDeclaration , TypeSolver typeSolver ) { } }

implementation: TypeInference typeInference = new TypeInference ( typeSolver ) ; Optional < InstantiationSet > instantiationSetOpt = typeInference . instantiationInference ( call , methodDeclaration ) ; if ( instantiationSetOpt . isPresent ( ) ) { return instantiationSetToMethodUsage ( methodDeclaration , instantiationSetOpt . get ( ) ) ; } else { throw new IllegalArgumentException ( ) ; }


signature: public class TypeInference { public Optional < InstantiationSet > instantiationInference ( MethodCallExpr methodCallExpr , ResolvedMethodDeclaration methodDeclaration ) { } }

implementation: return instantiationInference ( methodCallExpr . getArguments ( ) , methodDeclaration ) ;


signature:
public class TypeInference { /** * Determine whether a potentially applicable generic method m is applicable for a method invocation that
 * provides no explicit type arguments . */
public boolean invocationApplicabilityInference ( MethodCallExpr methodCallExpr , ResolvedMethodDeclaration methodDeclaration ) { } }

implementation:
if ( ! methodCallExpr . getNameAsString ( ) . equals ( methodDeclaration . getName ( ) ) ) { throw new IllegalArgumentException ( ) ; } Optional < InstantiationSet > partial = instantiationInference ( methodCallExpr , methodDeclaration ) ; if ( ! partial . isPresent ( ) ) { return false ; } int nActualParams = methodCallExpr . getArguments ( ) . size ( ) ; int nFormalParams = methodDeclaration . getNumberOfParams ( ) ; if ( nActualParams != nFormalParams ) { if ( methodDeclaration . hasVariadicParameter ( ) ) { if ( nActualParams < ( nFormalParams - 1 ) ) { return false ; } } else { return false ; } } // MethodUsage methodUsage = instantiationSetToMethodUsage ( methodDeclaration , partial . get ( ) ) ;
// for ( int i = 0 ; i < nActualParams ; i + + ) {
// int formalIndex = i > = nFormalParams ? nFormalParams - 1 : i ;
// Type formalType = methodDeclaration . getParam ( formalIndex ) . getType ( ) ;
// Type actualType = JavaParserFacade . get ( typeSolver ) . getType ( methodCallExpr . getArgument ( i ) ) ;
// / / if ( ! formalType . isAssignableBy ( actualType ) ) {
// / / return false ;
return true ;


signature:
public class TypeInference { /** * Return if m2 is more specific than m1
 * @ param methodCall
 * @ param m1
 * @ param m2 */
public boolean moreSpecificMethodInference ( MethodCallExpr methodCall , ResolvedMethodDeclaration m1 , ResolvedMethodDeclaration m2 ) { } }

implementation:
// When testing that one applicable method is more specific than another ( § 15.12.2.5 ) , where the second method
// is generic , it is necessary to test whether some instantiation of the second method ' s type parameters can be
// inferred to make the first method more specific than the second .
if ( ! m2 . isGeneric ( ) ) { throw new IllegalArgumentException ( "M2 is not generic (m2: " + m2 + ")" ) ; } // Let m1 be the first method and m2 be the second method . Where m2 has type parameters P1 , . . . , Pp ,
// let α1 , . . . , αp be inference variables , and let θ be the substitution [ P1 : = α1 , . . . , Pp : = αp ] .
// Let e1 , . . . , ek be the argument expressions of the corresponding invocation . Then :
// - If m1 and m2 are applicable by strict or loose invocation ( § 15.12.2.2 , § 15.12.2.3 ) , then let S1 , . . . , Sk be the formal parameter types of m1 , and let T1 , . . . , Tk be the result of θ applied to the formal parameter types of m2.
// - If m1 and m2 are applicable by variable arity invocation ( § 15.12.2.4 ) , then let S1 , . . . , Sk be the first k variable arity parameter types of m1 , and let T1 , . . . , Tk be the result of θ applied to the first k variable arity parameter types of m2.
// Note that no substitution is applied to S1 , . . . , Sk ; even if m1 is generic , the type parameters of m1 are treated as type variables , not inference variables .
// The process to determine if m1 is more specific than m2 is as follows :
// - First , an initial bound set , B , is constructed from the declared bounds of P1 , . . . , Pp , as specified in § 18.1.3.
// - Second , for all i ( 1 ≤ i ≤ k ) , a set of constraint formulas or bounds is generated .
// If Ti is a proper type , the result is true if Si is more specific than Ti for ei ( § 15.12.2.5 ) , and false otherwise . ( Note that Si is always a proper type . )
// Otherwise , if Ti is not a functional interface type , the constraint formula ‹ Si < : Ti › is generated .
// Otherwise , Ti is a parameterization of a functional interface , I . It must be determined whether Si satisfies the following five conditions :
// 1 . Si is a functional interface type .
// 2 . Si is not a superinterface of I , nor a parameterization of a superinterface of I .
// 3 . Si is not a subinterface of I , nor a parameterization of a subinterface of I .
// 4 . If Si is an intersection type , at least one element of the intersection is not a superinterface of I , nor a parameterization of a superinterface of I .
// 5 . If Si is an intersection type , no element of the intersection is a subinterface of I , nor a parameterization of a subinterface of I .
// If all five conditions are true , then the following constraint formulas or bounds are generated ( where U1 . . . Uk and R1 are the parameter types and return type of the function type of the capture of Si , and V1 . . . Vk and R2 are the parameter types and return type of the function type of Ti ) :
// - If ei is an explicitly typed lambda expression :
// - For all j ( 1 ≤ j ≤ k ) , ‹ Uj = Vj › .
// - If R2 is void , true .
// - Otherwise , if R1 and R2 are functional interface types , and neither interface is a subinterface of the other , and ei has at least one result expression , then these rules are applied recursively to R1 and R2 , for each result expression in ei .
// - Otherwise , if R1 is a primitive type and R2 is not , and ei has at least one result expression , and each result expression of ei is a standalone expression ( § 15.2 ) of a primitive type , true .
// - Otherwise , if R2 is a primitive type and R1 is not , and ei has at least one result expression , and each result expression of ei is either a standalone expression of a reference type or a poly expression , true .
// - Otherwise , ‹ R1 < : R2 › .
// - If ei is an exact method reference :
// - For all j ( 1 ≤ j ≤ k ) , ‹ Uj = Vj › .
// - If R2 is void , true .
// - Otherwise , if R1 is a primitive type and R2 is not , and the compile - time declaration for ei has a primitive return type , true .
// - Otherwise if R2 is a primitive type and R1 is not , and the compile - time declaration for ei has a reference return type , true .
// - Otherwise , ‹ R1 < : R2 › .
// - If ei is a parenthesized expression , these rules are applied recursively to the contained expression .
// - If ei is a conditional expression , these rules are applied recursively to each of the second and third operands .
// - Otherwise , false .
// If the five constraints on Si are not satisfied , the constraint formula ‹ Si < : Ti › is generated instead .
// - Third , if m2 is applicable by variable arity invocation and has k + 1 parameters , then where Sk + 1 is the k + 1 ' th variable arity parameter type of m1 and Tk + 1 is the result of θ applied to the k + 1 ' th variable arity parameter type of m2 , the constraint ‹ Sk + 1 < : Tk + 1 › is generated .
// - Fourth , the generated bounds and constraint formulas are reduced and incorporated with B to produce a bound set B ' .
// If B ' does not contain the bound false , and resolution of all the inference variables in B ' succeeds , then m1 is more specific than m2.
// Otherwise , m1 is not more specific than m2.
throw new UnsupportedOperationException ( ) ;


signature: public class TypeInference { private static MethodUsage instantiationSetToMethodUsage ( ResolvedMethodDeclaration methodDeclaration , InstantiationSet instantiationSet ) { } }

implementation: if ( instantiationSet . isEmpty ( ) ) { return new MethodUsage ( methodDeclaration ) ; } List < ResolvedType > paramTypes = new LinkedList < > ( ) ; for ( int i = 0 ; i < methodDeclaration . getNumberOfParams ( ) ; i ++ ) { paramTypes . add ( instantiationSet . apply ( methodDeclaration . getParam ( i ) . getType ( ) ) ) ; } ResolvedType returnType = instantiationSet . apply ( methodDeclaration . getReturnType ( ) ) ; return new MethodUsage ( methodDeclaration , paramTypes , returnType ) ;


signature:
public class TypeInference { /** * When inference begins , a bound set is typically generated from a list of type parameter declarations P1 , . . . , Pp
 * and associated inference variables α1 , . . . , αp
 * @ param typeParameterDeclarations
 * @ param inferenceVariables
 * @ return */
private BoundSet boundSetup ( List < ResolvedTypeParameterDeclaration > typeParameterDeclarations , List < InferenceVariable > inferenceVariables ) { } }

implementation:
if ( typeParameterDeclarations . size ( ) != inferenceVariables . size ( ) ) { throw new IllegalArgumentException ( ) ; } // When inference begins , a bound set is typically generated from a list of
// type parameter declarations P1 , . . . , Pp and associated inference variables α1 , . . . , αp .
// Such a bound set is constructed as follows . For each l ( 1 ≤ l ≤ p ) :
BoundSet boundSet = BoundSet . empty ( ) ; for ( int l = 0 ; l < typeParameterDeclarations . size ( ) ; l ++ ) { ResolvedTypeParameterDeclaration Pl = typeParameterDeclarations . get ( l ) ; InferenceVariable alphaL = inferenceVariables . get ( l ) ; // - If Pl has no TypeBound , the bound αl < : Object appears in the set .
if ( Pl . getBounds ( ) . isEmpty ( ) ) { boundSet = boundSet . withBound ( new SubtypeOfBound ( alphaL , object ) ) ; } else { // - Otherwise , for each type T delimited by & in the TypeBound , the bound αl < : T [ P1 : = α1 , . . . , Pp : = αp ] appears
// in the set ; if this results in no proper upper bounds for αl ( only dependencies ) , then the
// bound αl < : Object also appears in the set .
for ( ResolvedTypeParameterDeclaration . Bound bound : Pl . getBounds ( ) ) { ResolvedType T = bound . getType ( ) ; Substitution substitution = Substitution . empty ( ) ; for ( int j = 0 ; j < typeParameterDeclarations . size ( ) ; j ++ ) { substitution = substitution . withPair ( typeParameterDeclarations . get ( j ) , inferenceVariables . get ( j ) ) ; } ResolvedType TWithSubstitutions = substitution . apply ( T ) ; boundSet = boundSet . withBound ( new SubtypeOfBound ( alphaL , TWithSubstitutions ) ) ; if ( boundSet . getProperUpperBoundsFor ( alphaL ) . isEmpty ( ) ) { boundSet = boundSet . withBound ( new SubtypeOfBound ( alphaL , object ) ) ; } } } } return boundSet ;


signature: public class AbstractJavaParserContext { public static final SymbolReference < ResolvedValueDeclaration > solveWith ( SymbolDeclarator symbolDeclarator , String name ) { } }

implementation: for ( ResolvedValueDeclaration decl : symbolDeclarator . getSymbolDeclarations ( ) ) { if ( decl . getName ( ) . equals ( name ) ) { return SymbolReference . solved ( decl ) ; } } return SymbolReference . unsolved ( ResolvedValueDeclaration . class ) ;


signature: public class AbstractJavaParserContext { protected Optional < Value > solveWithAsValue ( SymbolDeclarator symbolDeclarator , String name , TypeSolver typeSolver ) { } }

implementation: return symbolDeclarator . getSymbolDeclarations ( ) . stream ( ) . filter ( d -> d . getName ( ) . equals ( name ) ) . map ( d -> Value . from ( d ) ) . findFirst ( ) ;


signature:
public class ExpressionHelper { /** * See https : / / docs . oracle . com / javase / specs / jls / se8 / html / jls - 15 . html # jls - 15.2
 * @ return */
public static boolean isPolyExpression ( Expression expression ) { } }

implementation:
if ( expression instanceof EnclosedExpr ) { throw new UnsupportedOperationException ( expression . toString ( ) ) ; } if ( expression instanceof ObjectCreationExpr ) { // A class instance creation expression is a poly expression ( § 15.2 ) if it uses the diamond form for type
// arguments to the class , and it appears in an assignment context or an invocation context ( § 5.2 , § 5.3 ) .
// Otherwise , it is a standalone expression .
ObjectCreationExpr objectCreationExpr = ( ObjectCreationExpr ) expression ; if ( objectCreationExpr . isUsingDiamondOperator ( ) ) { throw new UnsupportedOperationException ( expression . toString ( ) ) ; } else { return false ; } } if ( expression instanceof MethodCallExpr ) { MethodCallExpr methodCallExpr = ( MethodCallExpr ) expression ; // A method invocation expression is a poly expression if all of the following are true :
// 1 . The invocation appears in an assignment context or an invocation context ( § 5.2 , § 5.3 ) .
if ( ! appearsInAssignmentContext ( expression ) || appearsInInvocationContext ( expression ) ) { return false ; } // 2 . If the invocation is qualified ( that is , any form of MethodInvocation except for the first ) , then
// the invocation elides TypeArguments to the left of the Identifier .
if ( isQualified ( methodCallExpr ) && ! elidesTypeArguments ( methodCallExpr ) ) { return false ; } // 3 . The method to be invoked , as determined by the following subsections , is generic ( § 8.4.4 ) and has a
// return type that mentions at least one of the method ' s type parameters .
// boolean condition3 = ;
throw new UnsupportedOperationException ( expression . toString ( ) ) ; // Otherwise , the method invocation expression is a standalone expression .
// return true ;
} if ( expression instanceof MethodReferenceExpr ) { throw new UnsupportedOperationException ( expression . toString ( ) ) ; } if ( expression instanceof ConditionalExpr ) { throw new UnsupportedOperationException ( expression . toString ( ) ) ; } if ( expression instanceof LambdaExpr ) { return true ; } return false ;


signature:
public class ExpressionHelper { /** * Not sure if should look if the parent is an assignment context */
private static boolean appearsInAssignmentContext ( Expression expression ) { } }

implementation: if ( expression . getParentNode ( ) . isPresent ( ) ) { Node parent = expression . getParentNode ( ) . get ( ) ; if ( parent instanceof ExpressionStmt ) { return false ; } if ( parent instanceof MethodCallExpr ) { return false ; } if ( parent instanceof ReturnStmt ) { return false ; } throw new UnsupportedOperationException ( parent . getClass ( ) . getCanonicalName ( ) ) ; } return false ;


signature: public class ClassOrInterfaceDeclarationContext { @ Override public SymbolReference < ? extends ResolvedValueDeclaration > solveSymbol ( String name , TypeSolver typeSolver ) { } }

implementation:
if ( typeSolver == null ) throw new IllegalArgumentException ( ) ; if ( this . getDeclaration ( ) . hasVisibleField ( name ) ) { return SymbolReference . solved ( this . getDeclaration ( ) . getVisibleField ( name ) ) ; } // then to parent
return getParent ( ) . solveSymbol ( name , typeSolver ) ;


signature:
public class Predictor { /** * Generates predictions for given feature vector .
 * @ param feat feature vector
 * @ param output _ margin whether to only predict margin value instead of transformed prediction
 * @ param ntree _ limit limit the number of trees used in prediction
 * @ return prediction values */
public float [ ] predict ( FVec feat , boolean output_margin , int ntree_limit ) { } }

implementation: float [ ] preds = predictRaw ( feat , ntree_limit ) ; if ( ! output_margin ) { preds = obj . predTransform ( preds ) ; } return preds ;


signature:
public class Predictor { /** * Generates a prediction for given feature vector .
 * This method only works when the model outputs single value .
 * @ param feat feature vector
 * @ param output _ margin whether to only predict margin value instead of transformed prediction
 * @ param ntree _ limit limit the number of trees used in prediction
 * @ return prediction value */
public float predictSingle ( FVec feat , boolean output_margin , int ntree_limit ) { } }

implementation: float pred = predictSingleRaw ( feat , ntree_limit ) ; if ( ! output_margin ) { pred = obj . predTransform ( pred ) ; } return pred ;


signature:
public class ObjFunction { /** * Gets { @ link ObjFunction } from given name .
 * @ param name name of objective function
 * @ return objective function */
public static ObjFunction fromName ( String name ) { } }

implementation: ObjFunction result = FUNCTIONS . get ( name ) ; if ( result == null ) { throw new IllegalArgumentException ( name + " is not supported objective function." ) ; } return result ;


signature:
public class ObjFunction { /** * Uses Jafama ' s { @ link FastMath # exp ( double ) } instead of { @ link Math # exp ( double ) } .
 * @ param useJafama { @ code true } if you want to use Jafama ' s { @ link FastMath # exp ( double ) } ,
 * or { @ code false } if you don ' t want to use it but JDK ' s { @ link Math # exp ( double ) } . */
public static void useFastMathExp ( boolean useJafama ) { } }

implementation: if ( useJafama ) { register ( "binary:logistic" , new RegLossObjLogistic_Jafama ( ) ) ; register ( "multi:softprob" , new SoftmaxMultiClassObjProb_Jafama ( ) ) ; } else { register ( "binary:logistic" , new RegLossObjLogistic ( ) ) ; register ( "multi:softprob" , new SoftmaxMultiClassObjProb ( ) ) ; }


signature:
public class RegTreeImpl { /** * Loads model from stream .
 * @ param reader input stream
 * @ throws IOException If an I / O error occurs */
public void loadModel ( ModelReader reader ) throws IOException { } }

implementation: param = new Param ( reader ) ; nodes = new Node [ param . num_nodes ] ; for ( int i = 0 ; i < param . num_nodes ; i ++ ) { nodes [ i ] = new Node ( reader ) ; } stats = new RTreeNodeStat [ param . num_nodes ] ; for ( int i = 0 ; i < param . num_nodes ; i ++ ) { stats [ i ] = new RTreeNodeStat ( reader ) ; }


signature:
public class RegTreeImpl { /** * Retrieves nodes from root to leaf and returns leaf index .
 * @ param feat feature vector
 * @ param root _ id starting root index
 * @ return leaf index */
@ Override public int getLeafIndex ( FVec feat , int root_id ) { } }

implementation: int pid = root_id ; Node n ; while ( ! ( n = nodes [ pid ] ) . _isLeaf ) { pid = n . next ( feat ) ; } return pid ;


signature:
public class RegTreeImpl { /** * Retrieves nodes from root to leaf and returns leaf value .
 * @ param feat feature vector
 * @ param root _ id starting root index
 * @ return leaf value */
@ Override public float getLeafValue ( FVec feat , int root_id ) { } }

implementation: Node n = nodes [ root_id ] ; while ( ! n . _isLeaf ) { n = nodes [ n . next ( feat ) ] ; } return n . leaf_value ;


signature:
public class JsonUnflattener { /** * A fluent setter to setup the separator within a key in the flattened JSON .
 * The default separator is a dot ( . ) .
 * @ param separator
 * any character
 * @ return this { @ link JsonUnflattener } */
public JsonUnflattener withSeparator ( char separator ) { } }

implementation: isTrue ( ! Character . toString ( separator ) . matches ( "[\"\\s]" ) , "Separator contains illegal chracter(%s)" , Character . toString ( separator ) ) ; isTrue ( ! leftBracket . equals ( separator ) && ! rightBracket . equals ( separator ) , "Separator(%s) is already used in brackets" , Character . toString ( separator ) ) ; this . separator = separator ; return this ;


signature:
public class JsonUnflattener { /** * A fluent setter to setup the left and right brackets within a key in the
 * flattened JSON . The default left and right brackets are left square
 * bracket ( [ ) and right square bracket ( ] ) .
 * @ param leftBracket
 * any character
 * @ param rightBracket
 * any character
 * @ return this { @ link JsonUnflattener } */
public JsonUnflattener withLeftAndRightBrackets ( char leftBracket , char rightBracket ) { } }

implementation: isTrue ( leftBracket != rightBracket , "Both brackets cannot be the same" ) ; isTrue ( ! Character . toString ( leftBracket ) . matches ( illegalBracketsRegex ( ) ) , "Left bracket contains illegal chracter(%s)" , Character . toString ( leftBracket ) ) ; isTrue ( ! Character . toString ( rightBracket ) . matches ( illegalBracketsRegex ( ) ) , "Right bracket contains illegal chracter(%s)" , Character . toString ( rightBracket ) ) ; this . leftBracket = leftBracket ; this . rightBracket = rightBracket ; return this ;


signature:
public class JsonUnflattener { /** * Returns a JSON string of nested objects by the given flattened JSON string .
 * @ return a JSON string of nested objects */
public String unflatten ( ) { } }

implementation:
StringWriter sw = new StringWriter ( ) ; if ( root . isArray ( ) ) { try { unflattenArray ( root . asArray ( ) ) . writeTo ( sw , getWriterConfig ( ) ) ; } catch ( IOException e ) { } return sw . toString ( ) ; } if ( ! root . isObject ( ) ) { return root . toString ( ) ; } JsonObject flattened = root . asObject ( ) ; JsonValue unflattened = flattened . names ( ) . isEmpty ( ) ? Json . object ( ) : null ; for ( String key : flattened . names ( ) ) { JsonValue currentVal = unflattened ; String objKey = null ; Integer aryIdx = null ; Matcher matcher = keyPartPattern ( ) . matcher ( key ) ; while ( matcher . find ( ) ) { String keyPart = matcher . group ( ) ; if ( objKey != null ^ aryIdx != null ) { if ( isJsonArray ( keyPart ) ) { currentVal = findOrCreateJsonArray ( currentVal , objKey , aryIdx ) ; objKey = null ; aryIdx = extractIndex ( keyPart ) ; } else { // JSON object
if ( flattened . get ( key ) . isArray ( ) ) { // KEEP _ ARRAYS mode
flattened . set ( key , unflattenArray ( flattened . get ( key ) . asArray ( ) ) ) ; } currentVal = findOrCreateJsonObject ( currentVal , objKey , aryIdx ) ; objKey = extractKey ( keyPart ) ; aryIdx = null ; } } if ( objKey == null && aryIdx == null ) { if ( isJsonArray ( keyPart ) ) { aryIdx = extractIndex ( keyPart ) ; if ( currentVal == null ) currentVal = Json . array ( ) ; } else { // JSON object
objKey = extractKey ( keyPart ) ; if ( currentVal == null ) currentVal = Json . object ( ) ; } } if ( unflattened == null ) unflattened = currentVal ; } setUnflattenedValue ( flattened , key , currentVal , objKey , aryIdx ) ; } try { unflattened . writeTo ( sw , getWriterConfig ( ) ) ; } catch ( IOException e ) { } return sw . toString ( ) ;


signature:
public class IndexedPeekIterator { /** * Creates an { @ link IndexedPeekIterator } by given Iterable .
 * @ param < T >
 * the type of elements
 * @ param iter
 * any Iterable
 * @ return an { @ link IndexedPeekIterator } */
public static < T > IndexedPeekIterator < T > newIndexedPeekIterator ( Iterable < T > iter ) { } }

implementation: return new IndexedPeekIterator < T > ( iter . iterator ( ) ) ;


signature:
public class JsonFlattener { /** * A fluent setter to setup the separator within a key in the flattened JSON .
 * The default separator is a dot ( . ) .
 * @ param separator
 * any character
 * @ return this { @ link JsonFlattener } */
public JsonFlattener withSeparator ( char separator ) { } }

implementation: isTrue ( ! Character . toString ( separator ) . matches ( "[\"\\s]" ) , "Separator contains illegal chracter(%s)" , Character . toString ( separator ) ) ; isTrue ( ! leftBracket . equals ( separator ) && ! rightBracket . equals ( separator ) , "Separator(%s) is already used in brackets" , Character . toString ( separator ) ) ; this . separator = separator ; flattenedMap = null ; return this ;


signature:
public class JsonFlattener { /** * A fluent setter to setup the left and right brackets within a key in the
 * flattened JSON . The default left and right brackets are left square
 * bracket ( [ ) and right square bracket ( ] ) .
 * @ param leftBracket
 * any character
 * @ param rightBracket
 * any character
 * @ return this { @ link JsonFlattener } */
public JsonFlattener withLeftAndRightBrackets ( char leftBracket , char rightBracket ) { } }

implementation: isTrue ( leftBracket != rightBracket , "Both brackets cannot be the same" ) ; isTrue ( ! Character . toString ( leftBracket ) . matches ( illegalBracketsRegex ( ) ) , "Left bracket contains illegal chracter(%s)" , Character . toString ( leftBracket ) ) ; isTrue ( ! Character . toString ( rightBracket ) . matches ( illegalBracketsRegex ( ) ) , "Right bracket contains illegal chracter(%s)" , Character . toString ( rightBracket ) ) ; this . leftBracket = leftBracket ; this . rightBracket = rightBracket ; flattenedMap = null ; return this ;


signature:
public class JsonFlattener { /** * Returns a flattened JSON string .
 * @ return a flattened JSON string */
public String flatten ( ) { } }

implementation: flattenAsMap ( ) ; if ( source . isObject ( ) || isObjectifiableArray ( ) ) return flattenedMap . toString ( printMode ) ; else return javaObj2Json ( flattenedMap . get ( ROOT ) ) ;


signature:
public class JsonFlattener { /** * Returns a flattened JSON as Map .
 * @ return a flattened JSON as Map */
public Map < String , Object > flattenAsMap ( ) { } }

implementation:
if ( flattenedMap != null ) return flattenedMap ; flattenedMap = newJsonifyLinkedHashMap ( ) ; reduce ( source ) ; while ( ! elementIters . isEmpty ( ) ) { IndexedPeekIterator < ? > deepestIter = elementIters . getLast ( ) ; if ( ! deepestIter . hasNext ( ) ) { elementIters . removeLast ( ) ; } else if ( deepestIter . peek ( ) instanceof Member ) { Member mem = ( Member ) deepestIter . next ( ) ; reduce ( mem . getValue ( ) ) ; } else { // JsonValue
JsonValue val = ( JsonValue ) deepestIter . next ( ) ; reduce ( val ) ; } } return flattenedMap ;


signature:
public class FxTimer { /** * Prepares a ( stopped ) timer that lasts for { @ code delay } and whose action runs when timer < em > ends < / em > . */
public static Timer create ( java . time . Duration delay , Runnable action ) { } }

implementation: return new FxTimer ( delay , delay , action , 1 ) ;


signature:
public class FxTimer { /** * Equivalent to { @ code create ( delay , action ) . restart ( ) } . */
public static Timer runLater ( java . time . Duration delay , Runnable action ) { } }

implementation: Timer timer = create ( delay , action ) ; timer . restart ( ) ; return timer ;


signature:
public class FxTimer { /** * Prepares a ( stopped ) timer that lasts for { @ code interval } and that executes the given action periodically
 * when the timer < em > ends < / em > . */
public static Timer createPeriodic ( java . time . Duration interval , Runnable action ) { } }

implementation: return new FxTimer ( interval , interval , action , Animation . INDEFINITE ) ;


signature:
public class FxTimer { /** * Equivalent to { @ code createPeriodic ( interval , action ) . restart ( ) } . */
public static Timer runPeriodically ( java . time . Duration interval , Runnable action ) { } }

implementation: Timer timer = createPeriodic ( interval , action ) ; timer . restart ( ) ; return timer ;


signature:
public class FxTimer { /** * Prepares a ( stopped ) timer that lasts for { @ code interval } and that executes the given action periodically
 * when the timer < em > starts < / em > . */
public static Timer createPeriodic0 ( java . time . Duration interval , Runnable action ) { } }

implementation: return new FxTimer ( java . time . Duration . ZERO , interval , action , Animation . INDEFINITE ) ;


signature:
public class FxTimer { /** * Equivalent to { @ code createPeriodic0 ( interval , action ) . restart ( ) } . */
public static Timer runPeriodically0 ( java . time . Duration interval , Runnable action ) { } }

implementation: Timer timer = createPeriodic0 ( interval , action ) ; timer . restart ( ) ; return timer ;


signature:
public class ObservableBase { /** * Executes action for each observer , regardless of recursion state .
 * If { @ code action } throws an exception for one observer , it will not
 * be called for any subsequent observers and the exception will be
 * propagated by this method .
 * @ param action action to execute for each observer . */
protected final void forEachObserver ( Consumer < O > action ) { } }

implementation: ListHelper . forEach ( observers , o -> action . accept ( o ) ) ;


signature:
public class Lists { /** * Returns a list that is a concatenation of the given lists . The returned
 * list is a view of the underlying lists , without copying the elements .
 * The returned list is unmodifiable . Modifications to underlying lists
 * will be visible through the concatenation view . */
public static < E > List < E > concatView ( List < List < ? extends E > > lists ) { } }

implementation: if ( lists . isEmpty ( ) ) { return Collections . emptyList ( ) ; } else { return ConcatView . create ( lists ) ; }


signature:
public class Lists { /** * Returns a list that is a concatenation of the given lists . The returned
 * list is a view of the underlying lists , without copying the elements .
 * As opposed to { @ link # concatView ( List ) } , the underlying lists must not
 * be modified while the returned concatenation view is in use . On the other
 * hand , this method guarantees balanced nesting if some of the underlying
 * lists are already concatenations created by this method . */
public static < E > List < E > concat ( List < List < ? extends E > > lists ) { } }

implementation: return ListConcatenation . create ( lists ) ;


signature:
public class EventStreams { /** * Creates an event stream that emits an impulse on every invalidation
 * of the given observable . */
public static EventStream < Void > invalidationsOf ( Observable observable ) { } }

implementation: return new EventStreamBase < Void > ( ) { @ Override protected Subscription observeInputs ( ) { InvalidationListener listener = obs -> emit ( null ) ; observable . addListener ( listener ) ; return ( ) -> observable . removeListener ( listener ) ; } } ;


signature:
public class EventStreams { /** * Creates an event stream that emits the given observable immediately for
 * every subscriber and re - emits it on every subsequent invalidation of the
 * observable . */
public static < O extends Observable > EventStream < O > repeatOnInvalidation ( O observable ) { } }

implementation: return new EventStreamBase < O > ( ) { @ Override protected Subscription observeInputs ( ) { InvalidationListener listener = obs -> emit ( observable ) ; observable . addListener ( listener ) ; return ( ) -> observable . removeListener ( listener ) ; } @ Override protected void newObserver ( Consumer < ? super O > subscriber ) { subscriber . accept ( observable ) ; } } ;


signature:
public class EventStreams { /** * Creates an event stream that emits the value of the given
 * { @ code ObservableValue } immediately for every subscriber and then on
 * every change . */
public static < T > EventStream < T > valuesOf ( ObservableValue < T > observable ) { } }

implementation: return new EventStreamBase < T > ( ) { @ Override protected Subscription observeInputs ( ) { ChangeListener < T > listener = ( obs , old , val ) -> emit ( val ) ; observable . addListener ( listener ) ; return ( ) -> observable . removeListener ( listener ) ; } @ Override protected void newObserver ( Consumer < ? super T > subscriber ) { subscriber . accept ( observable . getValue ( ) ) ; } } ;


signature:
public class EventStreams { /** * Use only when the subscriber does not cause { @ code list } modification
 * of the underlying list . */
public static < T > EventStream < ListModification < ? extends T > > simpleChangesOf ( ObservableList < T > list ) { } }

implementation: return new EventStreamBase < ListModification < ? extends T > > ( ) { @ Override protected Subscription observeInputs ( ) { return LiveList . observeChanges ( list , c -> { for ( ListModification < ? extends T > mod : c ) { emit ( mod ) ; } } ) ; } } ;


signature:
public class EventStreams { /** * Returns an event stream that emits periodic < i > ticks < / i > . The first tick
 * is emitted after { @ code interval } amount of time has passed .
 * The returned stream may only be used on the JavaFX application thread .
 * < p > As with all lazily bound streams , ticks are emitted only when there
 * is at least one subscriber to the returned stream . This means that to
 * release associated resources , it suffices to unsubscribe from the
 * returned stream . */
public static EventStream < ? > ticks ( Duration interval ) { } }

implementation: return new EventStreamBase < Void > ( ) { private final Timer timer = FxTimer . createPeriodic ( interval , ( ) -> emit ( null ) ) ; @ Override protected Subscription observeInputs ( ) { timer . restart ( ) ; return timer :: stop ; } } ;


signature:
public class EventStreams { /** * Returns an event stream that emits periodic < i > ticks < / i > . The first tick
 * is emitted at time 0.
 * The returned stream may only be used on the JavaFX application thread .
 * < p > As with all lazily bound streams , ticks are emitted only when there
 * is at least one subscriber to the returned stream . This means that to
 * release associated resources , it suffices to unsubscribe from the
 * returned stream . */
public static EventStream < ? > ticks0 ( Duration interval ) { } }

implementation: return new EventStreamBase < Void > ( ) { private final Timer timer = FxTimer . createPeriodic0 ( interval , ( ) -> emit ( null ) ) ; @ Override protected Subscription observeInputs ( ) { timer . restart ( ) ; return timer :: stop ; } } ;


signature:
public class EventStreams { /** * Returns an event stream that emits periodic < i > ticks < / i > on the given
 * { @ code eventThreadExecutor } . The returned stream may only be used from
 * that executor ' s thread .
 * < p > As with all lazily bound streams , ticks are emitted only when there
 * is at least one subscriber to the returned stream . This means that to
 * release associated resources , it suffices to unsubscribe from the
 * returned stream .
 * @ param scheduler scheduler used to schedule periodic emissions .
 * @ param eventThreadExecutor single - thread executor used to emit the ticks . */
public static EventStream < ? > ticks ( Duration interval , ScheduledExecutorService scheduler , Executor eventThreadExecutor ) { } }

implementation: return new EventStreamBase < Void > ( ) { private final Timer timer = ScheduledExecutorServiceTimer . createPeriodic ( interval , ( ) -> emit ( null ) , scheduler , eventThreadExecutor ) ; @ Override protected Subscription observeInputs ( ) { timer . restart ( ) ; return timer :: stop ; } } ;


signature:
public class EventStreams { /** * Returns a { @ link # ticks ( Duration ) } EventStream whose timer restarts whenever
 * impulse emits an event .
 * @ param interval - the amount of time that passes until this stream emits its next tick
 * @ param impulse - the EventStream that resets this EventStream ' s internal timer */
public static EventStream < ? > restartableTicks ( Duration interval , EventStream < ? > impulse ) { } }

implementation: return new EventStreamBase < Void > ( ) { private final Timer timer = FxTimer . createPeriodic ( interval , ( ) -> emit ( null ) ) ; @ Override protected Subscription observeInputs ( ) { timer . restart ( ) ; return Subscription . multi ( impulse . subscribe ( x -> timer . restart ( ) ) , timer :: stop ) ; } } ;


signature:
public class EventStreams { /** * Returns an event stream that emits a timestamp of the current frame in
 * nanoseconds on every frame . The timestamp has the same meaning as the
 * argument of the { @ link AnimationTimer # handle ( long ) } method . */
public static EventStream < Long > animationTicks ( ) { } }

implementation: return new EventStreamBase < Long > ( ) { private final AnimationTimer timer = new AnimationTimer ( ) { @ Override public void handle ( long now ) { emit ( now ) ; } } ; @ Override protected Subscription observeInputs ( ) { timer . start ( ) ; return timer :: stop ; } } ;


signature:
public class EventStreams { /** * Returns a stream that , on each animation frame , emits the duration
 * elapsed since the previous animation frame , in nanoseconds . */
public static EventStream < Long > animationFrames ( ) { } }

implementation: return animationTicks ( ) . accumulate ( t ( 0L , - 1L ) , ( state , now ) -> state . map ( ( d , last ) -> { return t ( last == - 1L ? 0L : now - last , now ) ; } ) ) . map ( t -> t . _1 ) ;


signature:
public class EventStreams { /** * Returns an event stream that emits all the events emitted from any of
 * the { @ code inputs } . The event type of the returned stream is the nearest
 * common super - type of all the { @ code inputs } .
 * @ see EventStream # or ( EventStream ) */
@ SafeVarargs public static < T > EventStream < T > merge ( EventStream < ? extends T > ... inputs ) { } }

implementation: return new EventStreamBase < T > ( ) { @ Override protected Subscription observeInputs ( ) { return Subscription . multi ( i -> i . subscribe ( this :: emit ) , inputs ) ; } } ;


signature:
public class EventStreams { /** * Returns an event stream that emits all the events emitted from any of
 * the event streams in the given observable set . When an event stream is
 * added to the set , the returned stream will start emitting its events .
 * When an event stream is removed from the set , its events will no longer
 * be emitted from the returned stream . */
public static < T > EventStream < T > merge ( ObservableSet < ? extends EventStream < T > > set ) { } }

implementation: return new EventStreamBase < T > ( ) { @ Override protected Subscription observeInputs ( ) { return Subscription . dynamic ( set , s -> s . subscribe ( this :: emit ) ) ; } } ;


signature:
public class EventStreams { /** * A more general version of { @ link # merge ( ObservableSet ) } for a set of
 * arbitrary element type and a function to obtain an event stream from
 * the element .
 * @ param set observable set of elements
 * @ param f function to obtain an event stream from an element */
public static < T , U > EventStream < U > merge ( ObservableSet < ? extends T > set , Function < ? super T , ? extends EventStream < U > > f ) { } }

implementation: return new EventStreamBase < U > ( ) { @ Override protected Subscription observeInputs ( ) { return Subscription . dynamic ( set , t -> f . apply ( t ) . subscribe ( this :: emit ) ) ; } } ;


signature:
public class Collections { /** * Creates an ObservableList wrapper that is able to temporarily block
 * list change notifications .
 * @ param delegate the underlying observable list .
 * @ deprecated Use { @ link LiveList # suspendable ( javafx . collections . ObservableList ) } instead . */
@ Deprecated public static < E > ObservableList < E > wrap ( javafx . collections . ObservableList < E > delegate ) { } }

implementation: return LiveList . suspendable ( delegate ) ;


signature:
public class Indicator { /** * Runs the given computation , making sure this indicator is on .
 * When done , this indicator is reset to the previous state .
 * < pre >
 * T t = indicator . onWhile ( f ) ;
 * < / pre >
 * is equivalent to
 * < pre >
 * T t ;
 * try ( Guard g = on ( ) ) {
 * t = f . get ( ) ;
 * < / pre > */
public < T > T onWhile ( Supplier < T > f ) { } }

implementation: try ( Guard g = on ( ) ) { return f . get ( ) ; }


signature:
public class ProxyObservable { /** * Overridden to avoid second transformation on removeObserver */
@ Override public final Subscription observe ( O observer ) { } }

implementation: P adapted = adaptObserver ( observer ) ; underlying . addObserver ( adapted ) ; return ( ) -> underlying . removeObserver ( adapted ) ;


signature:
public class DBMetadataUtils { /** * 获取默认的Config
 * @ return
 * @ throws SQLException */
public DatabaseConfig getDefaultConfig ( ) throws SQLException { } }

implementation: DatabaseConfig config = null ; if ( catalogs . size ( ) == 1 ) { if ( schemas . size ( ) == 1 ) { config = new DatabaseConfig ( catalogs . get ( 0 ) , schemas . get ( 0 ) ) ; } else if ( schemas . size ( ) == 0 ) { config = new DatabaseConfig ( catalogs . get ( 0 ) , null ) ; } } else if ( catalogs . size ( ) == 0 ) { if ( schemas . size ( ) == 1 ) { config = new DatabaseConfig ( null , schemas . get ( 0 ) ) ; } else if ( schemas . size ( ) == 0 ) { config = new DatabaseConfig ( null , null ) ; } } if ( config == null ) { switch ( getDialect ( ) ) { case DB2 : case ORACLE : config = new DatabaseConfig ( null , dataSource . getUser ( ) ) ; break ; case MYSQL : if ( schemas . size ( ) > 0 ) { break ; } String url = dataSource . getUrl ( ) ; if ( url . indexOf ( '/' ) > 0 ) { String dbName = url . substring ( url . lastIndexOf ( '/' ) + 1 ) ; for ( String catalog : catalogs ) { if ( dbName . equalsIgnoreCase ( catalog ) ) { config = new DatabaseConfig ( catalog , null ) ; break ; } } } break ; case SQLSERVER : String sqlserverUrl = dataSource . getUrl ( ) ; String sqlserverCatalog = null ; if ( sqlserverUrl . indexOf ( '/' ) > 0 ) { String dbName = sqlserverUrl . substring ( sqlserverUrl . lastIndexOf ( '/' ) + 1 ) ; for ( String catalog : catalogs ) { if ( dbName . equalsIgnoreCase ( catalog ) ) { sqlserverCatalog = catalog ; break ; } } if ( sqlserverCatalog != null ) { for ( String schema : schemas ) { if ( "dbo" . equalsIgnoreCase ( schema ) ) { config = new DatabaseConfig ( sqlserverCatalog , "dbo" ) ; break ; } } } } break ; case POSTGRESQL : String postgreUrl = dataSource . getUrl ( ) ; String postgreCatalog = null ; if ( postgreUrl . indexOf ( '/' ) > 0 ) { String dbName = postgreUrl . substring ( postgreUrl . lastIndexOf ( '/' ) + 1 ) ; for ( String catalog : catalogs ) { if ( dbName . equalsIgnoreCase ( catalog ) ) { postgreCatalog = catalog ; break ; } } if ( postgreCatalog != null ) { for ( String schema : schemas ) { if ( "public" . equalsIgnoreCase ( schema ) ) { config = new DatabaseConfig ( postgreCatalog , "public" ) ; break ; } } } } break ; default : break ; } } return config ;


signature:
public class SqlServerIntrospector { /** * 获取表名和注释映射
 * @ param config
 * @ return
 * @ throws java . sql . SQLException */
protected Map < String , String > getTableComments ( DatabaseConfig config ) throws SQLException { } }

implementation: Map < String , String > answer = new HashMap < String , String > ( ) ; try { StringBuilder sqlBuilder = new StringBuilder ( "select a.name tname, b.value comments " ) ; sqlBuilder . append ( "from sys.tables a left join sys.extended_properties b on a.object_id=b.major_id    " ) ; sqlBuilder . append ( "where b.minor_id=0 and b.name = 'MS_Description'   " ) ; sqlBuilder . append ( "and a.schema_id in (   " ) ; sqlBuilder . append ( "    select schema_id from sys.schemas  " ) ; if ( StringUtils . isNotEmpty ( config . getSchemaPattern ( ) ) ) { sqlBuilder . append ( " where name like ?   " ) ; } sqlBuilder . append ( ")  and b.value is not null " ) ; PreparedStatement preparedStatement = dbMetadataUtils . getConnection ( ) . prepareStatement ( sqlBuilder . toString ( ) ) ; if ( StringUtils . isNotEmpty ( config . getSchemaPattern ( ) ) ) { preparedStatement . setString ( 1 , config . getSchemaPattern ( ) ) ; } ResultSet rs = preparedStatement . executeQuery ( ) ; while ( rs . next ( ) ) { answer . put ( rs . getString ( dbMetadataUtils . convertLetterByCase ( "tname" ) ) , rs . getString ( dbMetadataUtils . convertLetterByCase ( "comments" ) ) ) ; } closeResultSet ( rs ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return answer ;


signature:
public class PGIntrospector { /** * 获取表名和注释映射
 * @ param config
 * @ return
 * @ throws java . sql . SQLException */
protected Map < String , String > getTableComments ( DatabaseConfig config ) throws SQLException { } }

implementation: Map < String , String > answer = new HashMap < String , String > ( ) ; try { PreparedStatement preparedStatement = dbMetadataUtils . getConnection ( ) . prepareStatement ( "select tname,comments from(select relname as TNAME ,col_description(c.oid, 0) as COMMENTS from pg_class c where  relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%') as temp where comments is not null " ) ; ResultSet rs = preparedStatement . executeQuery ( ) ; while ( rs . next ( ) ) { answer . put ( rs . getString ( dbMetadataUtils . convertLetterByCase ( "tname" ) ) , rs . getString ( dbMetadataUtils . convertLetterByCase ( "comments" ) ) ) ; } closeResultSet ( rs ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return answer ;


signature:
public class ToolsService { /** * 处理标题列的居中
 * @ param dbField */
public void prcessDbFieldHeader ( JTable dbField ) { } }

implementation: dbField . getColumn ( fieldNames [ 4 ] ) . setPreferredWidth ( 40 ) ; dbField . getColumn ( fieldNames [ 4 ] ) . setMinWidth ( 40 ) ; dbField . getColumn ( fieldNames [ 4 ] ) . setMaxWidth ( 40 ) ; dbField . getColumn ( fieldNames [ 5 ] ) . setPreferredWidth ( 40 ) ; dbField . getColumn ( fieldNames [ 5 ] ) . setMinWidth ( 40 ) ; dbField . getColumn ( fieldNames [ 5 ] ) . setMaxWidth ( 40 ) ;


signature:
public class DBData { /** * 初始化默认的Config
 * @ throws SQLException */
private static void initConfig ( ) throws SQLException { } }

implementation: DBData . catalogs = dbMetadataUtils . getCatalogs ( ) ; DBData . schemas = dbMetadataUtils . getSchemas ( ) ; DBData . config = dbMetadataUtils . getDefaultConfig ( ) ;


signature:
public class DBData { /** * 查询表
 * @ param searchText
 * @ param searchComment
 * @ param matchType
 * @ param caseSensitive
 * @ return */
public static List < IntrospectedTable > selectTables ( String searchText , String searchComment , MatchType matchType , boolean caseSensitive ) { } }

implementation: List < IntrospectedTable > answer = new ArrayList < IntrospectedTable > ( ) ; if ( tables == null || tables . size ( ) == 0 ) { return answer ; } if ( StringUtils . isEmpty ( searchText ) && StringUtils . isEmpty ( searchComment ) ) { return tables ; } for ( IntrospectedTable table : tables ) { if ( table . filter ( searchText , searchComment , matchType , caseSensitive ) ) { answer . add ( table ) ; } } sortTables ( answer ) ; return answer ;


signature:
public class DBData { /** * 查询字段
 * @ param searchText
 * @ param searchComment
 * @ param matchType
 * @ param caseSensitive
 * @ return */
public static List < IntrospectedColumn > selectColumns ( String searchText , String searchComment , MatchType matchType , boolean caseSensitive ) { } }

implementation: List < IntrospectedColumn > answer = new ArrayList < IntrospectedColumn > ( ) ; if ( tables == null || tables . size ( ) == 0 ) { return answer ; } if ( StringUtils . isEmpty ( searchText ) && StringUtils . isEmpty ( searchComment ) ) { return null ; } for ( IntrospectedTable table : tables ) { for ( IntrospectedColumn column : table . getAllColumns ( ) ) { if ( column . filter ( searchText , searchComment , matchType , caseSensitive ) ) { answer . add ( column ) ; } } } sortColumns ( answer ) ; return answer ;


signature:
public class I18n { /** * 初始化 - 可以设置语言
 * @ param locale */
public static void init ( Locale locale ) { } }

implementation: if ( locale != null ) { Locale . setDefault ( locale ) ; } if ( baseNameList == null || baseNameList . size ( ) == 0 ) { initBaseNameList ( ) ; } resourceBundles = new ResourceBundle [ baseNameList . size ( ) ] ; int i = 0 ; for ( String baseName : baseNameList ) { resourceBundles [ i ] = ResourceBundle . getBundle ( baseName ) ; i ++ ; }


signature:
public class I18n { /** * 可配参数 , 如 : 查找 { 0 } 字段
 * @ param key
 * @ param args
 * @ return */
public static String key ( String key , Object ... args ) { } }

implementation: return MessageFormat . format ( key ( key ) , args ) ;


signature:
public class IntrospectedBase { /** * 根据条件进行过滤
 * @ param searchText
 * @ param searchComment
 * @ param matchType
 * @ param caseSensitive
 * @ return */
public boolean filter ( String searchText , String searchComment , MatchType matchType , boolean caseSensitive ) { } }

implementation: if ( StringUtils . isNotEmpty ( searchText ) ) { if ( matchType == MatchType . EQUALS ) { if ( caseSensitive ) { if ( ! getName ( ) . equals ( searchText ) ) { return false ; } } else { if ( ! getName ( ) . equalsIgnoreCase ( searchText ) ) { return false ; } } } else { if ( caseSensitive ) { if ( getName ( ) . indexOf ( searchText ) == - 1 ) { return false ; } } else { if ( getName ( ) . toUpperCase ( ) . indexOf ( searchText . toUpperCase ( ) ) == - 1 ) { return false ; } } } } if ( StringUtils . isNotEmpty ( searchComment ) ) { if ( matchType == MatchType . EQUALS ) { if ( caseSensitive ) { if ( getRemarks ( ) == null || ! getRemarks ( ) . equals ( searchComment ) ) { return false ; } } else { if ( getRemarks ( ) == null || ! getRemarks ( ) . equalsIgnoreCase ( searchComment ) ) { return false ; } } } else { if ( caseSensitive ) { if ( getRemarks ( ) == null || getRemarks ( ) . indexOf ( searchComment ) == - 1 ) { return false ; } } else { if ( getRemarks ( ) == null || getRemarks ( ) . indexOf ( searchComment ) == - 1 ) { return false ; } } } } return true ;


signature:
public class DatabaseIntrospector { /** * 计算主键
 * @ param config
 * @ param introspectedTable */
protected void calculatePrimaryKey ( DatabaseConfig config , IntrospectedTable introspectedTable ) { } }

implementation:
ResultSet rs = null ; try { rs = dbMetadataUtils . getDatabaseMetaData ( ) . getPrimaryKeys ( config . getCatalog ( ) , config . getSchemaPattern ( ) , introspectedTable . getName ( ) ) ; } catch ( SQLException e ) { closeResultSet ( rs ) ; return ; } try { Map < Short , String > keyColumns = new TreeMap < Short , String > ( ) ; while ( rs . next ( ) ) { // 主键列名
String columnName = rs . getString ( "COLUMN_NAME" ) ; // 主键顺序
short keySeq = rs . getShort ( "KEY_SEQ" ) ; keyColumns . put ( keySeq , columnName ) ; } for ( String columnName : keyColumns . values ( ) ) { introspectedTable . addPrimaryKeyColumn ( columnName ) ; } } catch ( SQLException e ) { } finally { closeResultSet ( rs ) ; }


signature:
public class DatabaseIntrospector { /** * 获取表信息
 * @ param config
 * @ return
 * @ throws SQLException */
public List < IntrospectedTable > introspectTables ( DatabaseConfig config ) throws SQLException { } }

implementation:
if ( config . hasProcess ( ) ) { config . getDatabaseProcess ( ) . processStart ( ) ; } List < IntrospectedTable > introspectedTables = null ; try { DatabaseConfig localConfig = getLocalDatabaseConfig ( config ) ; Map < IntrospectedTable , List < IntrospectedColumn > > columns = getColumns ( localConfig ) ; if ( columns . isEmpty ( ) ) { introspectedTables = new ArrayList < IntrospectedTable > ( 0 ) ; } else { introspectedTables = calculateIntrospectedTables ( localConfig , columns ) ; Iterator < IntrospectedTable > iter = introspectedTables . iterator ( ) ; while ( iter . hasNext ( ) ) { IntrospectedTable introspectedTable = iter . next ( ) ; // 去掉没有字段的表
if ( ! introspectedTable . hasAnyColumns ( ) ) { iter . remove ( ) ; } } } } finally { if ( config . hasProcess ( ) ) { config . getDatabaseProcess ( ) . processComplete ( introspectedTables ) ; } } return introspectedTables ;


signature:
public class DatabaseIntrospector { /** * 根据数据库转换配置
 * @ param config
 * @ return
 * @ throws SQLException */
protected DatabaseConfig getLocalDatabaseConfig ( DatabaseConfig config ) throws SQLException { } }

implementation: String localCatalog ; String localSchema ; String localTableName ; if ( dbMetadataUtils . getDatabaseMetaData ( ) . storesLowerCaseIdentifiers ( ) ) { localCatalog = config . getCatalog ( ) == null ? null : config . getCatalog ( ) . toLowerCase ( ) ; localSchema = config . getSchemaPattern ( ) == null ? null : config . getSchemaPattern ( ) . toLowerCase ( ) ; localTableName = config . getTableNamePattern ( ) == null ? null : config . getTableNamePattern ( ) . toLowerCase ( ) ; } else if ( dbMetadataUtils . getDatabaseMetaData ( ) . storesUpperCaseIdentifiers ( ) ) { localCatalog = config . getCatalog ( ) == null ? null : config . getCatalog ( ) . toUpperCase ( ) ; localSchema = config . getSchemaPattern ( ) == null ? null : config . getSchemaPattern ( ) . toUpperCase ( ) ; localTableName = config . getTableNamePattern ( ) == null ? null : config . getTableNamePattern ( ) . toUpperCase ( ) ; } else { localCatalog = config . getCatalog ( ) ; localSchema = config . getSchemaPattern ( ) ; localTableName = config . getTableNamePattern ( ) ; } DatabaseConfig newConfig = new DatabaseConfig ( localCatalog , localSchema , localTableName ) ; newConfig . setDatabaseProcess ( config . getDatabaseProcess ( ) ) ; return newConfig ;


signature:
public class DatabaseIntrospector { /** * 获取全部的表和字段
 * @ param config
 * @ return
 * @ throws SQLException */
protected Map < IntrospectedTable , List < IntrospectedColumn > > getColumns ( DatabaseConfig config ) throws SQLException { } }

implementation: Map < IntrospectedTable , List < IntrospectedColumn > > answer = new HashMap < IntrospectedTable , List < IntrospectedColumn > > ( ) ; ResultSet rs = dbMetadataUtils . getDatabaseMetaData ( ) . getColumns ( config . getCatalog ( ) , config . getSchemaPattern ( ) , config . getTableNamePattern ( ) , null ) ; while ( rs . next ( ) ) { IntrospectedColumn column = new IntrospectedColumn ( ) ; column . setJdbcType ( rs . getInt ( "DATA_TYPE" ) ) ; column . setType ( rs . getString ( "TYPE_NAME" ) ) ; column . setLength ( rs . getInt ( "COLUMN_SIZE" ) ) ; column . setName ( rs . getString ( "COLUMN_NAME" ) ) ; column . setNullable ( rs . getInt ( "NULLABLE" ) == DatabaseMetaData . columnNullable ) ; column . setScale ( rs . getInt ( "DECIMAL_DIGITS" ) ) ; column . setRemarks ( rs . getString ( "REMARKS" ) ) ; column . setDefaultValue ( rs . getString ( "COLUMN_DEF" ) ) ; IntrospectedTable table = new IntrospectedTable ( rs . getString ( "TABLE_CAT" ) , rs . getString ( "TABLE_SCHEM" ) , rs . getString ( "TABLE_NAME" ) ) ; List < IntrospectedColumn > columns = answer . get ( table ) ; if ( columns == null ) { columns = new ArrayList < IntrospectedColumn > ( ) ; answer . put ( table , columns ) ; if ( config . hasProcess ( ) ) { config . getDatabaseProcess ( ) . processTable ( table ) ; } } if ( config . hasProcess ( ) ) { config . getDatabaseProcess ( ) . processColumn ( table , column ) ; } columns . add ( column ) ; } closeResultSet ( rs ) ; return answer ;


signature:
public class DatabaseIntrospector { /** * 处理表
 * @ param config
 * @ param columns
 * @ return
 * @ throws SQLException */
protected List < IntrospectedTable > calculateIntrospectedTables ( DatabaseConfig config , Map < IntrospectedTable , List < IntrospectedColumn > > columns ) throws SQLException { } }

implementation:
List < IntrospectedTable > answer = new ArrayList < IntrospectedTable > ( ) ; // 获取表注释信息
Map < String , String > tableCommentsMap = getTableComments ( config ) ; Map < String , Map < String , String > > tableColumnCommentsMap = getColumnComments ( config ) ; for ( Map . Entry < IntrospectedTable , List < IntrospectedColumn > > entry : columns . entrySet ( ) ) { IntrospectedTable table = entry . getKey ( ) ; if ( tableCommentsMap != null && tableCommentsMap . containsKey ( table . getName ( ) ) ) { table . setRemarks ( tableCommentsMap . get ( table . getName ( ) ) ) ; } Map < String , String > columnCommentsMap = null ; if ( tableColumnCommentsMap != null && tableColumnCommentsMap . containsKey ( table . getName ( ) ) ) { columnCommentsMap = tableColumnCommentsMap . get ( table . getName ( ) ) ; } for ( IntrospectedColumn introspectedColumn : entry . getValue ( ) ) { FullyQualifiedJavaType fullyQualifiedJavaType = calculateJavaType ( introspectedColumn ) ; if ( fullyQualifiedJavaType != null ) { introspectedColumn . setFullyQualifiedJavaType ( fullyQualifiedJavaType ) ; introspectedColumn . setJdbcTypeName ( calculateJdbcTypeName ( introspectedColumn ) ) ; } // 转换为驼峰形式
if ( useCamelCase ) { introspectedColumn . setJavaProperty ( JavaBeansUtil . getCamelCaseString ( introspectedColumn . getName ( ) , false ) ) ; } else { introspectedColumn . setJavaProperty ( JavaBeansUtil . getValidPropertyName ( introspectedColumn . getName ( ) ) ) ; } // 处理注释
if ( columnCommentsMap != null && columnCommentsMap . containsKey ( introspectedColumn . getName ( ) ) ) { introspectedColumn . setRemarks ( columnCommentsMap . get ( introspectedColumn . getName ( ) ) ) ; } table . addColumn ( introspectedColumn ) ; } calculatePrimaryKey ( config , table ) ; answer . add ( table ) ; } return answer ;


signature:
public class DatabaseIntrospector { /** * 获取表名和注释映射
 * @ param config
 * @ return
 * @ throws SQLException */
protected Map < String , String > getTableComments ( DatabaseConfig config ) throws SQLException { } }

implementation: ResultSet rs = dbMetadataUtils . getDatabaseMetaData ( ) . getTables ( config . getCatalog ( ) , config . getSchemaPattern ( ) , config . getTableNamePattern ( ) , null ) ; Map < String , String > answer = new HashMap < String , String > ( ) ; while ( rs . next ( ) ) { answer . put ( rs . getString ( "TABLE_NAME" ) , rs . getString ( "REMARKS" ) ) ; } closeResultSet ( rs ) ; return answer ;


signature:
public class DatabaseIntrospector { /** * 获取表名和列名 - 注释映射
 * @ param config
 * @ return
 * @ throws SQLException */
protected Map < String , Map < String , String > > getColumnComments ( DatabaseConfig config ) throws SQLException { } }

implementation: return null ;


signature:
public class EncrypDES { /** * 加密
 * @ param str
 * @ return
 * @ throws Exception */
public static String Encrytor ( String str ) throws Exception { } }

implementation:
// 根据密钥 , 对Cipher对象进行初始化 , ENCRYPT _ MODE表示加密模式
Cipher c = getCipher ( ) ; c . init ( Cipher . ENCRYPT_MODE , deskey ) ; byte [ ] src = str . getBytes ( ) ; // 加密 , 结果保存进cipherByte
byte [ ] cipherByte = c . doFinal ( src ) ; return EncrypDES . byteArr2HexStr ( cipherByte ) ;


signature:
public class EncrypDES { /** * 解密
 * @ param str
 * @ return
 * @ throws Exception */
public static String Decryptor ( String str ) throws Exception { } }

implementation:
byte [ ] buff = EncrypDES . hexStr2ByteArr ( str ) ; // 根据密钥 , 对Cipher对象进行初始化 , DECRYPT _ MODE表示加密模式
Cipher c = getCipher ( ) ; c . init ( Cipher . DECRYPT_MODE , deskey ) ; byte [ ] cipherByte = c . doFinal ( buff ) ; return new String ( cipherByte ) ;


signature:
public class EncrypDES { /** * 将byte数组转换为表示16进制值的字符串 , 如 : byte [ ] { 8,18 } 转换为 : 0813 , 和public static byte [ ]
 * hexStr2ByteArr ( String strIn ) 互为可逆的转换过程
 * @ param arrB 需要转换的byte数组
 * @ return 转换后的字符串
 * @ throws Exception 本方法不处理任何异常 , 所有异常全部抛出 */
public static String byteArr2HexStr ( byte [ ] arrB ) throws Exception { } }

implementation:
int iLen = arrB . length ; // 每个byte用两个字符才能表示 , 所以字符串的长度是数组长度的两倍
StringBuffer sb = new StringBuffer ( iLen * 2 ) ; for ( int i = 0 ; i < iLen ; i ++ ) { int intTmp = arrB [ i ] ; // 把负数转换为正数
while ( intTmp < 0 ) { intTmp = intTmp + 256 ; } // 小于0F的数需要在前面补0
if ( intTmp < 16 ) { sb . append ( "0" ) ; } sb . append ( Integer . toString ( intTmp , 16 ) ) ; } return sb . toString ( ) ;


signature:
public class EncrypDES { /** * 将表示16进制值的字符串转换为byte数组 , 和public static String byteArr2HexStr ( byte [ ] arrB )
 * 互为可逆的转换过程
 * @ param strIn 需要转换的字符串
 * @ return 转换后的byte数组
 * @ throws Exception 本方法不处理任何异常 , 所有异常全部抛出 */
public static byte [ ] hexStr2ByteArr ( String strIn ) throws Exception { } }

implementation:
byte [ ] arrB = strIn . getBytes ( ) ; int iLen = arrB . length ; // 两个字符表示一个字节 , 所以字节数组长度是字符串长度除以2
byte [ ] arrOut = new byte [ iLen / 2 ] ; for ( int i = 0 ; i < iLen ; i = i + 2 ) { String strTmp = new String ( arrB , i , 2 ) ; arrOut [ i / 2 ] = ( byte ) Integer . parseInt ( strTmp , 16 ) ; } return arrOut ;


signature:
public class EncrypDES { /** * MD5加密
 * @ param info
 * @ return
 * @ throws Exception */
public static String Md5 ( String info ) throws Exception { } }

implementation:
// 根据MD5算法生成MessageDigest对象
MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; byte [ ] srcBytes = info . getBytes ( ) ; // 使用srcBytes更新摘要
md5 . update ( srcBytes ) ; // 完成哈希计算 , 得到result
byte [ ] resultBytes = md5 . digest ( ) ; return byteArr2HexStr ( resultBytes ) ;


signature:
public class PathAndQuery { /** * Create a { @ link Condition } that compares the current { @ link Address # getPathAndQuery ( ) } to the given pattern .
 * The given pattern may be parameterized :
 * < code >
 * / example ? { param } = foo < br >
 * / example / { param1 } ? bar = { param2 } & p = q < br >
 * < / code >
 * @ param pattern { @ link ParameterizedPattern } matching the path and query .
 * @ see ConfigurationRuleParameterBuilder # where ( String ) */
public static PathAndQuery matches ( final String pattern ) { } }

implementation: return new PathAndQuery ( pattern ) { @ Override public String toString ( ) { return "PathAndQuery.matches(\"" + pattern + "\")" ; } } ;


signature:
public class PathAndQuery { /** * Capture the entire path portion of the { @ link Address } into the given { @ link Parameter } .
 * @ param param the name of the { @ link Parameter } to which the entire path portion of the { @ link Address } will be
 * bound . */
public static PathAndQuery captureIn ( final String param ) { } }

implementation: PathAndQuery path = new PathAndQuery ( "{" + param + "}" ) { @ Override public String toString ( ) { return "PathAndQuery.captureIn(\"" + param + "\")" ; } } ; path . captureIn = param ; return path ;


signature:
public class PhaseAction { /** * Create an { @ link Operation } that invokes the given { @ link Retrieval } and processes { @ link InvocationResultHandler }
 * instances on the result value ( if any ) .
 * By default , this action is invoked after { @ link PhaseId # RESTORE _ VIEW } */
public static PhaseAction retrieveFrom ( final Retrieval retrieval ) { } }

implementation: return new PhaseAction ( null , retrieval ) { @ Override public String toString ( ) { return "PhaseAction.retrieveFrom(" + retrieval + ")" ; } } . after ( PhaseId . RESTORE_VIEW ) ;