idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
37,200 | private static SystemInputDef asSystemInputDef ( JsonValue json ) { try { SystemInputDef systemInput = null ; if ( json != null && json . getValueType ( ) == OBJECT ) { systemInput = SystemInputJson . asSystemInputDef ( ( JsonObject ) json ) ; } return systemInput ; } catch ( Exception e ) { throw new ProjectException ( "Error reading input definition" , e ) ; } } | Returns the system input definition represented by the given JSON value . |
37,201 | private static URI asSystemInputRef ( JsonValue json ) { try { URI uri = null ; if ( json != null && json . getValueType ( ) == STRING ) { uri = new URI ( ( ( JsonString ) json ) . getChars ( ) . toString ( ) ) ; } return uri ; } catch ( Exception e ) { throw new ProjectException ( "Error reading input definition" , e ) ; } } | Returns the system input definition URL represented by the given JSON value . |
37,202 | private static IGeneratorSet asGeneratorSet ( JsonValue json ) { try { IGeneratorSet generators = null ; if ( json != null && json . getValueType ( ) == OBJECT ) { generators = GeneratorSetJson . asGeneratorSet ( ( JsonObject ) json ) ; } return generators ; } catch ( Exception e ) { throw new ProjectException ( "Error reading generators" , e ) ; } } | Returns the generator set represented by the given JSON value . |
37,203 | public static JsonObject toJson ( Project project ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; Optional . ofNullable ( project . getBaseLocation ( ) ) . ifPresent ( uri -> builder . add ( REFBASE_KEY , String . valueOf ( uri ) ) ) ; if ( project . getSystemInputLocation ( ) != null ) { builder . add ( INPUTDEF_KEY , String . valueOf ( project . getSystemInputLocation ( ) ) ) ; } else if ( project . getSystemInput ( ) != null ) { builder . add ( INPUTDEF_KEY , SystemInputJson . toJson ( project . getSystemInput ( ) ) ) ; } if ( project . getGeneratorsLocation ( ) != null ) { builder . add ( GENERATORS_KEY , String . valueOf ( project . getGeneratorsLocation ( ) ) ) ; } else if ( project . getGenerators ( ) != null ) { builder . add ( GENERATORS_KEY , GeneratorSetJson . toJson ( project . getGenerators ( ) ) ) ; } if ( project . getBaseTestsLocation ( ) != null ) { builder . add ( BASETESTS_KEY , String . valueOf ( project . getBaseTestsLocation ( ) ) ) ; } else if ( project . getBaseTests ( ) != null ) { builder . add ( BASETESTS_KEY , SystemTestJson . toJson ( project . getBaseTests ( ) ) ) ; } return builder . build ( ) ; } | Returns the JSON object that represents the given project definition . |
37,204 | public void write ( IGeneratorSet generatorSet ) { writer_ . writeDeclaration ( ) ; writer_ . element ( GENERATORS_TAG ) . content ( ( ) -> { Arrays . stream ( generatorSet . getGeneratorFunctions ( ) ) . sorted ( ) . forEach ( function -> writeGenerator ( function , generatorSet . getGenerator ( function ) ) ) ; } ) . write ( ) ; } | Writes the given generator definition in the form of an XML document . |
37,205 | protected void writeCombiner ( TupleCombiner combiner ) { writer_ . element ( COMBINE_TAG ) . attribute ( TUPLES_ATR , String . valueOf ( combiner . getTupleSize ( ) ) ) . content ( ( ) -> { Arrays . stream ( combiner . getIncluded ( ) ) . sorted ( ) . forEach ( this :: writeIncluded ) ; Arrays . stream ( combiner . getExcluded ( ) ) . sorted ( ) . forEach ( this :: writeExcluded ) ; toStream ( combiner . getOnceTuples ( ) ) . forEach ( this :: writeOnceTuple ) ; } ) . write ( ) ; } | Writes the given combiner definition . |
37,206 | protected void writeOnceTuple ( TupleRef tuple ) { writer_ . element ( ONCE_TAG ) . content ( ( ) -> toStream ( tuple . getVarBindings ( ) ) . forEach ( this :: writeVarBinding ) ) . write ( ) ; } | Writes the given once - only tuple definition . |
37,207 | protected void writeVarBinding ( VarBinding binding ) { writer_ . element ( VAR_TAG ) . attribute ( NAME_ATR , binding . getVar ( ) ) . attribute ( VALUE_ATR , String . valueOf ( binding . getValue ( ) ) ) . write ( ) ; } | Writes the given variable binding definition . |
37,208 | public VarBindingDef bind ( VarDef varDef , VarValueDef valueDef ) { if ( valueDef != null && ! varDef . isApplicable ( valueDef ) ) { throw new IllegalArgumentException ( "Value=" + valueDef + " is not defined for var=" + varDef ) ; } varDef_ = varDef ; valueDef_ = valueDef ; effCondition_ = null ; return this ; } | Changes this input variable binding . |
37,209 | public ICondition getEffectiveCondition ( ) { if ( effCondition_ == null ) { effCondition_ = getValueDef ( ) . getEffectiveCondition ( getVarDef ( ) . getEffectiveCondition ( ) ) ; } return effCondition_ ; } | Returns the effective condition that defines when this binding is applicable . |
37,210 | private VarDef getNextVarDef ( ) { if ( nextVarDef_ == null ) { if ( nextVarSet_ != null && nextVarSet_ . hasNext ( ) ) { nextVarDef_ = nextVarSet_ . next ( ) ; } else { nextVarSet_ = null ; Iterator < IVarDef > members = null ; IVarDef varDef ; for ( varDef = null ; varDefs_ . hasNext ( ) && ( members = ( varDef = varDefs_ . next ( ) ) . getMembers ( ) ) != null && ! members . hasNext ( ) ; varDef = null ) ; nextVarDef_ = varDef == null ? null : members == null ? ( VarDef ) varDef : ( nextVarSet_ = new VarDefIterator ( members ) ) . next ( ) ; } } return nextVarDef_ ; } | Returns the next |
37,211 | public static IGeneratorSet asGeneratorSet ( JsonObject json ) { GeneratorSet generatorSet = new GeneratorSet ( ) ; json . keySet ( ) . stream ( ) . forEach ( function -> { try { generatorSet . addGenerator ( validFunction ( function ) , asGenerator ( json . getJsonObject ( function ) ) ) ; } catch ( GeneratorSetException e ) { throw new GeneratorSetException ( String . format ( "Error defining generator for function=%s" , function ) , e ) ; } } ) ; return generatorSet ; } | Returns the IGeneratorSet represented by the given JSON object . |
37,212 | private static TupleGenerator asGenerator ( JsonObject json ) { TupleGenerator tupleGenerator = new TupleGenerator ( ) ; Optional . ofNullable ( json . getJsonNumber ( TUPLES_KEY ) ) . ifPresent ( n -> tupleGenerator . setDefaultTupleSize ( n . intValue ( ) ) ) ; Optional . ofNullable ( json . getJsonNumber ( SEED_KEY ) ) . ifPresent ( n -> tupleGenerator . setRandomSeed ( n . longValue ( ) ) ) ; Optional . ofNullable ( json . getJsonArray ( COMBINERS_KEY ) ) . map ( combiners -> combiners . getValuesAs ( JsonObject . class ) . stream ( ) ) . orElse ( Stream . empty ( ) ) . forEach ( combiner -> tupleGenerator . addCombiner ( asCombiner ( combiner ) ) ) ; return tupleGenerator ; } | Returns the generator represented by the given JSON object . |
37,213 | private static TupleCombiner asCombiner ( JsonObject json ) { try { TupleCombiner tupleCombiner = new TupleCombiner ( ) ; Optional . ofNullable ( json . getJsonNumber ( TUPLES_KEY ) ) . ifPresent ( n -> tupleCombiner . setTupleSize ( n . intValue ( ) ) ) ; Optional . ofNullable ( json . getJsonArray ( INCLUDE_KEY ) ) . map ( includes -> includes . getValuesAs ( JsonString . class ) . stream ( ) ) . orElse ( Stream . empty ( ) ) . map ( JsonString :: getString ) . forEach ( var -> { try { try { tupleCombiner . addIncludedVar ( var ) ; } catch ( Exception e ) { throw new GeneratorSetException ( e . getMessage ( ) ) ; } } catch ( Exception e ) { throw new GeneratorSetException ( "Error defining included variables" , e ) ; } } ) ; Optional . ofNullable ( json . getJsonArray ( EXCLUDE_KEY ) ) . map ( excludes -> excludes . getValuesAs ( JsonString . class ) . stream ( ) ) . orElse ( Stream . empty ( ) ) . map ( JsonString :: getString ) . forEach ( var -> { try { try { tupleCombiner . addExcludedVar ( var ) ; } catch ( Exception e ) { throw new GeneratorSetException ( e . getMessage ( ) ) ; } } catch ( Exception e ) { throw new GeneratorSetException ( "Error defining excluded variables" , e ) ; } } ) ; Optional . ofNullable ( json . getJsonArray ( ONCE_KEY ) ) . map ( onceTuples -> onceTuples . getValuesAs ( JsonObject . class ) . stream ( ) ) . orElse ( Stream . empty ( ) ) . forEach ( onceTuple -> { try { try { tupleCombiner . addOnceTuple ( asTupleRef ( onceTuple ) ) ; } catch ( Exception e ) { throw new GeneratorSetException ( e . getMessage ( ) ) ; } } catch ( Exception e ) { throw new GeneratorSetException ( "Error defining once tuples" , e ) ; } } ) ; return tupleCombiner ; } catch ( GeneratorSetException e ) { throw new GeneratorSetException ( "Error defining combiner" , e ) ; } } | Returns the combiner represented by the given JSON object . |
37,214 | private static TupleRef asTupleRef ( JsonObject json ) { TupleRef tupleRef = new TupleRef ( ) ; json . keySet ( ) . stream ( ) . forEach ( var -> { try { tupleRef . addVarBinding ( new VarBinding ( var , ObjectUtils . toObject ( json . getString ( var ) ) ) ) ; } catch ( GeneratorSetException e ) { throw new GeneratorSetException ( String . format ( "Error adding binding for variable=%s" , var ) , e ) ; } } ) ; return tupleRef ; } | Returns the TupleRef represented by the given JSON object . |
37,215 | private static String validFunction ( String string ) { return GeneratorSet . ALL . equals ( string ) ? string : validIdentifier ( string ) ; } | Reports a GeneratorSetException if the given string is not a valid function id . Otherwise returns this string . |
37,216 | private static String validIdentifier ( String string ) { try { DefUtils . assertIdentifier ( string ) ; } catch ( Exception e ) { throw new GeneratorSetException ( e . getMessage ( ) ) ; } return string ; } | Reports a GeneratorSetException if the given string is not a valid identifier . Otherwise returns this string . |
37,217 | public static JsonObject toJson ( IGeneratorSet generatorSet ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; for ( String function : generatorSet . getGeneratorFunctions ( ) ) { builder . add ( function , toJson ( generatorSet . getGenerator ( function ) ) ) ; } return builder . build ( ) ; } | Returns the JSON object that represents the given generator set . |
37,218 | private static JsonStructure toJson ( ITestCaseGenerator generator ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; if ( generator . getClass ( ) . equals ( TupleGenerator . class ) ) { TupleGenerator tupleGenerator = ( TupleGenerator ) generator ; builder . add ( TUPLES_KEY , tupleGenerator . getDefaultTupleSize ( ) ) ; Optional . ofNullable ( tupleGenerator . getRandomSeed ( ) ) . ifPresent ( seed -> builder . add ( SEED_KEY , seed ) ) ; JsonArrayBuilder combinersBuilder = Json . createArrayBuilder ( ) ; tupleGenerator . getCombiners ( ) . stream ( ) . forEach ( combiner -> combinersBuilder . add ( toJson ( combiner ) ) ) ; JsonArray combiners = combinersBuilder . build ( ) ; if ( ! combiners . isEmpty ( ) ) { builder . add ( COMBINERS_KEY , combiners ) ; } } return builder . build ( ) ; } | Returns the JSON object that represents the given generator . |
37,219 | private static JsonStructure toJson ( TupleCombiner combiner ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; builder . add ( TUPLES_KEY , combiner . getTupleSize ( ) ) ; JsonArrayBuilder includeBuilder = Json . createArrayBuilder ( ) ; Arrays . stream ( combiner . getIncluded ( ) ) . forEach ( var -> includeBuilder . add ( var ) ) ; JsonArray include = includeBuilder . build ( ) ; if ( ! include . isEmpty ( ) ) { builder . add ( INCLUDE_KEY , include ) ; } JsonArrayBuilder excludeBuilder = Json . createArrayBuilder ( ) ; Arrays . stream ( combiner . getExcluded ( ) ) . forEach ( var -> excludeBuilder . add ( var ) ) ; JsonArray exclude = excludeBuilder . build ( ) ; if ( ! exclude . isEmpty ( ) ) { builder . add ( EXCLUDE_KEY , exclude ) ; } JsonArrayBuilder onceBuilder = Json . createArrayBuilder ( ) ; toStream ( combiner . getOnceTuples ( ) ) . forEach ( tuple -> onceBuilder . add ( toJson ( tuple ) ) ) ; JsonArray once = onceBuilder . build ( ) ; if ( ! once . isEmpty ( ) ) { builder . add ( ONCE_KEY , once ) ; } return builder . build ( ) ; } | Returns the JSON object that represents the given combiner . |
37,220 | private static JsonStructure toJson ( TupleRef tuple ) { JsonObjectBuilder builder = Json . createObjectBuilder ( ) ; toStream ( tuple . getVarBindings ( ) ) . forEach ( binding -> builder . add ( binding . getVar ( ) , String . valueOf ( binding . getValue ( ) ) ) ) ; return builder . build ( ) ; } | Returns the JSON object that represents the given once tuple . |
37,221 | public static Object toObject ( String value ) { return toObject ( value , ObjectUtils :: toBoolean , ObjectUtils :: toNumber , ObjectUtils :: toExternalString ) ; } | Returns the object represented by the given string . |
37,222 | public static Object toExternalObject ( Object value ) { return Optional . ofNullable ( toExternalNumber ( value ) ) . orElse ( toObject ( String . valueOf ( value ) ) ) ; } | Returns an object equal to the external form of the given value . |
37,223 | private static < T > Object toObject ( T value , Function < T , Object > ... converters ) { return Stream . of ( converters ) . map ( converter -> converter . apply ( value ) ) . filter ( Objects :: nonNull ) . findFirst ( ) . orElse ( null ) ; } | Returns the first non - null object produced by the given converters . Returns null if no such object found . |
37,224 | private static Object toBoolean ( String value ) { return "true" . equalsIgnoreCase ( value ) ? Boolean . TRUE : "false" . equalsIgnoreCase ( value ) ? Boolean . FALSE : null ; } | Returns the Boolean represented by the given string or null if not a boolean value . |
37,225 | private static Object toNumber ( String value ) { Object number ; try { number = toExternalNumber ( new BigDecimal ( value ) ) ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Number represented by the given string or null if not a numeric value . |
37,226 | private static Object toInt ( BigDecimal value ) { Object number ; try { number = value . scale ( ) == 0 ? Integer . valueOf ( value . intValueExact ( ) ) : null ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Integer represented by the given value or null if not an integer value . |
37,227 | private static Object toLong ( BigDecimal value ) { Object number ; try { number = value . scale ( ) == 0 ? Long . valueOf ( value . longValueExact ( ) ) : null ; } catch ( Exception e ) { number = null ; } return number ; } | Returns the Long represented by the given value or null if not an long value . |
37,228 | private static Object toExternalNumber ( Object value ) { Class < ? > valueType = value == null ? null : value . getClass ( ) ; return ! ( valueType != null && Number . class . isAssignableFrom ( valueType ) ) ? null : valueType . equals ( BigDecimal . class ) ? toExternalNumber ( ( BigDecimal ) value ) : valueType . equals ( Long . class ) ? toExternalNumber ( new BigDecimal ( ( Long ) value ) ) : value ; } | If the given value is a number returns an object equal to its external form . Otherwise returns null . |
37,229 | private static Object toExternalNumber ( BigDecimal number ) { return Optional . ofNullable ( toObject ( number , ObjectUtils :: toInt , ObjectUtils :: toLong ) ) . orElse ( number ) ; } | Returns an object equal to the external form of the given number value . |
37,230 | public String getPathName ( ) { if ( pathName_ == null ) { StringBuilder pathName = new StringBuilder ( ) ; IVarDef parent = getParent ( ) ; if ( parent != null ) { pathName . append ( parent . getPathName ( ) ) . append ( '.' ) ; } String name = getName ( ) ; if ( name != null ) { pathName . append ( name ) ; } pathName_ = pathName . toString ( ) ; } return pathName_ ; } | Returns the hierarchical path name of this variable . |
37,231 | public String getType ( ) { IVarDef parent = getParent ( ) ; return parent == null ? type_ : parent . getType ( ) ; } | Returns the type identifier for this variable . |
37,232 | public ICondition getEffectiveCondition ( ) { if ( effCondition_ == null ) { effCondition_ = getEffectiveCondition ( Optional . ofNullable ( getParent ( ) ) . map ( IVarDef :: getEffectiveCondition ) . orElse ( null ) ) ; } return effCondition_ ; } | Returns the effective condition that defines when this variable is applicable based on the conditions for this variable and all of its ancestors . |
37,233 | public IVarDef . Position getPosition ( ) { if ( position_ == null ) { setPosition ( new Position ( getParent ( ) , seqNum_ ) ) ; } return position_ ; } | Returns the position of this variable definition . |
37,234 | protected void writeAttribute ( String name , String value ) { print ( " " ) ; print ( name ) ; print ( "=\"" ) ; print ( NumericEntityEscaper . below ( 0x20 ) . translate ( StringEscapeUtils . escapeXml11 ( value ) ) ) ; print ( "\"" ) ; } | Writes an attribute definition . |
37,235 | public boolean matches ( VarNamePattern varName ) { boolean matched = varName != null && ( varName . varNamePath_ == null ) == ( varNamePath_ == null ) && ! varName . wildcard_ && varName . minDepth_ >= minDepth_ ; if ( matched && varNamePath_ != null ) { int i ; for ( i = 0 ; i < minDepth_ && ( matched = varName . varNamePath_ [ i ] . equals ( varNamePath_ [ i ] ) ) ; i ++ ) ; if ( matched ) { int membersLeft = varName . minDepth_ - minDepth_ ; String wildcardType = ! wildcard_ ? null : varNamePath_ [ i ] ; matched = wildcardType == null ? ( membersLeft == 0 ) : ( ( membersLeft == 1 && wildcardType . equals ( ALL_CHILDREN ) ) || wildcardType . equals ( ALL_DESCENDANTS ) ) ; } } return matched ; } | Returns true if the given variable name matches this pattern . |
37,236 | public boolean isValid ( ) { boolean valid = varNamePath_ != null ; if ( valid ) { int i ; for ( i = 0 ; i < varNamePath_ . length && DefUtils . isIdentifier ( varNamePath_ [ i ] ) ; i ++ ) ; int membersLeft = varNamePath_ . length - i ; valid = membersLeft == 0 || ( membersLeft == 1 && ( varNamePath_ [ i ] . equals ( ALL_DESCENDANTS ) || varNamePath_ [ i ] . equals ( ALL_CHILDREN ) ) ) ; } return valid ; } | Returns true if this pattern is valid . |
37,237 | private boolean isApplicable ( Iterator < IVarDef > varDefs ) { boolean applicable = false ; while ( varDefs . hasNext ( ) && ! ( applicable = isApplicable ( varDefs . next ( ) ) ) ) ; return applicable ; } | Returns true if this pattern is applicable to the given set of variables . |
37,238 | private boolean isApplicable ( IVarDef var ) { Iterator < IVarDef > members = var . getMembers ( ) ; return members == null ? matches ( var . getPathName ( ) ) : isApplicable ( members ) ; } | Returns true if this pattern is applicable to the given variable . |
37,239 | public static IConjunct negate ( IConjunct conjunct ) { AnyOf anyOf = new AnyOf ( ) ; for ( Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { Conjunction conjunction = new Conjunction ( ) ; for ( Iterator < IAssertion > assertions = disjuncts . next ( ) . getAssertions ( ) ; assertions . hasNext ( ) ; ) { conjunction . add ( assertions . next ( ) . negate ( ) ) ; } anyOf . add ( simplify ( conjunction ) ) ; } return Cnf . convert ( anyOf ) ; } | Returns the negation of the given CNF condition . |
37,240 | public static IConjunct either ( IConjunct conjunct1 , IConjunct conjunct2 ) { IConjunct conjunct ; if ( conjunct1 . getDisjunctCount ( ) == 0 ) { conjunct = conjunct2 ; } else if ( conjunct2 . getDisjunctCount ( ) == 0 ) { conjunct = conjunct1 ; } else { Conjunction conjunction = new Conjunction ( ) ; for ( Iterator < IDisjunct > disjuncts1 = conjunct1 . getDisjuncts ( ) ; disjuncts1 . hasNext ( ) ; ) { IDisjunct disjunct1 = disjuncts1 . next ( ) ; for ( Iterator < IDisjunct > disjuncts2 = conjunct2 . getDisjuncts ( ) ; disjuncts2 . hasNext ( ) ; ) { IDisjunct disjunct = new Disjunction ( disjunct1 , disjuncts2 . next ( ) ) ; if ( ! isTautology ( disjunct ) ) { conjunction . add ( simplify ( disjunct ) ) ; } } } conjunct = simplify ( conjunction ) ; } return conjunct ; } | Returns the logical OR of the given CNF conditions . |
37,241 | public static IConjunct refactor ( IConjunct conjunct ) { Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; IAssertion assertion = null ; while ( disjuncts . hasNext ( ) && ( assertion = toAssertion ( disjuncts . next ( ) ) ) == null ) ; return assertion == null ? conjunct : simplify ( new Conjunction ( assertion ) . append ( refactor ( remainder ( conjunct , assertion ) ) ) ) ; } | Return refactored conjunction formed by removing superfluous terms . |
37,242 | public static IConjunct remainder ( IConjunct conjunct , IAssertion assertion ) { Conjunction rest = new Conjunction ( ) ; for ( Iterator < IDisjunct > disjuncts = conjunct . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { IDisjunct disjunct = disjuncts . next ( ) ; if ( ! disjunct . contains ( assertion ) ) { rest . add ( disjunct ) ; } } return rest ; } | Returns the remainder after removing all terms that contain the given assertion . |
37,243 | public static IAssertion toAssertion ( IDisjunct disjunct ) { return disjunct . getAssertionCount ( ) == 1 ? disjunct . getAssertions ( ) . next ( ) : null ; } | If the given disjunction consists of a single assertion returns the equivalent assertion . Otherwise return null . |
37,244 | public static IConjunct simplify ( IConjunct conjunct ) { return conjunct . getDisjunctCount ( ) == 1 ? conjunct . getDisjuncts ( ) . next ( ) : conjunct ; } | Returns the simple form of the given conjunction . |
37,245 | public static IDisjunct simplify ( IDisjunct disjunct ) { IAssertion assertion = toAssertion ( disjunct ) ; return assertion == null ? disjunct : assertion ; } | Returns the simple form of the given disjunction . |
37,246 | public static boolean isTautology ( IDisjunct disjunct ) { boolean tautology = false ; if ( disjunct != null ) { IAssertion [ ] assertions = IteratorUtils . toArray ( disjunct . getAssertions ( ) , IAssertion . class ) ; int max = assertions . length ; int maxCompared = max - 1 ; for ( int compared = 0 ; ! tautology && compared < maxCompared ; compared ++ ) { IAssertion assertCompared = assertions [ compared ] ; for ( int other = compared + 1 ; ! tautology && other < max ; tautology = assertCompared . negates ( assertions [ other ++ ] ) ) ; } } return tautology ; } | Returns true if the given disjunction is universally true . |
37,247 | public static boolean satisfiesSome ( IConjunct condition , PropertySet properties ) { boolean satisfies ; Iterator < IDisjunct > disjuncts ; for ( disjuncts = condition . getDisjuncts ( ) , satisfies = ! disjuncts . hasNext ( ) ; ! satisfies && disjuncts . hasNext ( ) ; satisfies = disjuncts . next ( ) . satisfied ( properties ) ) ; return satisfies ; } | Returns true if the given properties partially satisfy the given condition . |
37,248 | public static IConjunct getUnsatisfied ( IConjunct condition , PropertySet properties ) { Conjunction unsatisfied = new Conjunction ( ) ; for ( Iterator < IDisjunct > disjuncts = condition . getDisjuncts ( ) ; disjuncts . hasNext ( ) ; ) { IDisjunct disjunct = disjuncts . next ( ) ; if ( ! disjunct . satisfied ( properties ) ) { unsatisfied . add ( disjunct ) ; } } return unsatisfied ; } | Returns the part of the given condition unsatisfied by the given properties . |
37,249 | public FunctionInputDef addVarDef ( IVarDef varDef ) { assert varDef != null ; assert varDef . getName ( ) != null ; if ( findVarDef ( varDef . getName ( ) ) >= 0 ) { throw new IllegalStateException ( "Variable=" + varDef . getName ( ) + " already defined for function=" + getName ( ) ) ; } vars_ . add ( varDef ) ; return this ; } | Adds a new variable definition . |
37,250 | public FunctionInputDef removeVarDef ( String name ) { int i = findVarDef ( name ) ; if ( i >= 0 ) { vars_ . remove ( i ) ; } return this ; } | Removes a variable definition . |
37,251 | public IVarDef getVarDef ( String name ) { int i = findVarDef ( name ) ; return i >= 0 ? vars_ . get ( i ) : null ; } | Returns the variable definition with the given name . |
37,252 | protected int findVarDef ( String name ) { int varCount = name == null ? 0 : vars_ . size ( ) ; int i ; for ( i = 0 ; i < varCount && ! name . equals ( vars_ . get ( i ) . getName ( ) ) ; i ++ ) ; return i < varCount ? i : - 1 ; } | Returns the index of the variable definition with the given name . |
37,253 | public IVarDef findVarPath ( String pathName ) { String [ ] path = DefUtils . toPath ( pathName ) ; IVarDef var ; return path == null ? null : ( var = getVarDef ( StringUtils . trimToNull ( path [ 0 ] ) ) ) == null ? null : var . find ( Arrays . copyOfRange ( path , 1 , path . length ) ) ; } | Returns the variable definition with the given path name . |
37,254 | public VarDef findVarDefPath ( String pathName ) { IVarDef var = findVarPath ( pathName ) ; return var != null && var . getClass ( ) . equals ( VarDef . class ) ? ( VarDef ) var : null ; } | Returns the individual variable definition with the given path name . |
37,255 | public void addConfiguredParam ( Parameter param ) { options_ . getTransformParams ( ) . put ( param . getName ( ) , param . getValue ( ) ) ; } | Adds a transform parameter . |
37,256 | public void setTransformDef ( File transformDef ) { options_ . setTransformDef ( transformDef ) ; if ( transformDef != null ) { options_ . setTransformType ( Options . TransformType . CUSTOM ) ; } } | Changes the transform file . |
37,257 | public static VarBinding create ( IVarDef varDef , VarValueDef valueDef ) { VarBinding binding = valueDef . isNA ( ) ? new VarNaBinding ( varDef . getPathName ( ) , varDef . getType ( ) ) : new VarBinding ( varDef . getPathName ( ) , varDef . getType ( ) , valueDef . getName ( ) ) ; binding . setValueValid ( valueDef . isValid ( ) ) ; binding . setVarDef ( varDef ) ; return binding ; } | Creates a new VarBinding object . |
37,258 | public static String getProjectName ( File inputDefFile ) { String projectName = null ; if ( inputDefFile != null ) { String inputBase = FilenameUtils . getBaseName ( inputDefFile . getName ( ) ) ; projectName = inputBase . toLowerCase ( ) . endsWith ( "-input" ) ? inputBase . substring ( 0 , inputBase . length ( ) - "-input" . length ( ) ) : inputBase ; } return projectName ; } | Returns the name of the project for the given input definition file . |
37,259 | public static String getVersion ( ) { Properties tcasesProperties = new Properties ( ) ; String tcasesPropertyFileName = "/tcases.properties" ; InputStream tcasesPropertyFile = null ; try { tcasesPropertyFile = Tcases . class . getResourceAsStream ( tcasesPropertyFileName ) ; tcasesProperties . load ( tcasesPropertyFile ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't read " + tcasesPropertyFileName , e ) ; } finally { IOUtils . closeQuietly ( tcasesPropertyFile ) ; } return "Tcases " + tcasesProperties . getProperty ( "tcases.version" ) + " (" + tcasesProperties . getProperty ( "tcases.date" ) + ")" ; } | Returns a description of the current version . |
37,260 | public static Map < String , Collection < VarBindingDef > > getPropertySources ( FunctionInputDef function ) { SetValuedMap < String , VarBindingDef > sources = MultiMapUtils . newSetValuedHashMap ( ) ; toStream ( new VarDefIterator ( function ) ) . flatMap ( var -> toStream ( var . getValues ( ) ) . map ( value -> new VarBindingDef ( var , value ) ) ) . forEach ( binding -> toStream ( binding . getValueDef ( ) . getProperties ( ) ) . forEach ( p -> sources . put ( p , binding ) ) ) ; return sources . asMap ( ) ; } | Maps every property in the given function input definition to the variable value definitions that contribute it . |
37,261 | public static Map < String , Collection < IConditional > > getPropertyReferences ( FunctionInputDef function ) { SetValuedMap < String , IConditional > refs = MultiMapUtils . newSetValuedHashMap ( ) ; conditionals ( function ) . forEach ( conditional -> propertiesReferenced ( conditional . getCondition ( ) ) . forEach ( p -> refs . put ( p , conditional ) ) ) ; return refs . asMap ( ) ; } | Maps every property in the given FunctionInputDef to the conditional elements that reference it . |
37,262 | public static Map < String , Collection < VarBindingDef > > getPropertiesUnused ( FunctionInputDef function ) { Map < String , Collection < VarBindingDef > > sources = getPropertySources ( function ) ; Collection < String > unused = CollectionUtils . subtract ( sources . keySet ( ) , getPropertyReferences ( function ) . keySet ( ) ) ; return sources . entrySet ( ) . stream ( ) . filter ( entry -> unused . contains ( entry . getKey ( ) ) ) . collect ( toMap ( entry -> entry . getKey ( ) , entry -> entry . getValue ( ) ) ) ; } | For every property in the given function input definition that is defined but never referenced maps the property to the variable value definitions that contribute it . |
37,263 | public static Map < String , Collection < IConditional > > getPropertiesUndefined ( FunctionInputDef function ) { Map < String , Collection < IConditional > > refs = getPropertyReferences ( function ) ; Collection < String > undefined = CollectionUtils . subtract ( refs . keySet ( ) , getPropertySources ( function ) . keySet ( ) ) ; return refs . entrySet ( ) . stream ( ) . filter ( entry -> undefined . contains ( entry . getKey ( ) ) ) . collect ( toMap ( entry -> entry . getKey ( ) , entry -> entry . getValue ( ) ) ) ; } | For every property in the given function input definition that is referenced but never defined maps the property to the conditional elements that reference it . |
37,264 | public static String getReferenceName ( IConditional conditional ) { return conditional instanceof IVarDef ? String . format ( "variable=%s" , ( ( IVarDef ) conditional ) . getPathName ( ) ) : conditional instanceof VarBindingDef ? String . format ( "variable=%s, value=%s" , ( ( VarBindingDef ) conditional ) . getVarDef ( ) . getPathName ( ) , String . valueOf ( ( ( VarBindingDef ) conditional ) . getValueDef ( ) . getName ( ) ) ) : null ; } | Returns the full reference name for the given IConditional . |
37,265 | private static Stream < IConditional > conditionals ( FunctionInputDef function ) { return toStream ( function . getVarDefs ( ) ) . flatMap ( var -> conditionals ( var ) ) ; } | Returns the IConditional instances defined by the given function input definition . |
37,266 | private static Stream < IConditional > conditionals ( IVarDef var ) { return Stream . concat ( Stream . of ( var ) , Stream . concat ( Optional . ofNullable ( var . getMembers ( ) ) . map ( members -> toStream ( members ) . flatMap ( member -> conditionals ( member ) ) ) . orElse ( Stream . empty ( ) ) , Optional . ofNullable ( var . getValues ( ) ) . map ( values -> toStream ( values ) . map ( value -> new VarBindingDef ( ( VarDef ) var , value ) ) ) . orElse ( Stream . empty ( ) ) ) ) ; } | Returns the IConditional instances defined by the given variable definition . |
37,267 | public static < K , V > MapBuilder < K , V > of ( K key , V value ) { return new MapBuilder < K , V > ( ) . put ( key , value ) ; } | Returns a new MapBuilder with the given entry . |
37,268 | public MapBuilder < K , V > put ( K key , V value ) { map_ . put ( key , value ) ; return this ; } | Adds an entry to the map for this builder . |
37,269 | public MapBuilder < K , V > putIf ( K key , Optional < V > value ) { value . ifPresent ( v -> map_ . put ( key , v ) ) ; return this ; } | Adds an entry to the map for this builder if the given value is present . |
37,270 | public < T > List < T > reorder ( List < T > sequence ) { int elementCount = sequence . size ( ) ; if ( elementCount > 1 ) { List < T > elements = new ArrayList < T > ( sequence ) ; sequence . clear ( ) ; for ( ; elementCount > 0 ; elementCount -- ) { sequence . add ( elements . remove ( generator_ . nextInt ( elementCount ) ) ) ; } } return sequence ; } | Returns the given list with its elements rearranged in a random order . |
37,271 | public < T > Iterator < T > reorder ( Iterator < T > sequence ) { return reorder ( IteratorUtils . toList ( sequence ) ) . iterator ( ) ; } | Returns an iterator that visits the elements of the given sequence in a random order . |
37,272 | public void setTupleSize ( int tupleSize ) { Integer onceSize = onceTuples_ . isEmpty ( ) ? null : getOnceTuples ( ) . next ( ) . size ( ) ; if ( ! ( onceSize == null || onceSize == tupleSize ) ) { throw new IllegalArgumentException ( "Tuple size=" + tupleSize + " is not compatible with existing once-only tuple size=" + onceSize ) ; } tupleSize_ = tupleSize ; } | Changes the tuple size for input variable combinations . A non - positive tupleSize specifies all permutations . |
37,273 | public String [ ] getIncluded ( ) { return IteratorUtils . toArray ( IteratorUtils . transformedIterator ( includedVars_ . iterator ( ) , VarNamePattern :: toString ) , String . class ) ; } | Returns the set of input variables to be included in this combination . |
37,274 | public String [ ] getExcluded ( ) { return IteratorUtils . toArray ( IteratorUtils . transformedIterator ( excludedVars_ . iterator ( ) , VarNamePattern :: toString ) , String . class ) ; } | Returns the set of input variables to be excluded from this combination . |
37,275 | public TupleCombiner addOnceTuple ( TupleRef tupleRef ) { if ( tupleRef != null ) { if ( tupleRef . size ( ) != getTupleSize ( ) ) { throw new IllegalArgumentException ( "Once-only tuple=" + tupleRef + " has size=" + tupleRef . size ( ) + ", expected size=" + getTupleSize ( ) ) ; } onceTuples_ . add ( tupleRef ) ; } return this ; } | Adds a once - only tuple to this combination . |
37,276 | public Collection < Tuple > getTuples ( FunctionInputDef inputDef ) { List < VarDef > combinedVars = getCombinedVars ( inputDef ) ; return getCombinedTuples ( combinedVars , getTuples ( combinedVars , getTupleSize ( ) ) ) ; } | Returns all valid N - tuples of values for the included input variables . |
37,277 | public static Collection < Tuple > getTuples ( List < VarDef > varDefs , int tupleSize ) { if ( tupleSize < 1 ) { tupleSize = varDefs . size ( ) ; } int varEnd = varDefs . size ( ) - tupleSize + 1 ; if ( varEnd <= 0 ) { throw new IllegalArgumentException ( "Can't create " + tupleSize + "-tuples for " + varDefs . size ( ) + " combined variables" ) ; } return getTuples ( varDefs , 0 , varEnd , tupleSize ) ; } | Returns all valid N - tuples of values for the given input variables . A non - positive tupleSize specifies all permutations . |
37,278 | private static Collection < Tuple > getTuples ( List < VarDef > varDefs , int varStart , int varEnd , int tupleSize ) { Collection < Tuple > tuples = new ArrayList < Tuple > ( ) ; for ( int i = varStart ; i < varEnd ; i ++ ) { VarDef nextVar = varDefs . get ( i ) ; Iterator < VarValueDef > values = nextVar . getValidValues ( ) ; if ( ! values . hasNext ( ) ) { throw new IllegalStateException ( "Can't complete tuples -- no valid values defined for var=" + nextVar ) ; } Collection < Tuple > subTuples = tupleSize == 1 ? null : getTuples ( varDefs , i + 1 , varEnd + 1 , tupleSize - 1 ) ; if ( subTuples == null ) { while ( values . hasNext ( ) ) { tuples . add ( new Tuple ( new VarBindingDef ( nextVar , values . next ( ) ) ) ) ; } } else if ( ! subTuples . isEmpty ( ) ) { while ( values . hasNext ( ) ) { VarBindingDef nextBinding = new VarBindingDef ( nextVar , values . next ( ) ) ; for ( Tuple subTuple : subTuples ) { Tuple nextTuple = new Tuple ( nextBinding ) . addAll ( subTuple ) ; if ( nextTuple . isCompatible ( ) ) { tuples . add ( nextTuple ) ; } } } } } return tuples ; } | Returns all valid tuples of values for the given input variables . |
37,279 | private Collection < Tuple > getCombinedTuples ( List < VarDef > combinedVars , Collection < Tuple > tuples ) { Set < Tuple > onceTuples = getOnceTupleDefs ( combinedVars ) ; if ( ! onceTuples . isEmpty ( ) ) { for ( Tuple tuple : tuples ) { tuple . setOnce ( onceTuples . contains ( tuple ) ) ; } } return tuples ; } | Returns all fully - combined N - tuples of values for the included input variables . |
37,280 | private Set < Tuple > getOnceTupleDefs ( final List < VarDef > combinedVars ) { try { return new HashSet < Tuple > ( IteratorUtils . toList ( IteratorUtils . transformedIterator ( getOnceTuples ( ) , tupleRef -> toTuple ( combinedVars , tupleRef ) ) ) ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Invalid once-only tuple definition" , e ) ; } } | Returns the set of once - only tuple definitions for this combiner . |
37,281 | private Tuple toTuple ( List < VarDef > combinedVars , TupleRef tupleRef ) { if ( tupleRef . size ( ) != getTupleSize ( ) ) { throw new IllegalStateException ( String . valueOf ( tupleRef ) + " does not match combiner tuple size=" + getTupleSize ( ) ) ; } Tuple tuple = new Tuple ( ) ; for ( Iterator < VarBinding > bindings = tupleRef . getVarBindings ( ) ; bindings . hasNext ( ) ; ) { VarBinding binding = bindings . next ( ) ; VarDef var = findVarPath ( combinedVars , binding . getVar ( ) ) ; if ( var == null ) { throw new IllegalStateException ( "Var=" + binding . getVar ( ) + " is not included in this combination" ) ; } VarValueDef value = var . getValue ( binding . getValue ( ) ) ; if ( value == null ) { throw new IllegalStateException ( "Value=" + binding . getValue ( ) + " is not defined for var=" + binding . getVar ( ) ) ; } if ( ! value . isValid ( ) ) { throw new IllegalStateException ( "Value=" + binding . getValue ( ) + " is a failure value for var=" + binding . getVar ( ) ) ; } tuple . add ( new VarBindingDef ( var , value ) ) ; } return tuple ; } | Converts a reference to a tuple of combined variables . |
37,282 | private VarDef findVarPath ( List < VarDef > combinedVars , String varPath ) { int i ; for ( i = 0 ; i < combinedVars . size ( ) && ! varPath . equals ( combinedVars . get ( i ) . getPathName ( ) ) ; i ++ ) ; return i < combinedVars . size ( ) ? combinedVars . get ( i ) : null ; } | Returns the member of the given variable list with the given path . |
37,283 | public List < VarDef > getCombinedVars ( FunctionInputDef inputDef ) { assertApplicable ( inputDef ) ; List < VarDef > combinedVars = new ArrayList < VarDef > ( ) ; for ( VarDefIterator varDefs = new VarDefIterator ( inputDef ) ; varDefs . hasNext ( ) ; ) { VarDef varDef = varDefs . next ( ) ; if ( isEligible ( varDef ) ) { combinedVars . add ( varDef ) ; } } if ( combinedVars . size ( ) < getTupleSize ( ) ) { throw new IllegalStateException ( "Can't return " + getTupleSize ( ) + "-tuples for " + inputDef + ": only " + combinedVars . size ( ) + " variables eligible for combination" ) ; } return combinedVars ; } | Returns the set of input variables to be combined . |
37,284 | private boolean isExcluded ( VarNamePattern varNamePath ) { boolean excluded = false ; Iterator < VarNamePattern > excludedVars = getExcludedVars ( ) . iterator ( ) ; while ( excludedVars . hasNext ( ) && ! ( excluded = excludedVars . next ( ) . matches ( varNamePath ) ) ) ; return excluded ; } | Returns true if the given variable matches any excluded input variable . |
37,285 | private boolean isIncluded ( VarNamePattern varNamePath ) { boolean included = getIncludedVars ( ) . isEmpty ( ) ; if ( ! included ) { Iterator < VarNamePattern > includedVars = getIncludedVars ( ) . iterator ( ) ; while ( includedVars . hasNext ( ) && ! ( included = includedVars . next ( ) . matches ( varNamePath ) ) ) ; } return included ; } | Returns true if the given variable matches any included input variable . |
37,286 | private void assertApplicable ( FunctionInputDef inputDef , VarNamePattern varNamePattern ) throws IllegalArgumentException { if ( ! varNamePattern . isApplicable ( inputDef ) ) { throw new IllegalArgumentException ( "Can't find variable matching pattern=" + varNamePattern ) ; } } | Throws an exception if the given variable pattern is not applicable to the given input definition . |
37,287 | public boolean isEligible ( IVarDef varDef ) { VarNamePattern varNamePath = new VarNamePattern ( varDef . getPathName ( ) ) ; return ! isExcluded ( varNamePath ) && isIncluded ( varNamePath ) ; } | Returns true if the given input variable is eligible to be combined . |
37,288 | public void setTarget ( File target ) { try { OutputStream targetStream = target == null ? null : new FileOutputStream ( target ) ; setTarget ( targetStream ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't create target stream" , e ) ; } } | Changes the target for filter output . |
37,289 | private OutputStream initializeSource ( ) { try { PipedOutputStream pipeOut = new PipedOutputStream ( ) ; PipedInputStream pipeIn = new PipedInputStream ( pipeOut ) ; filterInput_ = pipeIn ; return new FilterSourceStream ( pipeOut ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't initialize source stream" , e ) ; } } | Initializes the source for filter input . |
37,290 | protected OutputStream getFilterOutput ( ) { OutputStream target = getTarget ( ) ; return target == null ? System . out : target ; } | Returns the stream that provides output from the filter . |
37,291 | private void start ( ) { try { initializeFilter ( getFilterInput ( ) , getFilterOutput ( ) ) ; failure_ = null ; thread_ = new Thread ( this , String . valueOf ( this ) ) ; thread_ . start ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't start filtering" , e ) ; } } | Starts filter output . |
37,292 | public void close ( ) { IOUtils . closeQuietly ( source_ ) ; try { complete ( ) ; } catch ( Exception e ) { logger_ . error ( "Can't complete filtering" , e ) ; } } | Terminates filter output . |
37,293 | private void complete ( ) throws IOException { if ( source_ != null ) { try { thread_ . join ( ) ; } catch ( Exception e ) { logger_ . error ( "Thread=" + thread_ + " not completed" , e ) ; } IOException failure = failure_ == null ? null : new IOException ( "Can't write filter output" , failure_ ) ; failure_ = null ; filterInput_ = null ; source_ = null ; target_ = null ; thread_ = null ; if ( failure != null ) { throw failure ; } } } | Completes filter output . |
37,294 | public void setCondition ( ICondition condition ) { super . setCondition ( condition ) ; if ( members_ != null ) { for ( IVarDef member : members_ ) { member . setParent ( this ) ; } } } | Changes the condition that defines when this element is applicable . |
37,295 | public IVarDef find ( String ... path ) { return path == null || path . length == 0 ? this : getDescendant ( path ) ; } | Returns the descendant variable with the given name path relative to this variable . |
37,296 | public VarSet addMember ( IVarDef var ) { assert var != null ; assert var . getName ( ) != null ; if ( findMember ( var . getName ( ) ) >= 0 ) { throw new IllegalStateException ( "Member=" + var . getName ( ) + " already defined for varSet=" + getPathName ( ) ) ; } members_ . add ( var ) ; var . setParent ( this ) ; var . setSeqNum ( getNextSeqNum ( ) ) ; return this ; } | Adds an input variable to this set . |
37,297 | public VarSet removeMember ( String name ) { int i = findMember ( name ) ; if ( i >= 0 ) { members_ . remove ( i ) . setParent ( null ) ; } return this ; } | Removes an input variable from this set . |
37,298 | public IVarDef getMember ( String name ) { int i = findMember ( name ) ; return i >= 0 ? members_ . get ( i ) : null ; } | Returns the member variable with the given name . |
37,299 | private IVarDef getDescendant ( String [ ] path ) { int pathLength = path == null ? 0 : path . length ; int parentPathLength = pathLength - 1 ; int i ; VarSet parent ; IVarDef descendant ; for ( i = 0 , parent = this , descendant = null ; i < parentPathLength && ( descendant = parent . getMember ( StringUtils . trimToNull ( path [ i ] ) ) ) != null && descendant . getClass ( ) . equals ( getClass ( ) ) ; i ++ , parent = ( VarSet ) descendant ) ; return i == parentPathLength ? parent . getMember ( StringUtils . trimToNull ( path [ i ] ) ) : null ; } | Returns the descendant variable with the given path relative to this set . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.