idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
25,000 | public static < Item extends IItem > void restoreSubItemSelectionStatesForAlternativeStateManagement ( Item item , List < String > selectedItems ) { if ( item instanceof IExpandable && ! ( ( IExpandable ) item ) . isExpanded ( ) && ( ( IExpandable ) item ) . getSubItems ( ) != null ) { List < Item > subItems = ( List <... | internal method to restore the selection state of subItems |
25,001 | public static < Item extends IItem > void findSubItemSelections ( Item item , List < String > selections ) { if ( item instanceof IExpandable && ! ( ( IExpandable ) item ) . isExpanded ( ) && ( ( IExpandable ) item ) . getSubItems ( ) != null ) { List < Item > subItems = ( List < Item > ) ( ( IExpandable < Item , ? > )... | internal method to find all selections from subItems and sub sub items so we can save those inside our savedInstanceState |
25,002 | public static < Item extends IItem > void addAllSubItems ( Item item , List < Item > items ) { if ( item instanceof IExpandable && ! ( ( IExpandable ) item ) . isExpanded ( ) && ( ( IExpandable ) item ) . getSubItems ( ) != null ) { List < Item > subItems = ( List < Item > ) ( ( IExpandable < Item , ? > ) item ) . getS... | Gets all subItems from a given parent item |
25,003 | public < A extends IAdapter < Item > > FastAdapter < Item > addAdapter ( int index , A adapter ) { mAdapters . add ( index , adapter ) ; adapter . withFastAdapter ( this ) ; adapter . mapPossibleTypes ( adapter . getAdapterItems ( ) ) ; for ( int i = 0 ; i < mAdapters . size ( ) ; i ++ ) { mAdapters . get ( i ) . setOr... | add s a new adapter at the specific position |
25,004 | public IAdapter < Item > adapter ( int order ) { if ( mAdapters . size ( ) <= order ) { return null ; } return mAdapters . get ( order ) ; } | Tries to get an adapter by a specific order |
25,005 | public FastAdapter < Item > withSelectable ( boolean selectable ) { if ( selectable ) { addExtension ( mSelectExtension ) ; } else { mExtensions . remove ( mSelectExtension . getClass ( ) ) ; } mSelectExtension . withSelectable ( selectable ) ; return this ; } | Set to true if you want the items to be selectable . By default no items are selectable |
25,006 | @ SuppressWarnings ( "unchecked" ) public void registerTypeInstance ( Item item ) { if ( getTypeInstanceCache ( ) . register ( item ) ) { if ( item instanceof IHookable ) { withEventHooks ( ( ( IHookable < Item > ) item ) . getEventHooks ( ) ) ; } } } | register a new type into the TypeInstances to be able to efficiently create thew ViewHolders |
25,007 | @ SuppressWarnings ( "unchecked" ) public RecyclerView . ViewHolder onCreateViewHolder ( ViewGroup parent , int viewType ) { if ( mVerbose ) Log . v ( TAG , "onCreateViewHolder: " + viewType ) ; final RecyclerView . ViewHolder holder = mOnCreateViewHolderListener . onPreCreateViewHolder ( this , parent , viewType ) ; h... | Creates the ViewHolder by the viewType |
25,008 | @ SuppressWarnings ( "unchecked" ) public void onBindViewHolder ( final RecyclerView . ViewHolder holder , int position ) { if ( mLegacyBindViewMode ) { if ( mVerbose ) { Log . v ( TAG , "onBindViewHolderLegacy: " + position + "/" + holder . getItemViewType ( ) + " isLegacy: true" ) ; } holder . itemView . setTag ( R .... | Binds the data to the created ViewHolder and sets the listeners to the holder . itemView Note that you should use the onBindViewHolder ( RecyclerView . ViewHolder holder int position List payloads as it allows you to implement a more efficient adapter implementation |
25,009 | public void onBindViewHolder ( RecyclerView . ViewHolder holder , int position , List < Object > payloads ) { if ( ! mLegacyBindViewMode ) { if ( mVerbose ) Log . v ( TAG , "onBindViewHolder: " + position + "/" + holder . getItemViewType ( ) + " isLegacy: false" ) ; holder . itemView . setTag ( R . id . fastadapter_ite... | Binds the data to the created ViewHolder and sets the listeners to the holder . itemView |
25,010 | public void onViewRecycled ( RecyclerView . ViewHolder holder ) { if ( mVerbose ) Log . v ( TAG , "onViewRecycled: " + holder . getItemViewType ( ) ) ; super . onViewRecycled ( holder ) ; mOnBindViewHolderListener . unBindViewHolder ( holder , holder . getAdapterPosition ( ) ) ; } | Unbinds the data to the already existing ViewHolder and removes the listeners from the holder . itemView |
25,011 | public Item getItem ( int position ) { if ( position < 0 || position >= mGlobalSize ) { return null ; } int index = floorIndex ( mAdapterSizes , position ) ; return mAdapterSizes . valueAt ( index ) . getAdapterItem ( position - mAdapterSizes . keyAt ( index ) ) ; } | gets the IItem by a position from all registered adapters |
25,012 | public RelativeInfo < Item > getRelativeInfo ( int position ) { if ( position < 0 || position >= getItemCount ( ) ) { return new RelativeInfo < > ( ) ; } RelativeInfo < Item > relativeInfo = new RelativeInfo < > ( ) ; int index = floorIndex ( mAdapterSizes , position ) ; if ( index != - 1 ) { relativeInfo . item = mAda... | Internal method to get the Item as ItemHolder which comes with the relative position within its adapter Finds the responsible adapter for the given position |
25,013 | public IAdapter < Item > getAdapter ( int position ) { if ( position < 0 || position >= mGlobalSize ) { return null ; } if ( mVerbose ) Log . v ( TAG , "getAdapter" ) ; return mAdapterSizes . valueAt ( floorIndex ( mAdapterSizes , position ) ) ; } | Gets the adapter for the given position |
25,014 | protected void cacheSizes ( ) { mAdapterSizes . clear ( ) ; int size = 0 ; for ( IAdapter < Item > adapter : mAdapters ) { if ( adapter . getAdapterItemCount ( ) > 0 ) { mAdapterSizes . append ( size , adapter ) ; size = size + adapter . getAdapterItemCount ( ) ; } } if ( size == 0 && mAdapters . size ( ) > 0 ) { mAdap... | we cache the sizes of our adapters so get accesses are faster |
25,015 | @ SuppressWarnings ( "unchecked" ) public static < Item extends IItem > Triple < Boolean , Item , Integer > recursiveSub ( IAdapter < Item > lastParentAdapter , int lastParentPosition , IExpandable parent , AdapterPredicate < Item > predicate , boolean stopOnMatch ) { if ( ! parent . isExpanded ( ) && parent . getSubIt... | Util function which recursively iterates over all items of a IExpandable parent if and only if it is expanded and has subItems This is usually only used in |
25,016 | public FastAdapter < Item > getFastAdapter ( RecyclerView . ViewHolder viewHolder ) { Object tag = viewHolder . itemView . getTag ( R . id . fastadapter_item_adapter ) ; if ( tag instanceof FastAdapter ) { return ( FastAdapter < Item > ) tag ; } return null ; } | Helper method to get the FastAdapter from this ViewHolder |
25,017 | public Item getItem ( RecyclerView . ViewHolder viewHolder ) { FastAdapter < Item > adapter = getFastAdapter ( viewHolder ) ; if ( adapter == null ) { return null ; } int pos = adapter . getHolderAdapterPosition ( viewHolder ) ; if ( pos != RecyclerView . NO_POSITION ) { return adapter . getItem ( pos ) ; } return null... | helper method to get the item for this ViewHolder |
25,018 | private static Drawable getRippleMask ( int color , int radius ) { float [ ] outerRadius = new float [ 8 ] ; Arrays . fill ( outerRadius , radius ) ; RoundRectShape r = new RoundRectShape ( outerRadius , null , null ) ; ShapeDrawable shapeDrawable = new ShapeDrawable ( r ) ; shapeDrawable . getPaint ( ) . setColor ( co... | helper to create an ripple mask with the given color and radius |
25,019 | private static StateListDrawable getStateListDrawable ( int normalColor , int pressedColor ) { StateListDrawable states = new StateListDrawable ( ) ; states . addState ( new int [ ] { android . R . attr . state_pressed } , new ColorDrawable ( pressedColor ) ) ; states . addState ( new int [ ] { android . R . attr . sta... | helper to create an StateListDrawable for the given normal and pressed color |
25,020 | public static Set < IItem > getSelectedItems ( FastAdapter adapter ) { Set < IItem > selections = new HashSet < > ( ) ; int length = adapter . getItemCount ( ) ; List < IItem > items = new ArrayList < > ( ) ; for ( int i = 0 ; i < length ; i ++ ) { items . add ( adapter . getItem ( i ) ) ; } updateSelectedItemsWithColl... | returns a set of selected items regardless of their visibility |
25,021 | public static List < IItem > getAllItems ( List < IItem > items , boolean countHeaders , IPredicate predicate ) { return getAllItems ( items , countHeaders , false , predicate ) ; } | retrieves a flat list of the items in the provided list respecting subitems regardless of there current visibility |
25,022 | public static < T extends IItem & IExpandable > int countSelectedSubItems ( final FastAdapter adapter , T header ) { SelectExtension extension = ( SelectExtension ) adapter . getExtension ( SelectExtension . class ) ; if ( extension != null ) { Set < IItem > selections = extension . getSelectedItems ( ) ; return countS... | counts the selected items in the adapter underneath an expandable item recursively |
25,023 | public static List < IItem > deleteSelected ( final FastAdapter fastAdapter , final ExpandableExtension expandableExtension , boolean notifyParent , boolean deleteEmptyHeaders ) { List < IItem > deleted = new ArrayList < > ( ) ; LinkedList < IItem > selectedItems = new LinkedList < > ( getSelectedItems ( fastAdapter ) ... | deletes all selected items from the adapter respecting if the are sub items or not subitems are removed from their parents sublists main items are directly removed |
25,024 | public static List < IItem > delete ( final FastAdapter fastAdapter , final ExpandableExtension expandableExtension , Collection < Long > identifiersToDelete , boolean notifyParent , boolean deleteEmptyHeaders ) { List < IItem > deleted = new ArrayList < > ( ) ; if ( identifiersToDelete == null || identifiersToDelete .... | deletes all items in identifiersToDelete collection from the adapter respecting if there are sub items or not subitems are removed from their parents sublists main items are directly removed |
25,025 | private RecyclerView createRecyclerView ( ) { RecyclerView recyclerView = new RecyclerView ( getContext ( ) ) ; RecyclerView . LayoutParams params = new RecyclerView . LayoutParams ( ViewGroup . LayoutParams . MATCH_PARENT , ViewGroup . LayoutParams . MATCH_PARENT ) ; recyclerView . setLayoutParams ( params ) ; setCont... | Create the RecyclerView and set it as the dialog view . |
25,026 | public FastAdapterBottomSheetDialog < Item > withOnPreClickListener ( com . mikepenz . fastadapter . listeners . OnClickListener < Item > onPreClickListener ) { this . mFastAdapter . withOnPreClickListener ( onPreClickListener ) ; return this ; } | Define the OnPreClickListener which will be used for a single item and is called after all internal methods are done |
25,027 | private View getFirstViewUnobscuredByHeader ( RecyclerView parent , View firstHeader ) { boolean isReverseLayout = mOrientationProvider . isReverseLayout ( parent ) ; int step = isReverseLayout ? - 1 : 1 ; int from = isReverseLayout ? parent . getChildCount ( ) - 1 : 0 ; for ( int i = from ; i >= 0 && i <= parent . get... | Returns the first item currently in the RecyclerView that is not obscured by a header . |
25,028 | public Identifiable checkId ( Identifiable item ) { if ( item . getIdentifier ( ) == - 1 ) { item . withIdentifier ( nextId ( item ) ) ; } return item ; } | set an unique identifier for the item which do not have one set already |
25,029 | public void toggleSelection ( int position ) { if ( mFastAdapter . getItem ( position ) . isSelected ( ) ) { deselect ( position ) ; } else { select ( position ) ; } } | toggles the selection of the item at the given position |
25,030 | public void select ( Item item , boolean considerSelectableFlag ) { if ( considerSelectableFlag && ! item . isSelectable ( ) ) { return ; } item . withSetSelected ( true ) ; if ( mSelectionListener != null ) { mSelectionListener . onSelectionChanged ( item , true ) ; } } | select s a provided item this won t notify the adapter |
25,031 | public void deselect ( Iterable < Integer > positions ) { Iterator < Integer > entries = positions . iterator ( ) ; while ( entries . hasNext ( ) ) { deselect ( entries . next ( ) , entries ) ; } } | deselects all items at the positions in the iteratable |
25,032 | private void style ( View view , int value ) { view . setScaleX ( value ) ; view . setScaleY ( value ) ; view . setAlpha ( value ) ; } | helper method to style the heart view |
25,033 | public void animateHeart ( View imageLovedOn , View imageLovedOff , boolean on ) { imageLovedOn . setVisibility ( View . VISIBLE ) ; imageLovedOff . setVisibility ( View . VISIBLE ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB_MR1 ) { viewPropertyStartCompat ( imageLovedOff . animate ( ) . scal... | helper method to animate the heart view |
25,034 | public void apply ( List items ) { int size = items . size ( ) ; if ( size > 0 ) { if ( comparator != null ) { Collections . sort ( items , comparator ) ; } for ( int i = - 1 ; i < size ; i ++ ) { HeaderItem headerItem ; if ( i == - 1 ) { headerItem = groupingFunction . group ( null , ( Item ) items . get ( i + 1 ) , i... | call this when your list order has changed or was updated and you have to readd the headres |
25,035 | static String updateQueryAndParametersIndexes ( String parsedQuery , Map < String , List < Integer > > parameterNamesToIndexes , Map < String , Query . ParameterSetter > parameters , boolean allowArrayParameters ) { List < ArrayParameter > arrayParametersSortedAsc = arrayParametersSortedAsc ( parameterNamesToIndexes , ... | Update both the query and the parameter indexes to include the array parameters . |
25,036 | static Map < String , List < Integer > > updateParameterNamesToIndexes ( Map < String , List < Integer > > parametersNameToIndex , List < ArrayParameter > arrayParametersSortedAsc ) { for ( Map . Entry < String , List < Integer > > parameterNameToIndexes : parametersNameToIndex . entrySet ( ) ) { List < Integer > newPa... | Update the indexes of each query parameter |
25,037 | static int computeNewIndex ( int index , List < ArrayParameter > arrayParametersSortedAsc ) { int newIndex = index ; for ( ArrayParameter arrayParameter : arrayParametersSortedAsc ) { if ( index > arrayParameter . parameterIndex ) { newIndex = newIndex + arrayParameter . parameterCount - 1 ; } else { return newIndex ; ... | Compute the new index of a parameter given the index positions of the array parameters . |
25,038 | private static List < ArrayParameter > arrayParametersSortedAsc ( Map < String , List < Integer > > parameterNamesToIndexes , Map < String , Query . ParameterSetter > parameters , boolean allowArrayParameters ) { List < ArrayParameters . ArrayParameter > arrayParameters = new ArrayList < > ( ) ; for ( Map . Entry < Str... | List all the array parameters that contains more that 1 parameters . Indeed array parameter below 1 parameter will not change the text query nor the parameter indexes . |
25,039 | static String updateQueryWithArrayParameters ( String parsedQuery , List < ArrayParameter > arrayParametersSortedAsc ) { if ( arrayParametersSortedAsc . isEmpty ( ) ) { return parsedQuery ; } StringBuilder sb = new StringBuilder ( ) ; Iterator < ArrayParameter > parameterToReplaceIt = arrayParametersSortedAsc . iterato... | Change the query to replace ? at each arrayParametersSortedAsc . parameterIndex with ? ? ? .. multiple arrayParametersSortedAsc . parameterCount |
25,040 | public boolean hasNext ( ) { if ( next != null ) { return true ; } if ( resultSetFinished ) { return false ; } next = safeReadNext ( ) ; if ( next != null ) { return true ; } resultSetFinished = true ; return false ; } | used to note when result set exhausted |
25,041 | public Object get ( Object propertyName ) { if ( propertyName instanceof CharSequence ) { propertyName = propertyName . toString ( ) ; } if ( propertyName instanceof List ) { Map submap = new HashMap ( ) ; List propertyNames = ( List ) propertyName ; for ( Object currentName : propertyNames ) { if ( currentName != null... | Obtains the value of an object s properties on demand using Groovy s MOP . |
25,042 | protected GenericApplicationContext createApplicationContext ( ApplicationContext parentCtx ) { if ( parentCtx != null && beanFactory != null ) { Assert . isInstanceOf ( DefaultListableBeanFactory . class , beanFactory , "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory" ) ; return new GrailsApp... | Creates the ApplicationContext instance . Subclasses can override to customise the used ApplicationContext |
25,043 | protected void initialiseApplicationContext ( ) { if ( context != null ) { return ; } context = createApplicationContext ( parent ) ; if ( parent != null && classLoader == null ) { trySettingClassLoaderOnContextIfFoundInParent ( parent ) ; } else if ( classLoader != null ) { setClassLoaderOnContext ( classLoader ) ; } ... | Initialises the ApplicationContext instance . |
25,044 | public static GrailsApplication lookupApplication ( ServletContext servletContext ) { if ( servletContext == null ) { return null ; } GrailsApplication grailsApplication = ( GrailsApplication ) servletContext . getAttribute ( ApplicationAttributes . APPLICATION ) ; if ( grailsApplication != null ) { return grailsApplic... | Looks up a GrailsApplication instance from the ServletContext . |
25,045 | public static synchronized void runOperations ( ) { try { for ( Runnable shutdownOperation : shutdownOperations ) { try { shutdownOperation . run ( ) ; } catch ( Exception e ) { LOG . warn ( "Error occurred running shutdown operation: " + e . getMessage ( ) , e ) ; } } } finally { shutdownOperations . clear ( ) ; shutd... | Runs the shutdown operations |
25,046 | public static synchronized void addOperation ( Runnable runnable , boolean preserveForNextShutdown ) { shutdownOperations . add ( runnable ) ; if ( preserveForNextShutdown ) { preservedShutdownOperations . add ( runnable ) ; } } | Adds a shutdown operation |
25,047 | public < T > T getStaticPropertyValue ( String propName , Class < T > type ) { return ClassPropertyFetcher . getStaticPropertyValue ( getClazz ( ) , propName , type ) ; } | Get the value of the named static property . |
25,048 | public static void initialize ( Object instance , Map namedArgs ) { PersistentEntity dc = getDomainClass ( instance ) ; if ( dc == null ) { DataBindingUtils . bindObjectToInstance ( instance , namedArgs ) ; } else { DataBindingUtils . bindObjectToDomainInstance ( dc , instance , namedArgs ) ; DataBindingUtils . assignB... | A map based constructor that binds the named arguments to the target instance |
25,049 | public static void deprecated ( Class < ? > clazz , String methodOrPropName , String version ) { if ( LOG_DEPRECATED ) { deprecated ( "Property or method [" + methodOrPropName + "] of class [" + clazz . getName ( ) + "] is deprecated in [" + version + "] and will be removed in future releases" ) ; } } | Logs warning message about deprecation of specified property or method of some class . |
25,050 | public static void main ( String [ ] args ) { System . out . println ( version ) ; if ( args . length < 1 ) { initReadme ( ) ; if ( readme != null ) { System . out . println ( readme ) ; } printUsage ( System . out ) ; return ; } String name = args [ args . length - 1 ] ; for ( int i = 0 ; i < args . length - 1 ; i ++ ... | By default only look in the folder in parameter |
25,051 | public boolean shouldEncode ( Encoder encoderToApply , EncodingState encodingState ) { return ignoreEncodingState || ( encoderToApply != null && ( encodingState == null || shouldEncodeWith ( encoderToApply , encodingState ) ) ) ; } | Check if the encoder should be used to a input with certain encodingState |
25,052 | protected void encodeAndWrite ( Encoder encoder , EncodingState newEncodingState , CharSequence input ) throws IOException { Object encoded = encoder . encode ( input ) ; if ( encoded != null ) { String encodedStr = String . valueOf ( encoded ) ; write ( newEncodingState , encodedStr , 0 , encodedStr . length ( ) ) ; }... | Encode and write input to buffer using a non - streaming encoder |
25,053 | public String getContextPath ( ) { final HttpServletRequest request = getCurrentRequest ( ) ; String appUri = ( String ) request . getAttribute ( GrailsApplicationAttributes . APP_URI_ATTRIBUTE ) ; if ( appUri == null ) { appUri = urlHelper . getContextPath ( request ) ; } return appUri ; } | Returns the context path of the request . |
25,054 | public boolean isFlowRequest ( ) { GrailsApplication application = getAttributes ( ) . getGrailsApplication ( ) ; Object controllerClassObject = getControllerClass ( ) ; GrailsControllerClass controllerClass = null ; if ( controllerClassObject instanceof GrailsControllerClass ) { controllerClass = ( GrailsControllerCla... | Returns true if the current executing request is a flow request |
25,055 | public PropertyEditorRegistry getPropertyEditorRegistry ( ) { final HttpServletRequest servletRequest = getCurrentRequest ( ) ; PropertyEditorRegistry registry = ( PropertyEditorRegistry ) servletRequest . getAttribute ( GrailsApplicationAttributes . PROPERTY_REGISTRY ) ; if ( registry == null ) { registry = new Proper... | Obtains the PropertyEditorRegistry instance . |
25,056 | public static GrailsWebRequest lookup ( HttpServletRequest request ) { GrailsWebRequest webRequest = ( GrailsWebRequest ) request . getAttribute ( GrailsApplicationAttributes . WEB_REQUEST ) ; return webRequest == null ? lookup ( ) : webRequest ; } | Looks up the GrailsWebRequest from the current request . |
25,057 | public static GrailsWebRequest lookup ( ) { GrailsWebRequest webRequest = null ; RequestAttributes requestAttributes = RequestContextHolder . getRequestAttributes ( ) ; if ( requestAttributes instanceof GrailsWebRequest ) { webRequest = ( GrailsWebRequest ) requestAttributes ; } return webRequest ; } | Looks up the current Grails WebRequest instance |
25,058 | protected boolean isApplicationClass ( String className ) { for ( String packageName : packagesToFilter ) { if ( className . startsWith ( packageName ) ) return false ; } return true ; } | Whether the given class name is an internal class and should be filtered |
25,059 | private static final void registerPrimitiveClassPair ( Class < ? > left , Class < ? > right ) { PRIMITIVE_TYPE_COMPATIBLE_CLASSES . put ( left , right ) ; PRIMITIVE_TYPE_COMPATIBLE_CLASSES . put ( right , left ) ; } | Just add two entries to the class compatibility map |
25,060 | public static Class [ ] getAllInterfaces ( Object instance ) { Assert . notNull ( instance , "Instance must not be null" ) ; return getAllInterfacesForClass ( instance . getClass ( ) ) ; } | Return all interfaces that the given instance implements as array including ones implemented by superclasses . |
25,061 | public static boolean isPropertyOfType ( Class < ? > clazz , String propertyName , Class < ? > type ) { try { Class < ? > propType = getPropertyType ( clazz , propertyName ) ; return propType != null && propType . equals ( type ) ; } catch ( Exception e ) { return false ; } } | Returns true if the specified property in the specified class is of the specified type |
25,062 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static Object getPropertyValueOfNewInstance ( Class clazz , String propertyName , Class < ? > propertyType ) { if ( clazz == null || ! StringUtils . hasText ( propertyName ) ) { return null ; } try { return getPropertyOrStaticPropertyOrFieldValue ( BeanUtils . ... | Returns the value of the specified property and type from an instance of the specified Grails class |
25,063 | public static PropertyDescriptor getPropertyDescriptorForValue ( Object instance , Object propertyValue ) { if ( instance == null || propertyValue == null ) { return null ; } PropertyDescriptor [ ] descriptors = BeanUtils . getPropertyDescriptors ( instance . getClass ( ) ) ; for ( PropertyDescriptor pd : descriptors )... | Retrieves a PropertyDescriptor for the specified instance and property value |
25,064 | public static Class < ? > getPropertyType ( Class < ? > clazz , String propertyName ) { if ( clazz == null || ! StringUtils . hasText ( propertyName ) ) { return null ; } try { PropertyDescriptor desc = BeanUtils . getPropertyDescriptor ( clazz , propertyName ) ; if ( desc != null ) { return desc . getPropertyType ( ) ... | Returns the type of the given property contained within the specified class |
25,065 | public static PropertyDescriptor [ ] getPropertiesAssignableToType ( Class < ? > clazz , Class < ? > propertySuperType ) { if ( clazz == null || propertySuperType == null ) return new PropertyDescriptor [ 0 ] ; Set < PropertyDescriptor > properties = new HashSet < PropertyDescriptor > ( ) ; PropertyDescriptor descripto... | Retrieves all the properties of the given class which are assignable to the given type |
25,066 | @ SuppressWarnings ( "rawtypes" ) public static boolean isMatchBetweenPrimativeAndWrapperTypes ( Class leftType , Class rightType ) { if ( leftType == null ) { throw new NullPointerException ( "Left type is null!" ) ; } if ( rightType == null ) { throw new NullPointerException ( "Right type is null!" ) ; } Class < ? > ... | Detect if left and right types are matching types . In particular test if one is a primitive type and the other is the corresponding Java wrapper type . Primitive and wrapper classes may be passed to either arguments . |
25,067 | public static boolean isPublicStatic ( Method m ) { final int modifiers = m . getModifiers ( ) ; return Modifier . isPublic ( modifiers ) && Modifier . isStatic ( modifiers ) ; } | Determine whether the method is declared public static |
25,068 | public static boolean isPublicStatic ( Field f ) { final int modifiers = f . getModifiers ( ) ; return Modifier . isPublic ( modifiers ) && Modifier . isStatic ( modifiers ) ; } | Determine whether the field is declared public static |
25,069 | public static Object getFieldValue ( Object obj , String name ) { Class < ? > clazz = obj . getClass ( ) ; try { Field f = clazz . getDeclaredField ( name ) ; return f . get ( obj ) ; } catch ( Exception e ) { return null ; } } | Get the value of a declared field on an object |
25,070 | public static boolean isPublicField ( Object obj , String name ) { Class < ? > clazz = obj . getClass ( ) ; try { Field f = clazz . getDeclaredField ( name ) ; return Modifier . isPublic ( f . getModifiers ( ) ) ; } catch ( NoSuchFieldException e ) { return false ; } } | Work out if the specified object has a public field with the name supplied . |
25,071 | @ SuppressWarnings ( "rawtypes" ) public static boolean isPropertyInherited ( Class clz , String propertyName ) { if ( clz == null ) return false ; Assert . isTrue ( StringUtils . hasText ( propertyName ) , "Argument [propertyName] cannot be null or blank" ) ; Class < ? > superClass = clz . getSuperclass ( ) ; Property... | Checks whether the specified property is inherited from a super class |
25,072 | public static boolean isPropertyGetter ( Method method ) { return ! Modifier . isStatic ( method . getModifiers ( ) ) && Modifier . isPublic ( method . getModifiers ( ) ) && GrailsNameUtils . isGetter ( method . getName ( ) , method . getReturnType ( ) , method . getParameterTypes ( ) ) ; } | Check whether the specified method is a property getter |
25,073 | @ SuppressWarnings ( "rawtypes" ) public static Collection createConcreteCollection ( Class interfaceType ) { Collection elements ; if ( interfaceType . equals ( List . class ) || interfaceType . equals ( Collection . class ) ) { elements = new ArrayList ( ) ; } else if ( interfaceType . equals ( SortedSet . class ) ) ... | Creates a concrete collection for the suppied interface |
25,074 | @ SuppressWarnings ( "rawtypes" ) public static boolean isSetter ( String name , Class [ ] args ) { if ( ! StringUtils . hasText ( name ) || args == null ) return false ; if ( name . startsWith ( "set" ) ) { if ( args . length != 1 ) return false ; return GrailsNameUtils . isPropertyMethodSuffix ( name . substring ( 3 ... | Returns true if the name of the method specified and the number of arguments make it a javabean property setter . The name is assumed to be a valid Java method name that is not verified . |
25,075 | public static boolean isAssignableOrConvertibleFrom ( Class < ? > clazz , Class < ? > type ) { if ( type == null || clazz == null ) { return false ; } if ( type . isPrimitive ( ) ) { Class < ? > primitiveClass = GrailsClassUtils . PRIMITIVE_TYPE_COMPATIBLE_CLASSES . get ( type ) ; if ( primitiveClass == null ) { return... | Returns true if the specified clazz parameter is either the same as or is a superclass or superinterface of the specified type parameter . Converts primitive types to compatible class automatically . |
25,076 | public static String findPropertyNameForValue ( Object target , Object obj ) { MetaClass mc = GroovySystem . getMetaClassRegistry ( ) . getMetaClass ( target . getClass ( ) ) ; List < MetaProperty > metaProperties = mc . getProperties ( ) ; for ( MetaProperty metaProperty : metaProperties ) { if ( isAssignableOrConvert... | Locates the name of a property for the given value on the target object using Groovy s meta APIs . Note that this method uses the reference so the incorrect result could be returned for two properties that refer to the same reference . Use with caution . |
25,077 | public static boolean isClassBelowPackage ( Class < ? > theClass , List < ? > packageList ) { String classPackage = theClass . getPackage ( ) . getName ( ) ; for ( Object packageName : packageList ) { if ( packageName != null ) { if ( classPackage . startsWith ( packageName . toString ( ) ) ) { return true ; } } } retu... | Returns whether the specified class is either within one of the specified packages or within a subpackage of one of the packages |
25,078 | protected void populateParamsForMapping ( GrailsWebRequest webRequest ) { Map dispatchParams = webRequest . getParams ( ) ; String encoding = webRequest . getRequest ( ) . getCharacterEncoding ( ) ; if ( encoding == null ) encoding = "UTF-8" ; for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) { Stri... | Populates request parameters for the given UrlMappingInfo instance using the GrailsWebRequest |
25,079 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static void copyExpandoMetaClass ( Class < ? > fromClass , Class < ? > toClass , boolean removeSource ) { MetaClassRegistry registry = getRegistry ( ) ; MetaClass oldMetaClass = registry . getMetaClass ( fromClass ) ; AdaptingMetaClass adapter = null ; ExpandoM... | Copies the ExpandoMetaClass dynamic methods and properties from one Class to another . |
25,080 | public void skipPast ( String to ) { this . myIndex = this . mySource . indexOf ( to , this . myIndex ) ; if ( this . myIndex < 0 ) { this . myIndex = this . mySource . length ( ) ; } else { this . myIndex += to . length ( ) ; } } | Skip characters until past the requested string . If it is not found we are left at the end of the source . |
25,081 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < K , V > V getValue ( ConcurrentMap < K , CacheEntry < V > > map , K key , long timeoutMillis , Callable < V > updater , Callable < ? extends CacheEntry > cacheEntryFactory , boolean returnExpiredWhileUpdating , Object cacheRequestObject ) { CacheEntry ... | Gets a value from cache . If the key doesn t exist it will create the value using the updater callback Prevents cache storms with a lock |
25,082 | public V getValue ( long timeout , Callable < V > updater , boolean returnExpiredWhileUpdating , Object cacheRequestObject ) { if ( ! isInitialized ( ) || hasExpired ( timeout , cacheRequestObject ) ) { boolean lockAcquired = false ; try { long beforeLockingCreatedMillis = createdMillis ; if ( returnExpiredWhileUpdatin... | gets the current value from the entry and updates it if it s older than timeout |
25,083 | public static Encoder lookupEncoder ( GrailsApplication grailsApplication , String codecName ) { ApplicationContext ctx = grailsApplication != null ? grailsApplication . getMainContext ( ) : null ; if ( ctx != null ) { try { CodecLookup codecLookup = ctx . getBean ( "codecLookup" , CodecLookup . class ) ; return codecL... | Lookup encoder . |
25,084 | public void updateConstantMetaClass ( MetaClassRegistryChangeEvent cmcu ) { Class < ? > classToUpdate = cmcu . getClassToUpdate ( ) ; MetaClass newMetaClass = cmcu . getNewMetaClass ( ) ; System . out . println ( "Class [" + classToUpdate + "] updated MetaClass to [" + newMetaClass + "]" ) ; Thread . dumpStack ( ) ; } | Called when the a constant MetaClass is updated . If the new MetaClass is null then the MetaClass is removed . Be careful while this method is executed other updates may happen . If you want this method thread safe you have to take care of that by yourself . |
25,085 | public static String getPropertyForSetter ( String setterName ) { if ( setterName == null || setterName . length ( ) == 0 ) return null ; if ( setterName . startsWith ( "set" ) ) { String prop = setterName . substring ( 3 ) ; return convertValidPropertyMethodSuffix ( prop ) ; } return null ; } | Returns a property name equivalent for the given setter name or null if it is not a valid setter . If not null or empty the setter name is assumed to be a valid identifier . |
25,086 | private MethodNode convertToMethodAction ( ClassNode classNode , MethodNode methodNode , SourceUnit source , GeneratorContext context ) { final ClassNode returnType = methodNode . getReturnType ( ) ; Parameter [ ] parameters = methodNode . getParameters ( ) ; for ( Parameter param : parameters ) { if ( param . hasIniti... | Converts a method into a controller action . If the method accepts parameters a no - arg counterpart is created which delegates to the original . |
25,087 | private boolean doesModulePathIncludeSubstring ( ModuleNode moduleNode , final String substring ) { if ( moduleNode == null ) { return false ; } boolean substringFoundInDescription = false ; String commandObjectModuleDescription = moduleNode . getDescription ( ) ; if ( commandObjectModuleDescription != null ) { substri... | Checks to see if a Module is defined at a path which includes the specified substring |
25,088 | public String getViewURI ( GroovyObject controller , String viewName ) { return getViewURI ( getLogicalControllerName ( controller ) , viewName ) ; } | Obtains a view URI of the given controller and view name |
25,089 | public String getNoSuffixViewURI ( GroovyObject controller , String viewName ) { return getNoSuffixViewURI ( getLogicalControllerName ( controller ) , viewName ) ; } | Obtains a view URI of the given controller and view name without the suffix |
25,090 | public String getAbsoluteTemplateURI ( String templateName , boolean includeExtension ) { FastStringWriter buf = new FastStringWriter ( ) ; String tmp = templateName . substring ( 1 , templateName . length ( ) ) ; if ( tmp . indexOf ( SLASH ) > - 1 ) { buf . append ( SLASH ) ; int i = tmp . lastIndexOf ( SLASH ) ; buf ... | Used to resolve template names that are not relative to a controller . |
25,091 | public String getViewURI ( String controllerName , String viewName ) { FastStringWriter buf = new FastStringWriter ( ) ; return getViewURIInternal ( controllerName , viewName , buf , true ) ; } | Obtains a view URI of the given controller name and view name |
25,092 | public String getAbsoluteViewURI ( String viewName ) { FastStringWriter buf = new FastStringWriter ( ) ; return getAbsoluteViewURIInternal ( viewName , buf , true ) ; } | Obtains a view URI that is not relative to any given controller |
25,093 | public String getNoSuffixViewURI ( String controllerName , String viewName ) { FastStringWriter buf = new FastStringWriter ( ) ; return getViewURIInternal ( controllerName , viewName , buf , false ) ; } | Obtains a view URI of the given controller name and view name without the suffix |
25,094 | public static boolean shouldEncodeWith ( Encoder encoderToApply , EncodingState currentEncodingState ) { if ( isNoneEncoder ( encoderToApply ) ) return false ; if ( currentEncodingState != null && currentEncodingState . getEncoders ( ) != null ) { for ( Encoder encoder : currentEncodingState . getEncoders ( ) ) { if ( ... | Checks if encoder should be applied to a input with given encoding state |
25,095 | public static boolean isPreviousEncoderSafeOrEqual ( Encoder encoderToApply , Encoder previousEncoder ) { return previousEncoder == encoderToApply || ! encoderToApply . isApplyToSafelyEncoded ( ) && previousEncoder . isSafe ( ) && encoderToApply . isSafe ( ) || previousEncoder . getCodecIdentifier ( ) . isEquivalent ( ... | Checks if is previous encoder is already safe equal or equivalent |
25,096 | public static boolean isDomainClass ( URL url ) { if ( url == null ) return false ; return KNOWN_DOMAIN_CLASSES . get ( url . getFile ( ) ) ; } | Checks whether the file referenced by the given url is a domain class |
25,097 | public static String getClassNameForClassFile ( String rootDir , String path ) { path = path . replace ( "/" , "." ) ; path = path . replace ( '\\' , '.' ) ; path = path . substring ( 0 , path . length ( ) - CLASS_EXTENSION . length ( ) ) ; if ( rootDir != null ) { path = path . substring ( rootDir . length ( ) ) ; } r... | Returns the class name for a compiled class file |
25,098 | public static boolean isGrailsResource ( Resource r ) { try { String file = r . getURL ( ) . getFile ( ) ; return isGrailsPath ( file ) || file . endsWith ( "GrailsPlugin.groovy" ) ; } catch ( IOException e ) { return false ; } } | Checks whether the specific resources is a Grails resource . A Grails resource is a Groovy or Java class under the grails - app directory |
25,099 | public static String getPathFromBaseDir ( String path ) { int i = path . indexOf ( "grails-app/" ) ; if ( i > - 1 ) { return path . substring ( i + 11 ) ; } else { try { File baseDir = BuildSettings . BASE_DIR ; String basePath = baseDir != null ? baseDir . getCanonicalPath ( ) : null ; if ( basePath != null ) { String... | Gets the path relative to the project base directory . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.