idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
21,800
private boolean isSingleMultiDay ( ) { long duration = getEnd ( ) . getTime ( ) - getStart ( ) . getTime ( ) ; if ( duration > I_CmsSerialDateValue . DAY_IN_MILLIS ) { return true ; } if ( isWholeDay ( ) && ( duration <= I_CmsSerialDateValue . DAY_IN_MILLIS ) ) { return false ; } Calendar start = new GregorianCalendar ...
Returns a flag indicating if the current event is a multi - day event . The method is only called if the single event has an explicitely set end date or an explicitely changed whole day option .
21,801
public static void checkCreateUpload ( CmsObject cms , CmsUgcConfiguration config , String name , long size ) throws CmsUgcException { if ( ! config . getUploadParentFolder ( ) . isPresent ( ) ) { String message = Messages . get ( ) . container ( Messages . ERR_NO_UPLOADS_ALLOWED_0 ) . key ( cms . getRequestContext ( )...
Checks whether an uploaded file can be created in the VFS and throws an exception otherwise .
21,802
protected void addFacetPart ( CmsSolrQuery query ) { StringBuffer value = new StringBuffer ( ) ; value . append ( "{!key=" ) . append ( m_config . getName ( ) ) ; addFacetOptions ( value ) ; if ( m_config . getIgnoreAllFacetFilters ( ) || ( ! m_state . getCheckedEntries ( ) . isEmpty ( ) && ! m_config . getIsAndFacet (...
Generate query part for the facet without filters .
21,803
private void setFittingWeekDay ( Calendar date ) { date . set ( Calendar . DAY_OF_MONTH , 1 ) ; int weekDayFirst = date . get ( Calendar . DAY_OF_WEEK ) ; int firstFittingWeekDay = ( ( ( m_weekDay . toInt ( ) + I_CmsSerialDateValue . NUM_OF_WEEKDAYS ) - weekDayFirst ) % I_CmsSerialDateValue . NUM_OF_WEEKDAYS ) + 1 ; in...
Adjusts the day in the provided month that it fits the specified week day . If there s no match for that provided month the next possible month is checked .
21,804
public VerticalLayout getEmptyLayout ( ) { m_emptyLayout = CmsVaadinUtils . getInfoLayout ( CmsOuTreeType . USER . getEmptyMessageKey ( ) ) ; setVisible ( size ( ) > 0 ) ; m_emptyLayout . setVisible ( size ( ) == 0 ) ; return m_emptyLayout ; }
Layout which gets displayed if table is empty .
21,805
public List < CmsUser > getVisibleUser ( ) { if ( ! m_fullyLoaded ) { return m_users ; } if ( size ( ) == m_users . size ( ) ) { return m_users ; } List < CmsUser > directs = new ArrayList < CmsUser > ( ) ; for ( CmsUser user : m_users ) { if ( ! m_indirects . contains ( user ) ) { directs . add ( user ) ; } } return d...
Gets currently visible user .
21,806
String getStatus ( CmsUser user , boolean disabled , boolean newUser ) { if ( disabled ) { return CmsVaadinUtils . getMessageText ( Messages . GUI_USERMANAGEMENT_USER_DISABLED_0 ) ; } if ( newUser ) { return CmsVaadinUtils . getMessageText ( Messages . GUI_USERMANAGEMENT_USER_INACTIVE_0 ) ; } if ( OpenCms . getLoginMan...
Returns status message .
21,807
String getStatusHelp ( CmsUser user , boolean disabled , boolean newUser ) { if ( disabled ) { return CmsVaadinUtils . getMessageText ( Messages . GUI_USERMANAGEMENT_USER_DISABLED_HELP_0 ) ; } if ( newUser ) { return CmsVaadinUtils . getMessageText ( Messages . GUI_USERMANAGEMENT_USER_INACTIVE_HELP_0 ) ; } if ( isUserP...
Returns status help message .
21,808
boolean isUserPasswordReset ( CmsUser user ) { if ( USER_PASSWORD_STATUS . containsKey ( user . getId ( ) ) ) { if ( ! USER_PASSWORD_STATUS . get ( user . getId ( ) ) . booleanValue ( ) ) { return false ; } if ( m_checkedUserPasswordReset . contains ( user . getId ( ) ) ) { return true ; } } CmsUser currentUser = user ...
Is the user password reset?
21,809
public CmsSolrQuery getQuery ( CmsObject cms ) { final CmsSolrQuery query = new CmsSolrQuery ( ) ; query . setCategories ( m_categories ) ; if ( null != m_containerTypes ) { query . addFilterQuery ( CmsSearchField . FIELD_CONTAINER_TYPES , m_containerTypes , false , false ) ; } query . addFilterQuery ( CmsSearchUtil . ...
Returns a CmsSolrQuery representation of this class .
21,810
private void addFoldersToSearchIn ( final List < String > folders ) { if ( null == folders ) { return ; } for ( String folder : folders ) { if ( ! CmsResource . isFolder ( folder ) ) { folder += "/" ; } m_foldersToSearchIn . add ( folder ) ; } }
Adds folders to perform the search in .
21,811
private void setSearchScopeFilter ( CmsObject cms ) { final List < String > searchRoots = CmsSearchUtil . computeScopeFolders ( cms , this ) ; if ( ( null != getResourceTypes ( ) ) && containsFunctionType ( getResourceTypes ( ) ) ) { searchRoots . add ( "/system/modules/" ) ; } addFoldersToSearchIn ( searchRoots ) ; }
Sets the search scope .
21,812
private String dbProp ( String name ) { String dbType = m_setupBean . getDatabase ( ) ; Object prop = m_setupBean . getDatabaseProperties ( ) . get ( dbType ) . get ( dbType + "." + name ) ; if ( prop == null ) { return "" ; } return prop . toString ( ) ; }
Accesses a property from the DB configuration for the selected DB .
21,813
protected void add ( Widget child , Element container ) { child . removeFromParent ( ) ; getChildren ( ) . add ( child ) ; DOM . appendChild ( container , child . getElement ( ) ) ; adopt ( child ) ; }
Adds a new child widget to the panel attaching its Element to the specified container Element .
21,814
protected int adjustIndex ( Widget child , int beforeIndex ) { checkIndexBoundsForInsertion ( beforeIndex ) ; if ( child . getParent ( ) == this ) { int idx = getWidgetIndex ( child ) ; if ( idx < beforeIndex ) { beforeIndex -- ; } } return beforeIndex ; }
Adjusts beforeIndex to account for the possibility that the given widget is already a child of this panel .
21,815
protected void beginDragging ( MouseDownEvent event ) { m_dragging = true ; m_windowWidth = Window . getClientWidth ( ) ; m_clientLeft = Document . get ( ) . getBodyOffsetLeft ( ) ; m_clientTop = Document . get ( ) . getBodyOffsetTop ( ) ; DOM . setCapture ( getElement ( ) ) ; m_dragStartX = event . getX ( ) ; m_dragSt...
Called on mouse down in the caption area begins the dragging loop by turning on event capture .
21,816
protected void endDragging ( MouseUpEvent event ) { m_dragging = false ; DOM . releaseCapture ( getElement ( ) ) ; removeStyleName ( I_CmsLayoutBundle . INSTANCE . dialogCss ( ) . dragging ( ) ) ; }
Called on mouse up in the caption area ends dragging by ending event capture .
21,817
public Map < String , String > getParams ( ) { Map < String , String > params = new HashMap < > ( 1 ) ; params . put ( PARAM_COLLAPSED , Boolean . TRUE . toString ( ) ) ; return params ; }
Add the option specifying if the categories should be displayed collapsed when the dialog opens .
21,818
public static boolean updatingIndexNecessesary ( CmsObject cms ) { setCmsOfflineProject ( cms ) ; if ( isSolrSpellcheckIndexDirectoryEmpty ( ) ) { return true ; } long dateMostRecentDictionary = getMostRecentDate ( cms ) ; long dateOldestIndexWrite = getOldestIndexDate ( cms ) ; return dateMostRecentDictionary > dateOl...
Checks whether a built of the indices is necessary .
21,819
private static String getSolrSpellcheckRfsPath ( ) { String sPath = OpenCms . getSystemInfo ( ) . getWebInfRfsPath ( ) ; if ( ! OpenCms . getSystemInfo ( ) . getWebInfRfsPath ( ) . endsWith ( File . separator ) ) { sPath += File . separator ; } return sPath + "solr" + File . separator + "spellcheck" + File . separator ...
Returns the path in the RFS where the Solr spellcheck files reside .
21,820
private static void readAndAddDocumentsFromStream ( final SolrClient client , final String lang , final InputStream is , final List < SolrInputDocument > documents , final boolean closeStream ) { final BufferedReader br = new BufferedReader ( new InputStreamReader ( is ) ) ; try { String line = br . readLine ( ) ; whil...
Parses the dictionary from an InputStream .
21,821
private static void setCmsOfflineProject ( CmsObject cms ) { if ( null == cms ) { return ; } final CmsRequestContext cmsContext = cms . getRequestContext ( ) ; final CmsProject cmsProject = cmsContext . getCurrentProject ( ) ; if ( cmsProject . isOnlineProject ( ) ) { CmsProject cmsOfflineProject ; try { cmsOfflineProj...
Sets the appropriate OpenCms context .
21,822
private String toPath ( String name , IconSize size ) { return CmsStringUtil . joinPaths ( CmsWorkplace . getSkinUri ( ) , ICON_FOLDER , "" + name . hashCode ( ) ) + size . getSuffix ( ) ; }
Transforms user name and icon size into the image path .
21,823
private String toRfsName ( String name , IconSize size ) { return CmsStringUtil . joinPaths ( m_cache . getRepositoryPath ( ) , "" + name . hashCode ( ) ) + size . getSuffix ( ) ; }
Transforms user name and icon size into the rfs image path .
21,824
private I_CmsSearchIndex getIndex ( ) { I_CmsSearchIndex index = null ; if ( isInitialCall ( ) ) { index = OpenCms . getSearchManager ( ) . getIndex ( getSettings ( ) . getUserSettings ( ) . getWorkplaceSearchIndexName ( ) ) ; } else { index = OpenCms . getSearchManager ( ) . getIndex ( getJsp ( ) . getRequest ( ) . ge...
Gets the index to use in the search .
21,825
public void transform ( String name , String transform ) throws Exception { File configFile = new File ( m_configDir , name ) ; File transformFile = new File ( m_xsltDir , transform ) ; try ( InputStream stream = new FileInputStream ( transformFile ) ) { StreamSource source = new StreamSource ( stream ) ; transform ( c...
Transforms a config file with an XSLT transform .
21,826
public void transformConfig ( ) throws Exception { List < TransformEntry > entries = readTransformEntries ( new File ( m_xsltDir , "transforms.xml" ) ) ; for ( TransformEntry entry : entries ) { transform ( entry . getConfigFile ( ) , entry . getXslt ( ) ) ; } m_isDone = true ; }
Transforms the configuration .
21,827
public String validationErrors ( ) { List < String > errors = new ArrayList < > ( ) ; for ( File config : getConfigFiles ( ) ) { String filename = config . getName ( ) ; try ( FileInputStream stream = new FileInputStream ( config ) ) { CmsXmlUtils . unmarshalHelper ( CmsFileUtil . readFully ( stream , false ) , new Cms...
Gets validation errors either as a JSON string or null if there are no validation errors .
21,828
private List < File > getConfigFiles ( ) { String [ ] filenames = { "opencms-modules.xml" , "opencms-system.xml" , "opencms-vfs.xml" , "opencms-importexport.xml" , "opencms-sites.xml" , "opencms-variables.xml" , "opencms-scheduler.xml" , "opencms-workplace.xml" , "opencms-search.xml" } ; List < File > result = new Arra...
Gets existing config files .
21,829
private List < TransformEntry > readTransformEntries ( File file ) throws Exception { List < TransformEntry > result = new ArrayList < > ( ) ; try ( FileInputStream fis = new FileInputStream ( file ) ) { byte [ ] data = CmsFileUtil . readFully ( fis , false ) ; Document doc = CmsXmlUtils . unmarshalHelper ( data , null...
Reads entries from transforms . xml .
21,830
private void transform ( File file , Source transformSource ) throws TransformerConfigurationException , IOException , SAXException , TransformerException , ParserConfigurationException { Transformer transformer = m_transformerFactory . newTransformer ( transformSource ) ; transformer . setOutputProperty ( OutputKeys ....
Transforms a single configuration file using the given transformation source .
21,831
public List < CmsJspNavElement > getSubNavigation ( ) { if ( m_subNavigation == null ) { if ( m_resource . isFile ( ) ) { m_subNavigation = Collections . emptyList ( ) ; } else if ( m_navContext == null ) { try { throw new Exception ( "Can not get subnavigation because navigation context is not set." ) ; } catch ( Exce...
Gets the sub - entries of the navigation entry .
21,832
private Map < String , String > getLocaleProperties ( ) { if ( m_localeProperties == null ) { m_localeProperties = CmsCollectionsGenericWrapper . createLazyMap ( new CmsProperty . CmsPropertyLocaleTransformer ( m_properties , m_locale ) ) ; } return m_localeProperties ; }
Helper to get locale specific properties .
21,833
public void setEveryWorkingDay ( final boolean isEveryWorkingDay ) { if ( m_model . isEveryWorkingDay ( ) != isEveryWorkingDay ) { removeExceptionsOnChange ( new Command ( ) { public void execute ( ) { m_model . setEveryWorkingDay ( Boolean . valueOf ( isEveryWorkingDay ) ) ; m_model . setInterval ( getPatternDefaultVa...
Set the everyWorkingDay flag .
21,834
private void removeListener ( CmsUUID listenerId ) { getRequest ( ) . getSession ( ) . removeAttribute ( SESSION_ATTRIBUTE_LISTENER_ID ) ; m_listeners . remove ( listenerId ) ; }
Remove the listener active in this session .
21,835
private Map < String , String > parseAttributes ( I_CmsXmlContentLocation formatterLoc ) { Map < String , String > result = new LinkedHashMap < > ( ) ; for ( I_CmsXmlContentValueLocation mappingLoc : formatterLoc . getSubValues ( N_ATTRIBUTE ) ) { String key = CmsConfigurationReader . getString ( m_cms , mappingLoc . g...
Parses formatter attributes .
21,836
public Set < String > getConfiguredWorkplaceBundles ( ) { CmsADEConfigData configData = internalLookupConfiguration ( null , null ) ; return configData . getConfiguredWorkplaceBundles ( ) ; }
Returns the names of the bundles configured as workplace bundles in any module configuration .
21,837
public static String removeOpenCmsContext ( final String path ) { String context = OpenCms . getSystemInfo ( ) . getOpenCmsContext ( ) ; if ( path . startsWith ( context + "/" ) ) { return path . substring ( context . length ( ) ) ; } String renderPrefix = OpenCms . getStaticExportManager ( ) . getVfsPrefix ( ) ; if ( ...
Given a path to a VFS resource the method removes the OpenCms context in case the path is prefixed by that context .
21,838
public String getPermalink ( CmsObject cms , String resourceName , CmsUUID detailContentId ) { String permalink = "" ; try { permalink = substituteLink ( cms , CmsPermalinkResourceHandler . PERMALINK_HANDLER ) ; String id = cms . readResource ( resourceName , CmsResourceFilter . ALL ) . getStructureId ( ) . toString ( ...
Returns the perma link for the given resource and optional detail content . <p<
21,839
public String getPermalinkForCurrentPage ( CmsObject cms ) { return getPermalink ( cms , cms . getRequestContext ( ) . getUri ( ) , cms . getRequestContext ( ) . getDetailContentId ( ) ) ; }
Returns the perma link for the current page based on the URI and detail content id stored in the CmsObject passed as a parameter . <p<
21,840
public String getWorkplaceLink ( CmsObject cms , String resourceName , boolean forceSecure ) { String result = substituteLinkForUnknownTarget ( cms , resourceName , forceSecure ) ; return appendServerPrefix ( cms , result , resourceName , true ) ; }
Returns the link for the given workplace resource .
21,841
private Table buildTable ( CmsSqlConsoleResults results ) { IndexedContainer container = new IndexedContainer ( ) ; int numCols = results . getColumns ( ) . size ( ) ; for ( int c = 0 ; c < numCols ; c ++ ) { container . addContainerProperty ( Integer . valueOf ( c ) , results . getColumnType ( c ) , null ) ; } int r =...
Builds the table for the database results .
21,842
private void updateImageInfo ( ) { String crop = getCrop ( ) ; String point = getPoint ( ) ; m_imageInfoDisplay . fillContent ( m_info , crop , point ) ; }
Updates the image information .
21,843
public static CmsShell getTopShell ( ) { ArrayList < CmsShell > shells = SHELL_STACK . get ( ) ; if ( shells . isEmpty ( ) ) { return null ; } return shells . get ( shells . size ( ) - 1 ) ; }
Gets the top of thread - local shell stack or null if it is empty .
21,844
public static void popShell ( ) { ArrayList < CmsShell > shells = SHELL_STACK . get ( ) ; if ( shells . size ( ) > 0 ) { shells . remove ( shells . size ( ) - 1 ) ; } }
Removes top of thread - local shell stack .
21,845
public static CmsSearchConfigurationSorting create ( final String sortParam , final List < I_CmsSearchConfigurationSortOption > options , final I_CmsSearchConfigurationSortOption defaultOption ) { return ( null != sortParam ) || ( ( null != options ) && ! options . isEmpty ( ) ) || ( null != defaultOption ) ? new CmsSe...
Creates a sort configuration iff at least one of the parameters is not null and the options list is not empty .
21,846
public static CmsResourceTypeStatResultList init ( CmsResourceTypeStatResultList resList ) { if ( resList == null ) { return new CmsResourceTypeStatResultList ( ) ; } resList . deleteOld ( ) ; return resList ; }
Method to initialize the list .
21,847
protected boolean exportWithMinimalMetaData ( String path ) { String checkPath = path . startsWith ( "/" ) ? path + "/" : "/" + path + "/" ; for ( String p : m_parameters . getResourcesToExportWithMetaData ( ) ) { if ( checkPath . startsWith ( p ) ) { return false ; } } return true ; }
Check if the resource should be exported with minimal meta - data . This holds for resources that are not part of the export but must be exported as super - folders .
21,848
public void setDraggable ( Element elem , String draggable ) { super . setDraggable ( elem , draggable ) ; if ( "true" . equals ( draggable ) ) { elem . getStyle ( ) . setProperty ( "webkitUserDrag" , "element" ) ; } else { elem . getStyle ( ) . clearProperty ( "webkitUserDrag" ) ; } }
Webkit based browsers require that we set the webkit - user - drag style attribute to make an element draggable .
21,849
protected void createParentXmlElements ( CmsXmlContent xmlContent , String xmlPath , Locale l ) { if ( CmsXmlUtils . isDeepXpath ( xmlPath ) ) { String parentPath = CmsXmlUtils . removeLastXpathElement ( xmlPath ) ; if ( null == xmlContent . getValue ( parentPath , l ) ) { createParentXmlElements ( xmlContent , parentP...
Creates the parents of nested XML elements if necessary .
21,850
public byte [ ] join ( Map < Integer , byte [ ] > parts ) { checkArgument ( parts . size ( ) > 0 , "No parts provided" ) ; final int [ ] lengths = parts . values ( ) . stream ( ) . mapToInt ( v -> v . length ) . distinct ( ) . toArray ( ) ; checkArgument ( lengths . length == 1 , "Varying lengths of part values" ) ; fi...
Joins the given parts to recover the original secret .
21,851
public static Processor < DataSinkTask > sink ( DataSink dataSink , int parallelism , String description , UserConfig taskConf , ActorSystem system ) { io . gearpump . streaming . Processor < DataSinkTask > p = DataSinkProcessor . apply ( dataSink , parallelism , description , taskConf , system ) ; return new Processor...
Creates a Sink Processor
21,852
public static Processor < DataSourceTask > source ( DataSource source , int parallelism , String description , UserConfig taskConf , ActorSystem system ) { io . gearpump . streaming . Processor < DataSourceTask < Object , Object > > p = DataSourceProcessor . apply ( source , parallelism , description , taskConf , syste...
Creates a Source Processor
21,853
public Token recoverInline ( Parser recognizer ) throws RecognitionException { Token matchedSymbol = singleTokenDeletion ( recognizer ) ; if ( matchedSymbol != null ) { recognizer . consume ( ) ; return matchedSymbol ; } if ( singleTokenInsertion ( recognizer ) ) { return getMissingSymbol ( recognizer ) ; } throw new I...
Make sure we don t attempt to recover inline ; if the parser successfully recovers it won t throw an exception .
21,854
protected DirectiveStatement parseDirectiveStatement ( DirectiveStContext node ) { DirectiveStContext stContext = ( DirectiveStContext ) node ; DirectiveExpContext direExp = stContext . directiveExp ( ) ; Token token = direExp . Identifier ( ) . getSymbol ( ) ; String directive = token . getText ( ) . toLowerCase ( ) ....
directive dynamic xxx yy
21,855
public static NamingConvention determineNamingConvention ( TypeElement type , Iterable < ExecutableElement > methods , Messager messager , Types types ) { ExecutableElement beanMethod = null ; ExecutableElement prefixlessMethod = null ; for ( ExecutableElement method : methods ) { switch ( methodNameConvention ( method...
Determine whether the user has followed bean - like naming convention or not .
21,856
public SourceBuilder add ( String fmt , Object ... args ) { TemplateApplier . withParams ( args ) . onText ( source :: append ) . onParam ( this :: add ) . parse ( fmt ) ; return this ; }
Appends formatted text to the source .
21,857
public SourceBuilder addLine ( String fmt , Object ... args ) { add ( fmt , args ) ; source . append ( LINE_SEPARATOR ) ; return this ; }
Appends a formatted line of code to the source .
21,858
private Map < StandardMethod , UnderrideLevel > findUnderriddenMethods ( Iterable < ExecutableElement > methods ) { Map < StandardMethod , ExecutableElement > standardMethods = new LinkedHashMap < > ( ) ; for ( ExecutableElement method : methods ) { Optional < StandardMethod > standardMethod = maybeStandardMethod ( met...
Find any standard methods the user has underridden in their type .
21,859
private boolean hasToBuilderMethod ( DeclaredType builder , boolean isExtensible , Iterable < ExecutableElement > methods ) { for ( ExecutableElement method : methods ) { if ( isToBuilderMethod ( builder , method ) ) { if ( ! isExtensible ) { messager . printMessage ( ERROR , "No accessible no-args Builder constructor ...
Find a toBuilder method if the user has provided one .
21,860
private String generatedBuilderSimpleName ( TypeElement type ) { String packageName = elements . getPackageOf ( type ) . getQualifiedName ( ) . toString ( ) ; String originalName = type . getQualifiedName ( ) . toString ( ) ; checkState ( originalName . startsWith ( packageName + "." ) ) ; String nameWithoutPackage = o...
Returns the simple name of the builder class that should be generated for the given type .
21,861
public static void addToString ( SourceBuilder code , Datatype datatype , Map < Property , PropertyCodeGenerator > generatorsByProperty , boolean forPartial ) { String typename = ( forPartial ? "partial " : "" ) + datatype . getType ( ) . getSimpleName ( ) ; Predicate < PropertyCodeGenerator > isOptional = generator ->...
Generates a toString method using concatenation or a StringBuilder .
21,862
private static void bodyWithConcatenation ( SourceBuilder code , Map < Property , PropertyCodeGenerator > generatorsByProperty , String typename ) { code . add ( " return \"%s{" , typename ) ; String prefix = "" ; for ( Property property : generatorsByProperty . keySet ( ) ) { PropertyCodeGenerator generator = generat...
Generate the body of a toString method that uses plain concatenation .
21,863
private static void bodyWithBuilder ( SourceBuilder code , Datatype datatype , Map < Property , PropertyCodeGenerator > generatorsByProperty , String typename , Predicate < PropertyCodeGenerator > isOptional ) { Variable result = new Variable ( "result" ) ; code . add ( " %1$s %2$s = new %1$s(\"%3$s{" , StringBuilder ...
Generates the body of a toString method that uses a StringBuilder .
21,864
private static void bodyWithBuilderAndSeparator ( SourceBuilder code , Datatype datatype , Map < Property , PropertyCodeGenerator > generatorsByProperty , String typename ) { Variable result = new Variable ( "result" ) ; Variable separator = new Variable ( "separator" ) ; code . addLine ( " %1$s %2$s = new %1$s(\"%3$s...
Generates the body of a toString method that uses a StringBuilder and a separator variable .
21,865
public static void addLazyDefinitions ( SourceBuilder code ) { Set < Declaration > defined = new HashSet < > ( ) ; List < Declaration > declarations = code . scope ( ) . keysOfType ( Declaration . class ) . stream ( ) . sorted ( ) . collect ( toList ( ) ) ; while ( ! defined . containsAll ( declarations ) ) { for ( Dec...
Finds all lazily - declared classes and methods and adds their definitions to the source .
21,866
public void addPartialFieldAssignment ( SourceBuilder code , Excerpt finalField , String builder ) { addFinalFieldAssignment ( code , finalField , builder ) ; }
Add the final assignment of the property to the partial value object s source code .
21,867
public static void addActionsTo ( SourceBuilder code , Set < MergeAction > mergeActions , boolean forBuilder ) { SetMultimap < String , String > nounsByVerb = TreeMultimap . create ( ) ; mergeActions . forEach ( mergeAction -> { if ( forBuilder || ! mergeAction . builderOnly ) { nounsByVerb . put ( mergeAction . verb ,...
Emits a sentence fragment combining all the merge actions .
21,868
public static Variable upcastToGeneratedBuilder ( SourceBuilder code , Datatype datatype , String builder ) { return code . scope ( ) . computeIfAbsent ( Declaration . UPCAST , ( ) -> { Variable base = new Variable ( "base" ) ; code . addLine ( UPCAST_COMMENT ) . addLine ( "%s %s = %s;" , datatype . getGeneratedBuilder...
Upcasts a Builder instance to the generated superclass to allow access to private fields .
21,869
public static Optional < Variable > freshBuilder ( SourceBuilder code , Datatype datatype ) { if ( ! datatype . getBuilderFactory ( ) . isPresent ( ) ) { return Optional . empty ( ) ; } return Optional . of ( code . scope ( ) . computeIfAbsent ( Declaration . FRESH_BUILDER , ( ) -> { Variable defaults = new Variable ( ...
Declares a fresh Builder to copy default property values from .
21,870
public JavadocLink javadocMethodLink ( String memberName , Type ... types ) { return new JavadocLink ( "%s#%s(%s)" , getQualifiedName ( ) , memberName , ( Excerpt ) code -> { String separator = "" ; for ( Type type : types ) { code . add ( "%s%s" , separator , type . getQualifiedName ( ) ) ; separator = ", " ; } } ) ; ...
Returns a source excerpt of a JavaDoc link to a method on this type .
21,871
public Excerpt typeParameters ( ) { if ( getTypeParameters ( ) . isEmpty ( ) ) { return Excerpts . EMPTY ; } else { return Excerpts . add ( "<%s>" , Excerpts . join ( ", " , getTypeParameters ( ) ) ) ; } }
Returns a source excerpt of the type parameters of this type including angle brackets . Always an empty string if the type class is not generic .
21,872
protected Violation createViolation ( Integer lineNumber , String sourceLine , String message ) { Violation violation = new Violation ( ) ; violation . setRule ( this ) ; violation . setSourceLine ( sourceLine ) ; violation . setLineNumber ( lineNumber ) ; violation . setMessage ( message ) ; return violation ; }
Create and return a new Violation for this rule and the specified values
21,873
protected Violation createViolation ( SourceCode sourceCode , ASTNode node , String message ) { String sourceLine = sourceCode . line ( node . getLineNumber ( ) - 1 ) ; return createViolation ( node . getLineNumber ( ) , sourceLine , message ) ; }
Create a new Violation for the AST node .
21,874
protected Violation createViolationForImport ( SourceCode sourceCode , ImportNode importNode , String message ) { Map importInfo = ImportUtil . sourceLineAndNumberForImport ( sourceCode , importNode ) ; Violation violation = new Violation ( ) ; violation . setRule ( this ) ; violation . setSourceLine ( ( String ) impor...
Create and return a new Violation for this rule and the specified import
21,875
protected Violation createViolationForImport ( SourceCode sourceCode , String className , String alias , String violationMessage ) { Map importInfo = ImportUtil . sourceLineAndNumberForImport ( sourceCode , className , alias ) ; Violation violation = new Violation ( ) ; violation . setRule ( this ) ; violation . setSou...
Create and return a new Violation for this rule and the specified import className and alias
21,876
protected boolean shouldApplyThisRuleTo ( ClassNode classNode ) { boolean shouldApply = true ; String applyTo = getApplyToClassNames ( ) ; String doNotApplyTo = getDoNotApplyToClassNames ( ) ; if ( applyTo != null && applyTo . length ( ) > 0 ) { WildcardPattern pattern = new WildcardPattern ( applyTo , true ) ; shouldA...
Return true if this rule should be applied for the specified ClassNode based on the configuration of this rule .
21,877
public Results analyze ( RuleSet ruleSet ) { long startTime = System . currentTimeMillis ( ) ; DirectoryResults reportResults = new DirectoryResults ( ) ; int numThreads = Runtime . getRuntime ( ) . availableProcessors ( ) - 1 ; numThreads = numThreads > 0 ? numThreads : 1 ; ExecutorService pool = Executors . newFixedT...
Analyze all source code using the specified RuleSet and return the report results .
21,878
private static boolean isPredefinedConstant ( Expression expression ) { if ( expression instanceof PropertyExpression ) { Expression object = ( ( PropertyExpression ) expression ) . getObjectExpression ( ) ; Expression property = ( ( PropertyExpression ) expression ) . getProperty ( ) ; if ( object instanceof VariableE...
Tells you if the expression is a predefined constant like TRUE or FALSE .
21,879
public static boolean isMapLiteralWithOnlyConstantValues ( Expression expression ) { if ( expression instanceof MapExpression ) { List < MapEntryExpression > entries = ( ( MapExpression ) expression ) . getMapEntryExpressions ( ) ; for ( MapEntryExpression entry : entries ) { if ( ! isConstantOrConstantLiteral ( entry ...
Returns true if a Map literal that contains only entries where both key and value are constants .
21,880
public static boolean isListLiteralWithOnlyConstantValues ( Expression expression ) { if ( expression instanceof ListExpression ) { List < Expression > expressions = ( ( ListExpression ) expression ) . getExpressions ( ) ; for ( Expression e : expressions ) { if ( ! isConstantOrConstantLiteral ( e ) ) { return false ; ...
Returns true if a List literal that contains only entries that are constants .
21,881
public static boolean isConstant ( Expression expression , Object expected ) { return expression instanceof ConstantExpression && expected . equals ( ( ( ConstantExpression ) expression ) . getValue ( ) ) ; }
Tells you if an expression is the expected constant .
21,882
public static List < ? extends Expression > getMethodArguments ( ASTNode methodCall ) { if ( methodCall instanceof ConstructorCallExpression ) { return extractExpressions ( ( ( ConstructorCallExpression ) methodCall ) . getArguments ( ) ) ; } else if ( methodCall instanceof MethodCallExpression ) { return extractExpres...
Return the List of Arguments for the specified MethodCallExpression or a ConstructorCallExpression . The returned List contains either ConstantExpression or MapEntryExpression objects .
21,883
public static boolean isMethodNamed ( MethodCallExpression methodCall , String methodNamePattern , Integer numArguments ) { Expression method = methodCall . getMethod ( ) ; boolean IS_NAME_MATCH = false ; if ( method instanceof ConstantExpression ) { if ( ( ( ConstantExpression ) method ) . getValue ( ) instanceof Stri...
Return true only if the MethodCallExpression represents a method call for the specified method name
21,884
public static boolean isConstructorCall ( Expression expression , List < String > classNames ) { return expression instanceof ConstructorCallExpression && classNames . contains ( expression . getType ( ) . getName ( ) ) ; }
Return true if the expression is a constructor call on any of the named classes with any number of parameters .
21,885
public static boolean isConstructorCall ( Expression expression , String classNamePattern ) { return expression instanceof ConstructorCallExpression && expression . getType ( ) . getName ( ) . matches ( classNamePattern ) ; }
Return true if the expression is a constructor call on a class that matches the supplied .
21,886
public static AnnotationNode getAnnotation ( AnnotatedNode node , String name ) { List < AnnotationNode > annotations = node . getAnnotations ( ) ; for ( AnnotationNode annot : annotations ) { if ( annot . getClassNode ( ) . getName ( ) . equals ( name ) ) { return annot ; } } return null ; }
Return the AnnotationNode for the named annotation or else null . Supports Groovy 1 . 5 and Groovy 1 . 6 .
21,887
public static boolean hasAnnotation ( AnnotatedNode node , String name ) { return AstUtil . getAnnotation ( node , name ) != null ; }
Return true only if the node has the named annotation
21,888
public static boolean hasAnyAnnotation ( AnnotatedNode node , String ... names ) { for ( String name : names ) { if ( hasAnnotation ( node , name ) ) { return true ; } } return false ; }
Return true only if the node has any of the named annotations
21,889
public static List < Expression > getVariableExpressions ( DeclarationExpression declarationExpression ) { Expression leftExpression = declarationExpression . getLeftExpression ( ) ; if ( leftExpression instanceof ArrayExpression ) { List < Expression > expressions = ( ( ArrayExpression ) leftExpression ) . getExpressi...
Return the List of VariableExpression objects referenced by the specified DeclarationExpression .
21,890
public static boolean isFinalVariable ( DeclarationExpression declarationExpression , SourceCode sourceCode ) { if ( isFromGeneratedSourceCode ( declarationExpression ) ) { return false ; } List < Expression > variableExpressions = getVariableExpressions ( declarationExpression ) ; if ( ! variableExpressions . isEmpty ...
Return true if the DeclarationExpression represents a final variable declaration .
21,891
public static boolean isTrue ( Expression expression ) { if ( expression == null ) { return false ; } if ( expression instanceof PropertyExpression && classNodeImplementsType ( ( ( PropertyExpression ) expression ) . getObjectExpression ( ) . getType ( ) , Boolean . class ) ) { if ( ( ( PropertyExpression ) expression ...
Tells you if the expression is true which can be true or Boolean . TRUE .
21,892
public static boolean isFalse ( Expression expression ) { if ( expression == null ) { return false ; } if ( expression instanceof PropertyExpression && classNodeImplementsType ( ( ( PropertyExpression ) expression ) . getObjectExpression ( ) . getType ( ) , Boolean . class ) ) { if ( ( ( PropertyExpression ) expression...
Tells you if the expression is the false expression either literal or constant .
21,893
public static boolean respondsTo ( Object object , String methodName ) { MetaClass metaClass = DefaultGroovyMethods . getMetaClass ( object ) ; if ( ! metaClass . respondsTo ( object , methodName ) . isEmpty ( ) ) { return true ; } Map properties = DefaultGroovyMethods . getProperties ( object ) ; return properties . c...
Return true only if the specified object responds to the named method
21,894
public static boolean classNodeImplementsType ( ClassNode node , Class target ) { ClassNode targetNode = ClassHelper . make ( target ) ; if ( node . implementsInterface ( targetNode ) ) { return true ; } if ( node . isDerivedFrom ( targetNode ) ) { return true ; } if ( node . getName ( ) . equals ( target . getName ( )...
This method tells you if a ClassNode implements or extends a certain class .
21,895
public static boolean isClosureDeclaration ( ASTNode expression ) { if ( expression instanceof DeclarationExpression ) { if ( ( ( DeclarationExpression ) expression ) . getRightExpression ( ) instanceof ClosureExpression ) { return true ; } } if ( expression instanceof FieldNode ) { ClassNode type = ( ( FieldNode ) exp...
Returns true if the ASTNode is a declaration of a closure either as a declaration or a field .
21,896
public static List < String > getParameterNames ( MethodNode node ) { ArrayList < String > result = new ArrayList < String > ( ) ; if ( node . getParameters ( ) != null ) { for ( Parameter parameter : node . getParameters ( ) ) { result . add ( parameter . getName ( ) ) ; } } return result ; }
Gets the parameter names of a method node .
21,897
public static List < String > getArgumentNames ( MethodCallExpression methodCall ) { ArrayList < String > result = new ArrayList < String > ( ) ; Expression arguments = methodCall . getArguments ( ) ; List < Expression > argExpressions = null ; if ( arguments instanceof ArrayExpression ) { argExpressions = ( ( ArrayExp...
Gets the argument names of a method call . If the arguments are not VariableExpressions then a null will be returned .
21,898
public static boolean isSafe ( Expression expression ) { if ( expression instanceof MethodCallExpression ) { return ( ( MethodCallExpression ) expression ) . isSafe ( ) ; } if ( expression instanceof PropertyExpression ) { return ( ( PropertyExpression ) expression ) . isSafe ( ) ; } return false ; }
Tells you if the expression is a null safe dereference .
21,899
public static boolean isSpreadSafe ( Expression expression ) { if ( expression instanceof MethodCallExpression ) { return ( ( MethodCallExpression ) expression ) . isSpreadSafe ( ) ; } if ( expression instanceof PropertyExpression ) { return ( ( PropertyExpression ) expression ) . isSpreadSafe ( ) ; } return false ; }
Tells you if the expression is a spread operator call