idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,000
public static boolean [ ] [ ] cloneAdjacencyMarix ( boolean [ ] [ ] src ) { int length = src . length ; boolean [ ] [ ] target = new boolean [ length ] [ src [ 0 ] . length ] ; for ( int i = 0 ; i < length ; i ++ ) { System . arraycopy ( src [ i ] , 0 , target [ i ] , 0 , src [ i ] . length ) ; } return target ; }
Clones the provided array
8,001
public void mapNodeToCliqueFamily ( OpenBitSet [ ] varNodeToCliques , JunctionTreeClique [ ] jtNodes ) { for ( int i = 0 ; i < varNodeToCliques . length ; i ++ ) { GraphNode < BayesVariable > varNode = graph . getNode ( i ) ; OpenBitSet parents = new OpenBitSet ( ) ; int count = 0 ; for ( Edge edge : varNode . getInEdg...
Given the set of cliques mapped via ID in a Bitset for a given bayes node Find the best clique . Where best clique is one that contains all it s parents with the smallest number of nodes in that clique . When there are no parents then simply pick the clique with the smallest number nodes .
8,002
public void mapVarNodeToCliques ( OpenBitSet [ ] nodeToCliques , int id , OpenBitSet clique ) { for ( int i = clique . nextSetBit ( 0 ) ; i >= 0 ; i = clique . nextSetBit ( i + 1 ) ) { OpenBitSet cliques = nodeToCliques [ i ] ; if ( cliques == null ) { cliques = new OpenBitSet ( ) ; nodeToCliques [ i ] = cliques ; } cl...
Maps each Bayes node to cliques it s in . It uses a BitSet to map the ID of the cliques
8,003
public static String convertDTCellValueToString ( DTCellValue52 dcv ) { switch ( dcv . getDataType ( ) ) { case BOOLEAN : Boolean booleanValue = dcv . getBooleanValue ( ) ; return ( booleanValue == null ? null : booleanValue . toString ( ) ) ; case DATE : Date dateValue = dcv . getDateValue ( ) ; return ( dateValue == ...
Utility method to convert DTCellValues to their String representation
8,004
protected void marshalPackageHeader ( final RuleModel model , final StringBuilder buf ) { PackageNameWriter . write ( buf , model ) ; ImportsWriter . write ( buf , model ) ; }
Append package name and imports to DRL
8,005
protected void marshalRuleHeader ( final RuleModel model , final StringBuilder buf ) { buf . append ( "rule \"" + marshalRuleName ( model ) + "\"" ) ; if ( null != model . parentName && model . parentName . length ( ) > 0 ) { buf . append ( " extends \"" + model . parentName + "\"\n" ) ; } else { buf . append ( '\n' ) ...
Append rule header
8,006
protected void marshalAttributes ( final StringBuilder buf , final RuleModel model ) { boolean hasDialect = false ; for ( int i = 0 ; i < model . attributes . length ; i ++ ) { RuleAttribute attr = model . attributes [ i ] ; buf . append ( "\t" ) ; buf . append ( attr ) ; buf . append ( "\n" ) ; if ( attr . getAttribut...
Marshal model attributes
8,007
protected void marshalMetadata ( final StringBuilder buf , final RuleModel model ) { if ( model . metadataList != null ) { for ( int i = 0 ; i < model . metadataList . length ; i ++ ) { buf . append ( "\t" ) . append ( model . metadataList [ i ] ) . append ( "\n" ) ; } } }
Marshal model metadata
8,008
protected void marshalLHS ( final StringBuilder buf , final RuleModel model , final boolean isDSLEnhanced , final LHSGeneratorContextFactory generatorContextFactory ) { String indentation = "\t\t" ; String nestedIndentation = indentation ; boolean isNegated = model . isNegated ( ) ; if ( model . lhs != null ) { if ( is...
Marshal LHS patterns
8,009
private static ExpressionPart getExpressionPart ( String expressionPart , ModelField currentFact ) { if ( currentFact == null ) { return new ExpressionText ( expressionPart ) ; } else { return new ExpressionVariable ( expressionPart , currentFact . getClassName ( ) , currentFact . getType ( ) ) ; } }
If the bound type is not in the DMO it probably hasn t been imported . So we have little option than to fall back to keeping the value as Text .
8,010
public RuleModel getSimpleRuleModel ( final String drl ) { final RuleModel rm = new RuleModel ( ) ; rm . setPackageName ( PackageNameParser . parsePackageName ( drl ) ) ; rm . setImports ( ImportsParser . parseImports ( drl ) ) ; final Pattern rulePattern = Pattern . compile ( ".*\\s?rule\\s+(.+?)\\s+.*" , Pattern . DO...
Simple fall - back parser of DRL
8,011
public void removeConstraint ( final int idx ) { FieldConstraint constraintToRemove = this . constraints [ idx ] ; if ( constraintToRemove instanceof SingleFieldConstraint ) { final SingleFieldConstraint sfc = ( SingleFieldConstraint ) constraintToRemove ; FieldConstraint parent = sfc . getParent ( ) ; for ( FieldConst...
at this point in time .
8,012
private TupleList getOrCreate ( final Tuple tuple ) { final int hashCode = this . index . hashCodeOf ( tuple , left ) ; final int index = indexOf ( hashCode , this . table . length ) ; TupleList entry = ( TupleList ) this . table [ index ] ; while ( entry != null ) { if ( matches ( entry , tuple , hashCode , ! left ) )...
We use this method to aviod to table lookups for the same hashcode ; which is what we would have to do if we did a get and then a create if the value is null .
8,013
public String getColumnHeader ( ) { String result = super . getColumnHeader ( ) ; if ( result == null || result . trim ( ) . length ( ) == 0 ) result = metadata ; return result ; }
Returns the header for the metadata column .
8,014
public List < org . kie . dmn . model . api . dmndi . Point > getWaypoint ( ) { if ( waypoint == null ) { waypoint = new ArrayList < > ( ) ; } return this . waypoint ; }
Gets the value of the waypoint property .
8,015
public static < T > void checkEachParameterNotNull ( final String name , final T ... parameters ) { if ( parameters == null ) { throw new IllegalArgumentException ( "Parameter named '" + name + "' should be not null!" ) ; } for ( final Object parameter : parameters ) { if ( parameter == null ) { throw new IllegalArgume...
Assert that this parameter is not null as also each item of the array is not null .
8,016
public static String checkNotEmpty ( final String name , final String parameter ) { if ( parameter == null || parameter . trim ( ) . length ( ) == 0 ) { throw new IllegalArgumentException ( "Parameter named '" + name + "' should be filled!" ) ; } return parameter ; }
Assert that this parameter is not empty . It trims the parameter to see if have any valid data on that .
8,017
public static < T > T checkNotNull ( final String name , final T parameter ) { if ( parameter == null ) { throw new IllegalArgumentException ( "Parameter named '" + name + "' should be not null!" ) ; } return parameter ; }
Assert that this parameter is not null .
8,018
private boolean isEntity ( Object o ) { Class < ? extends Object > varClass = o . getClass ( ) ; return managedClasses . contains ( varClass . getCanonicalName ( ) ) ; }
Changed implementation using EntityManager Metamodel in spite of Reflection .
8,019
public RuleConditionElement build ( RuleBuildContext context , PatternDescr patternDescr , Pattern prefixPattern ) { if ( patternDescr . getObjectType ( ) == null ) { lookupObjectType ( context , patternDescr ) ; } if ( patternDescr . getObjectType ( ) == null || patternDescr . getObjectType ( ) . equals ( "" ) ) { reg...
Build a pattern for the given descriptor in the current context and using the given utils object
8,020
protected void processConstraintsAndBinds ( final RuleBuildContext context , final PatternDescr patternDescr , final Pattern pattern ) { MVELDumper . MVELDumperContext mvelCtx = new MVELDumper . MVELDumperContext ( ) . setRuleContext ( context ) ; for ( BaseDescr b : patternDescr . getDescrs ( ) ) { String expression ;...
Process all constraints and bindings on this pattern
8,021
protected static Declaration createDeclarationObject ( final RuleBuildContext context , final String identifier , final Pattern pattern ) { return createDeclarationObject ( context , identifier , identifier , pattern ) ; }
Creates a declaration object for the field identified by the given identifier on the give pattern object
8,022
public void blockExcept ( Integer ... values ) { free . clear ( ) ; for ( Integer value : values ) { free . add ( value ) ; } }
Redefine the set of acceptable values for this cell .
8,023
public static DMNKnowledgeBuilderError from ( Resource resource , String namespace , DMNMessage m ) { ResultSeverity rs = ResultSeverity . ERROR ; switch ( m . getLevel ( ) ) { case ERROR : rs = ResultSeverity . ERROR ; break ; case INFO : rs = ResultSeverity . INFO ; break ; case WARNING : rs = ResultSeverity . WARNIN...
Builds a DMNKnowledgeBuilderError from a DMNMessage associated with the given Resource
8,024
public void saveMapping ( final Writer out ) throws IOException { for ( final Iterator it = this . mapping . getEntries ( ) . iterator ( ) ; it . hasNext ( ) ; ) { out . write ( it . next ( ) . toString ( ) ) ; out . write ( "\n" ) ; } }
Saves current mapping into a DSL mapping file
8,025
public static void saveMapping ( final Writer out , final DSLMapping mapping ) throws IOException { for ( DSLMappingEntry dslMappingEntry : mapping . getEntries ( ) ) { out . write ( dslMappingEntry . toString ( ) ) ; out . write ( "\n" ) ; } }
Saves the given mapping into a DSL mapping file
8,026
public String dumpFile ( ) { final StringBuilder buf = new StringBuilder ( ) ; for ( DSLMappingEntry dslMappingEntry : this . mapping . getEntries ( ) ) { buf . append ( dslMappingEntry ) ; buf . append ( "\n" ) ; } return buf . toString ( ) ; }
Method to return the current mapping as a String object
8,027
public Object unmarshall ( Type feelType , String value ) { return feel . evaluate ( value ) ; }
Unmarshalls the string into a FEEL value by executing it .
8,028
public static boolean isEqualOrNull ( List s1 , List s2 ) { if ( s1 == null && s2 == null ) { return true ; } else if ( s1 != null && s2 != null && s1 . size ( ) == s2 . size ( ) ) { return true ; } return false ; }
Check whether two List are same size or both null .
8,029
public static boolean isEqualOrNull ( Map s1 , Map s2 ) { if ( s1 == null && s2 == null ) { return true ; } else if ( s1 != null && s2 != null && s1 . size ( ) == s2 . size ( ) ) { return true ; } return false ; }
Check whether two Map are same size or both null .
8,030
public static boolean adOrOver ( Bound < ? > left , Bound < ? > right ) { boolean isValueEqual = left . getValue ( ) . equals ( right . getValue ( ) ) ; boolean isBothOpen = left . getBoundaryType ( ) == RangeBoundary . OPEN && right . getBoundaryType ( ) == RangeBoundary . OPEN ; return isValueEqual && ! isBothOpen ; ...
Returns true if left is overlapping or adjacent to right
8,031
public MetadataCol52 cloneColumn ( ) { MetadataCol52 cloned = new MetadataCol52 ( ) ; cloned . setMetadata ( getMetadata ( ) ) ; cloned . cloneCommonColumnConfigFrom ( this ) ; return cloned ; }
Clones this metadata column instance .
8,032
public Map < String , Declaration > getDeclarations ( RuleImpl rule , String consequenceName ) { Map < String , Declaration > declarations = new HashMap < String , Declaration > ( ) ; for ( RuleConditionElement aBuildStack : this . buildStack ) { if ( aBuildStack instanceof GroupElement && ( ( GroupElement ) aBuildStac...
Return all declarations scoped to the current RuleConditionElement in the build stack
8,033
public void attach ( BuildContext context ) { this . source . addObjectSink ( this ) ; Class < ? > nodeTypeClass = objectType . getClassType ( ) ; if ( nodeTypeClass == null ) { return ; } EntryPointNode epn = context . getKnowledgeBase ( ) . getRete ( ) . getEntryPointNode ( ( ( EntryPointNode ) source ) . getEntryPoi...
Rete needs to know that this ObjectTypeNode has been added
8,034
public ObjectTypeNodeMemory createMemory ( final RuleBaseConfiguration config , InternalWorkingMemory wm ) { Class < ? > classType = ( ( ClassObjectType ) getObjectType ( ) ) . getClassType ( ) ; if ( InitialFact . class . isAssignableFrom ( classType ) ) { return new InitialFactObjectTypeNodeMemory ( classType ) ; } r...
Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs . However PrimitiveLongMap is not ideal for spase data . So it should be monitored incase its more optimal to switch back to a standard HashMap .
8,035
public FEELFnResult < TemporalAmount > invoke ( @ ParameterName ( "from" ) TemporalAmount val ) { if ( val == null ) { return FEELFnResult . ofError ( new InvalidParametersEvent ( Severity . ERROR , "from" , "cannot be null" ) ) ; } return FEELFnResult . ofResult ( val ) ; }
This is the identity function implementation
8,036
private synchronized void internalCreateAndDeployKjarToMaven ( ReleaseId releaseId , String kbaseName , String ksessionName , List < String > resourceFilePaths , List < Class < ? > > classes , List < String > dependencies ) { InternalKieModule kjar = ( InternalKieModule ) internalCreateKieJar ( releaseId , kbaseName , ...
Create a KJar and deploy it to maven .
8,037
private synchronized KieModule internalCreateKieJar ( ReleaseId releaseId , String kbaseName , String ksessionName , List < String > resourceFilePaths , List < Class < ? > > classes , List < String > dependencies ) { ReleaseId [ ] releaseIds = { } ; if ( dependencies != null && dependencies . size ( ) > 0 ) { List < Re...
Create a KJar for deployment ;
8,038
private static String getPomText ( ReleaseId releaseId , ReleaseId ... dependencies ) { String pom = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://maven.apache.org/...
Create the pom that will be placed in the KJar .
8,039
public Behavior . Context [ ] createBehaviorContext ( ) { Behavior . Context [ ] behaviorCtx = new Behavior . Context [ behaviors . length ] ; for ( int i = 0 ; i < behaviors . length ; i ++ ) { behaviorCtx [ i ] = behaviors [ i ] . createContext ( ) ; } return behaviorCtx ; }
Creates the behaviors context
8,040
public boolean assertFact ( final Object behaviorContext , final InternalFactHandle factHandle , final PropagationContext pctx , final InternalWorkingMemory workingMemory ) { boolean result = true ; for ( int i = 0 ; i < behaviors . length ; i ++ ) { result = result && behaviors [ i ] . assertFact ( ( ( Object [ ] ) be...
Register a newly asserted right tuple into the behaviors context
8,041
public void retractFact ( final Object behaviorContext , final InternalFactHandle factHandle , final PropagationContext pctx , final InternalWorkingMemory workingMemory ) { for ( int i = 0 ; i < behaviors . length ; i ++ ) { behaviors [ i ] . retractFact ( ( ( Object [ ] ) behaviorContext ) [ i ] , factHandle , pctx , ...
Removes a newly asserted fact handle from the behaviors context
8,042
protected CompilationProblem [ ] collectCompilerProblems ( ) { if ( this . errors . isEmpty ( ) ) { return null ; } else { final CompilationProblem [ ] list = new CompilationProblem [ this . errors . size ( ) ] ; this . errors . toArray ( list ) ; return list ; } }
We must use an error of JCI problem objects . If there are no problems null is returned . These errors are placed in the DroolsError instances . Its not 1 to 1 with reported errors .
8,043
@ SuppressWarnings ( "unchecked" ) public < T > T get ( Contextual < T > contextual ) { Bean bean = ( Bean ) contextual ; if ( somewhere . containsKey ( bean . getName ( ) ) ) { return ( T ) somewhere . get ( bean . getName ( ) ) ; } else { return null ; } }
Return an existing instance of a certain contextual type or a null value .
8,044
private String getVariableName ( Class clazz , int nodeId ) { String type = clazz . getSimpleName ( ) ; return Character . toLowerCase ( type . charAt ( 0 ) ) + type . substring ( 1 ) + nodeId ; }
Returns a variable name based on the simple name of the specified class appended with the specified nodeId .
8,045
public List < DecisionService > getDecisionService ( ) { return drgElement . stream ( ) . filter ( DecisionService . class :: isInstance ) . map ( DecisionService . class :: cast ) . collect ( Collectors . toList ( ) ) ; }
Implementing support for internal model
8,046
private void cacheStream ( ) { try { File fi = getTemproralCacheFile ( ) ; if ( fi . exists ( ) ) { if ( ! fi . delete ( ) ) { throw new IllegalStateException ( "Cannot delete file " + fi . getAbsolutePath ( ) + "!" ) ; } } FileOutputStream fout = new FileOutputStream ( fi ) ; InputStream in = grabStream ( ) ; byte [ ]...
Save a copy in the local cache - in case remote source is not available in future .
8,047
private URL getCleanedUrl ( URL originalUrl , String originalPath ) { try { return new URL ( StringUtils . cleanPath ( originalPath ) ) ; } catch ( MalformedURLException ex ) { return originalUrl ; } }
Determine a cleaned URL for the given original URL .
8,048
public DroolsParserException createTrailingSemicolonException ( int line , int column , int offset ) { String message = String . format ( TRAILING_SEMI_COLON_NOT_ALLOWED_MESSAGE , line , column , formatParserLocation ( ) ) ; return new DroolsParserException ( "ERR 104" , message , line , column , offset , null ) ; }
This method creates a DroolsParserException for trailing semicolon exception full of information .
8,049
public DroolsParserException createDroolsException ( RecognitionException e ) { List < String > codeAndMessage = createErrorMessage ( e ) ; return new DroolsParserException ( codeAndMessage . get ( 1 ) , codeAndMessage . get ( 0 ) , e . line , e . charPositionInLine , e . index , e ) ; }
This method creates a DroolsParserException full of information .
8,050
private String formatParserLocation ( ) { StringBuilder sb = new StringBuilder ( ) ; if ( paraphrases != null ) { for ( Map < DroolsParaphraseTypes , String > map : paraphrases ) { for ( Entry < DroolsParaphraseTypes , String > activeEntry : map . entrySet ( ) ) { if ( activeEntry . getValue ( ) . length ( ) == 0 ) { S...
This will take Paraphrases stack and create a sensible location
8,051
private String getLocationName ( DroolsParaphraseTypes type ) { switch ( type ) { case PACKAGE : return "package" ; case IMPORT : return "import" ; case FUNCTION_IMPORT : return "function import" ; case ACCUMULATE_IMPORT : return "accumulate import" ; case GLOBAL : return "global" ; case FUNCTION : return "function" ; ...
Returns a string based on Paraphrase Type
8,052
String makeInList ( final String cell ) { if ( cell . startsWith ( "(" ) ) { return cell ; } String result = "" ; Iterator < String > iterator = Arrays . asList ( ListSplitter . split ( "\"" , true , cell ) ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { final String item = iterator . next ( ) ; if ( item . start...
take a CSV list and turn it into DRL syntax
8,053
private FieldConstraint makeSingleFieldConstraint ( ConditionCol52 c , String cell ) { SingleFieldConstraint sfc = new SingleFieldConstraint ( c . getFactField ( ) ) ; if ( no ( c . getOperator ( ) ) ) { String [ ] a = cell . split ( "\\s" ) ; if ( a . length > 1 ) { StringBuilder operator = new StringBuilder ( a [ 0 ]...
Build a normal SingleFieldConstraint for a non - otherwise cell value
8,054
private FieldConstraint makeSingleFieldConstraint ( ConditionCol52 c , List < BaseColumn > allColumns , List < List < DTCellValue52 > > data ) { GuidedDTDRLOtherwiseHelper . OtherwiseBuilder builder = GuidedDTDRLOtherwiseHelper . getBuilder ( c ) ; return builder . makeFieldConstraint ( c , allColumns , data ) ; }
Build a SingleFieldConstraint for an otherwise cell value
8,055
private String generateModelId ( ) { String mt = this . modelType . toString ( ) ; StringBuilder mid = new StringBuilder ( mt ) ; Integer lastId = null ; if ( generatedModelIds . containsKey ( mt ) ) { lastId = generatedModelIds . get ( mt ) ; } else { lastId = new Integer ( - 1 ) ; } lastId ++ ; mid . append ( lastId ...
A method that tries to generate a model identifier for those times when models arrive without an identifier
8,056
private static DTDecisionRule toDecisionRule ( EvaluationContext mainCtx , FEEL embeddedFEEL , int index , List < ? > rule , int inputSize ) { DTDecisionRule dr = new DTDecisionRule ( index ) ; for ( int i = 0 ; i < rule . size ( ) ; i ++ ) { Object o = rule . get ( i ) ; if ( i < inputSize ) { dr . getInputEntry ( ) ....
Convert row to DTDecisionRule
8,057
public void addChild ( final RuleConditionElement child ) { if ( ( this . isNot ( ) || this . isExists ( ) ) && ( this . children . size ( ) > 0 ) ) { throw new RuntimeException ( this . type . toString ( ) + " can have only a single child element. Either a single Pattern or another CE." ) ; } this . children . add ( c...
Adds a child to the current GroupElement .
8,058
public static Interval [ ] [ ] calculateTemporalDistance ( Interval [ ] [ ] constraintMatrix ) { Interval [ ] [ ] result = new Interval [ constraintMatrix . length ] [ ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = new Interval [ constraintMatrix [ i ] . length ] ; for ( int j = 0 ; j < result [ i ...
This method calculates the transitive closure of the given adjacency matrix in order to find the temporal distance between each event represented in the adjacency matrix .
8,059
public static long parseTimeString ( String time ) { String trimmed = time . trim ( ) ; long result = 0 ; if ( trimmed . length ( ) > 0 ) { Matcher mat = SIMPLE . matcher ( trimmed ) ; if ( mat . matches ( ) ) { int days = ( mat . group ( SIM_DAY ) != null ) ? Integer . parseInt ( mat . group ( SIM_DAY ) ) : 0 ; int ho...
Parses the given time String and returns the corresponding time in milliseconds
8,060
public void passMessage ( JunctionTreeClique sourceClique , JunctionTreeSeparator sep , JunctionTreeClique targetClique ) { double [ ] sepPots = separatorStates [ sep . getId ( ) ] . getPotentials ( ) ; double [ ] oldSepPots = Arrays . copyOf ( sepPots , sepPots . length ) ; BayesVariable [ ] sepVars = sep . getValues ...
Passes a message from node1 to node2 . node1 projects its trgPotentials into the separator . node2 then absorbs those trgPotentials from the separator .
8,061
private static Optional < String > methodToCustomProperty ( Method m ) { return Optional . ofNullable ( m . getAnnotation ( FEELProperty . class ) ) . map ( a -> a . value ( ) ) ; }
If method m is annotated with FEELProperty will return FEELProperty . value otherwise empty .
8,062
public static Type of ( Class < ? > clazz ) { return Optional . ofNullable ( ( Type ) cache . computeIfAbsent ( clazz , JavaBackedType :: createIfAnnotated ) ) . orElse ( BuiltInType . UNKNOWN ) ; }
If clazz can be represented as a JavaBackedType returns a JavaBackedType for representing clazz . If clazz can not be represented as a JavaBackedType returns BuiltInType . UNKNOWN . This method performs memoization when necessary .
8,063
private static JavaBackedType createIfAnnotated ( Class < ? > clazz ) { if ( clazz . isAnnotationPresent ( FEELType . class ) || Stream . of ( clazz . getMethods ( ) ) . anyMatch ( m -> m . getAnnotation ( FEELProperty . class ) != null ) ) { return new JavaBackedType ( clazz ) ; } return null ; }
For internal use returns a new JavaBackedType if clazz can be represented as such returns null otherwise .
8,064
public < S , T > Modify < S > getInverse ( T value ) { ModifyLiteral inverse = new InverseModifyLiteral ( value ) ; ModifyTaskLiteral task = this . task ; do { if ( isAffected ( value , task . value ) ) { MetaProperty inv = ( ( InvertibleMetaProperty ) task . getProperty ( ) ) . getInverse ( ) ; inverse . addTask ( inv...
not used for execution but for provenance logging only
8,065
< T extends Node > NodeList < T > add ( NodeList < T > list , T obj ) { if ( list == null ) { list = new NodeList < > ( ) ; } list . add ( obj ) ; return list ; }
Add obj to list and return it . Create a new list if list is null
8,066
< T > List < T > add ( List < T > list , T obj ) { if ( list == null ) { list = new LinkedList < > ( ) ; } list . add ( obj ) ; return list ; }
Add obj to list
8,067
ArrayCreationExpr juggleArrayCreation ( TokenRange range , List < TokenRange > levelRanges , Type type , NodeList < Expression > dimensions , List < NodeList < AnnotationExpr > > arrayAnnotations , ArrayInitializerExpr arrayInitializerExpr ) { NodeList < ArrayCreationLevel > levels = new NodeList < > ( ) ; for ( int i ...
Throws together an ArrayCreationExpr from a lot of pieces
8,068
Type juggleArrayType ( Type partialType , List < ArrayType . ArrayBracketPair > additionalBrackets ) { Pair < Type , List < ArrayType . ArrayBracketPair > > partialParts = unwrapArrayTypes ( partialType ) ; Type elementType = partialParts . a ; List < ArrayType . ArrayBracketPair > leftMostBrackets = partialParts . b ;...
Throws together a Type taking care of all the array brackets
8,069
private String makeMessageForParseException ( ParseException exception ) { final StringBuilder sb = new StringBuilder ( "Parse error. Found " ) ; final StringBuilder expected = new StringBuilder ( ) ; int maxExpectedTokenSequenceLength = 0 ; TreeSet < String > sortedOptions = new TreeSet < > ( ) ; for ( int i = 0 ; i <...
This is the code from ParseException . initialise modified to be more horizontal .
8,070
public void pushParaphrases ( DroolsParaphraseTypes type ) { Map < DroolsParaphraseTypes , String > activeMap = new HashMap < DroolsParaphraseTypes , String > ( ) ; activeMap . put ( type , "" ) ; paraphrases . push ( activeMap ) ; }
Method that adds a paraphrase type into paraphrases stack .
8,071
public void setParaphrasesValue ( DroolsParaphraseTypes type , String value ) { paraphrases . peek ( ) . put ( type , value ) ; }
Method that sets paraphrase value for a type into paraphrases stack .
8,072
public void setPomModel ( PomModel pomModel ) { this . pomModel = pomModel ; if ( srcMfs . isAvailable ( "pom.xml" ) ) { this . pomXml = srcMfs . getBytes ( "pom.xml" ) ; } }
This can be used for performance reason to avoid the recomputation of the pomModel when it is already available
8,073
public boolean equal ( final Object o1 , final Object o2 ) { if ( o1 instanceof InternalFactHandle ) { return ( ( InternalFactHandle ) o1 ) . getId ( ) == ( ( InternalFactHandle ) o2 ) . getId ( ) ; } Object left = o1 ; final InternalFactHandle handle = ( ( InternalFactHandle ) o2 ) ; if ( left == handle . getObject ( ...
Special comparator that allows FactHandles to be keys but always checks like for like .
8,074
public String getReadMethod ( ) { if ( getterName != null ) { return getterName ; } String prefix ; if ( "boolean" . equals ( this . type ) ) { prefix = "is" ; } else { prefix = "get" ; } return prefix + this . name . substring ( 0 , 1 ) . toUpperCase ( ) + this . name . substring ( 1 ) ; }
Creates the String name for the get method for a field with the given name and type
8,075
public String getWriteMethod ( ) { return setterName != null ? setterName : "set" + this . name . substring ( 0 , 1 ) . toUpperCase ( ) + this . name . substring ( 1 ) ; }
Creates the String name for the set method for a field with the given name and type
8,076
public boolean matches ( Object clazz ) { return clazz instanceof FactTemplate ? this . typeTemplate . equals ( clazz ) : this . typeClass . isAssignableFrom ( ( Class < ? > ) clazz ) ; }
Returns true if the given parameter matches this type declaration
8,077
public ConstraintConnectiveDescr parse ( final String text ) { ConstraintConnectiveDescr constraint = null ; try { DRLLexer lexer = DRLFactory . getDRLLexer ( new ANTLRStringStream ( text ) , languageLevel ) ; CommonTokenStream input = new CommonTokenStream ( lexer ) ; RecognizerSharedState state = new RecognizerShared...
Parse an expression from text
8,078
public List < Pattern52 > getPatterns ( ) { final List < Pattern52 > patterns = new ArrayList < Pattern52 > ( ) ; for ( CompositeColumn < ? > cc : conditionPatterns ) { if ( cc instanceof Pattern52 ) { patterns . add ( ( Pattern52 ) cc ) ; } } return Collections . unmodifiableList ( patterns ) ; }
Return an immutable list of Pattern columns
8,079
public List < BaseColumn > getExpandedColumns ( ) { final List < BaseColumn > columns = new ArrayList < BaseColumn > ( ) ; columns . add ( rowNumberCol ) ; columns . add ( descriptionCol ) ; columns . addAll ( metadataCols ) ; columns . addAll ( attributeCols ) ; for ( CompositeColumn < ? > cc : this . conditionPattern...
This method expands Composite columns into individual columns where knowledge of individual columns is necessary ; for example separate columns in the user - interface or where individual columns need to be analysed .
8,080
private static void removeMatch ( final AccumulateNode accNode , final Accumulate accumulate , final RightTuple rightTuple , final LeftTuple match , final InternalWorkingMemory wm , final AccumulateMemory am , final AccumulateContext accctx , final boolean reaccumulate ) { LeftTuple leftTuple = match . getLeftParent ( ...
Removes a match between left and right tuple
8,081
public org . kie . dmn . model . api . dmndi . DiagramElement . Extension getExtension ( ) { return extension ; }
Gets the value of the extension property .
8,082
public void setExtension ( org . kie . dmn . model . api . dmndi . DiagramElement . Extension value ) { this . extension = value ; }
Sets the value of the extension property .
8,083
public void setStyle ( org . kie . dmn . model . api . dmndi . Style value ) { this . style = value ; }
Sets the value of the style property .
8,084
public void setSharedStyle ( org . kie . dmn . model . api . dmndi . Style value ) { this . sharedStyle = value ; }
Sets the value of the sharedStyle property .
8,085
public void addContent ( DroolsToken token ) { if ( startOffset == - 1 ) { startOffset = token . getStartIndex ( ) ; } endOffset = token . getStopIndex ( ) ; this . content . add ( token ) ; }
Add a token to the content and sets char offset info
8,086
private void visitActionFieldList ( ActionInsertFact afl ) { String factType = afl . getFactType ( ) ; for ( ActionFieldValue afv : afl . getFieldValues ( ) ) { InterpolationVariable var = new InterpolationVariable ( afv . getValue ( ) , afv . getType ( ) , factType , afv . getField ( ) ) ; if ( afv . getNature ( ) == ...
ActionInsertFact ActionSetField ActionUpdateField
8,087
public boolean removeFactPattern ( int index ) { final int newSize = ( ( index >= 0 && index < this . patterns . length ) ? this . patterns . length - 1 : this . patterns . length ) ; final IFactPattern [ ] newList = new IFactPattern [ newSize ] ; boolean deleted = false ; int newIdx = 0 ; for ( int i = 0 ; i < this . ...
Remove a FactPattern at the provided index . If index is less than zero or greater than or equal to the number of patterns the effect of this method is no operation .
8,088
public static String getInternalType ( String type ) { String internalType = null ; if ( "byte" . equals ( type ) ) { internalType = "B" ; } else if ( "char" . equals ( type ) ) { internalType = "C" ; } else if ( "double" . equals ( type ) ) { internalType = "D" ; } else if ( "float" . equals ( type ) ) { internalType ...
Returns the corresponding internal type representation for the given type .
8,089
public static String getTypeDescriptor ( String type ) { String internalType = null ; if ( "byte" . equals ( type ) ) { internalType = "B" ; } else if ( "char" . equals ( type ) ) { internalType = "C" ; } else if ( "double" . equals ( type ) ) { internalType = "D" ; } else if ( "float" . equals ( type ) ) { internalTyp...
Returns the corresponding type descriptor for the given type .
8,090
public static String arrayType ( String type ) { if ( isArray ( type ) ) if ( type . length ( ) == arrayDimSize ( type ) + 1 ) { return type ; } else { String ans = "Ljava/lang/Object;" ; for ( int j = 0 ; j < arrayDimSize ( type ) ; j ++ ) { ans = "[" + ans ; } return ans ; } return null ; }
Can only be used with internal names i . e . after [ has been prefix
8,091
public static boolean isPrimitive ( String type ) { boolean isPrimitive = false ; if ( "byte" . equals ( type ) || "char" . equals ( type ) || "double" . equals ( type ) || "float" . equals ( type ) || "int" . equals ( type ) || "long" . equals ( type ) || "short" . equals ( type ) || "boolean" . equals ( type ) || "vo...
Returns true if the provided type is a primitive type
8,092
public void add ( VerifierComponent descr ) { if ( subSolver != null ) { subSolver . add ( descr ) ; } else { if ( type == OperatorDescrType . AND ) { if ( possibilityLists . isEmpty ( ) ) { possibilityLists . add ( new HashSet < VerifierComponent > ( ) ) ; } for ( Set < VerifierComponent > set : possibilityLists ) { s...
Add new descr .
8,093
protected void end ( ) { if ( subSolver != null && subSolver . subSolver == null ) { if ( type == OperatorDescrType . AND ) { if ( possibilityLists . isEmpty ( ) ) { possibilityLists . add ( new HashSet < VerifierComponent > ( ) ) ; } List < Set < VerifierComponent > > newPossibilities = new ArrayList < Set < VerifierC...
Ends subSolvers data collection .
8,094
public final int compare ( final Activation existing , final Activation adding ) { final int s1 = existing . getSalience ( ) ; final int s2 = adding . getSalience ( ) ; if ( s1 > s2 ) { return 1 ; } else if ( s1 < s2 ) { return - 1 ; } return ( int ) ( existing . getRule ( ) . getLoadOrder ( ) - adding . getRule ( ) . ...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8,095
public static boolean isReadLocalsFromTuple ( final RuleBuildContext context , final AccumulateDescr accumDescr , final RuleConditionElement source ) { if ( accumDescr . isMultiPattern ( ) ) { return true ; } PatternDescr inputPattern = accumDescr . getInputPattern ( ) ; if ( inputPattern == null ) { context . addError...
This method checks for the conditions when local declarations should be read from a tuple instead of the right object when resolving declarations in an accumulate
8,096
public static DMNCompilerConfigurationImpl compilerConfigWithKModulePrefs ( ClassLoader classLoader , ChainedProperties chainedProperties , List < DMNProfile > dmnProfiles , DMNCompilerConfigurationImpl config ) { config . setRootClassLoader ( classLoader ) ; Map < String , String > dmnPrefs = new HashMap < > ( ) ; cha...
Returns a DMNCompilerConfiguration with the specified properties set and applying the explicited dmnProfiles .
8,097
private String determineResultClassName ( ClassObjectType objType ) { String className = objType . getClassName ( ) ; if ( List . class . getName ( ) . equals ( className ) ) { className = ArrayList . class . getName ( ) ; } else if ( Set . class . getName ( ) . equals ( className ) ) { className = HashSet . class . ge...
If the user uses an interface as a result type use a default concrete class .
8,098
protected static ClassWriter buildClassHeader ( Class < ? > superClass , String className ) { ClassWriter cw = createClassWriter ( superClass . getClassLoader ( ) , Opcodes . ACC_PUBLIC + Opcodes . ACC_SUPER , className , null , Type . getInternalName ( superClass ) , null ) ; cw . visitSource ( null , null ) ; return ...
Builds the class header
8,099
private static void build3ArgConstructor ( final Class < ? > superClazz , final String className , final ClassWriter cw ) { MethodVisitor mv ; { mv = cw . visitMethod ( Opcodes . ACC_PUBLIC , "<init>" , Type . getMethodDescriptor ( Type . VOID_TYPE , Type . getType ( int . class ) , Type . getType ( Class . class ) , T...
Creates a constructor for the field extractor receiving the index field type and value type