idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
13,300
public void billingAccount_voicemail_serviceName_migrateOnNewVersion_POST ( String billingAccount , String serviceName ) throws IOException { String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/migrateOnNewVersion" ; StringBuilder sb = path ( qPath , billingAccount , serviceName ) ; exec ( qPath , "POST" , sb . toString ( ) , null ) ; }
Change the voicemail on a new version to manager greetings directories and extra settings .
100
17
13,301
public ArrayList < Long > billingAccount_voicemail_serviceName_directories_GET ( String billingAccount , String serviceName , OvhVoicemailMessageFolderDirectoryEnum dir ) throws IOException { String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/directories" ; StringBuilder sb = path ( qPath , billingAccount , serviceName ) ; query ( sb , "dir" , dir ) ; String resp = exec ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t2 ) ; }
Voicemail directory messages
135
5
13,302
public void billingAccount_voicemail_serviceName_directories_id_move_POST ( String billingAccount , String serviceName , Long id , OvhVoicemailMessageFolderDirectoryEnum dir ) throws IOException { String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}/move" ; StringBuilder sb = path ( qPath , billingAccount , serviceName , id ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "dir" , dir ) ; exec ( qPath , "POST" , sb . toString ( ) , o ) ; }
Move the message to another directory
153
6
13,303
public OvhPcsFile billingAccount_voicemail_serviceName_directories_id_download_GET ( String billingAccount , String serviceName , Long id , OvhServiceVoicemailAudioFormatEnum format ) throws IOException { String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/directories/{id}/download" ; StringBuilder sb = path ( qPath , billingAccount , serviceName , id ) ; query ( sb , "format" , format ) ; String resp = exec ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , OvhPcsFile . class ) ; }
Get a url to download the sound file
155
8
13,304
public void billingAccount_voicemail_serviceName_settings_changePassword_POST ( String billingAccount , String serviceName , String password ) throws IOException { String qPath = "/telephony/{billingAccount}/voicemail/{serviceName}/settings/changePassword" ; StringBuilder sb = path ( qPath , billingAccount , serviceName ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "password" , password ) ; exec ( qPath , "POST" , sb . toString ( ) , o ) ; }
Change the voicemail password . It must be 4 digit
133
11
13,305
public OvhTrunkExternalDisplayedNumber billingAccount_trunk_serviceName_externalDisplayedNumber_POST ( String billingAccount , String serviceName , Boolean autoValidation , String number ) throws IOException { String qPath = "/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber" ; StringBuilder sb = path ( qPath , billingAccount , serviceName ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "autoValidation" , autoValidation ) ; addBody ( o , "number" , number ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , o ) ; return convertTo ( resp , OvhTrunkExternalDisplayedNumber . class ) ; }
External displayed number creation for a given trunk
180
8
13,306
public void billingAccount_trunk_serviceName_externalDisplayedNumber_number_DELETE ( String billingAccount , String serviceName , String number ) throws IOException { String qPath = "/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}" ; StringBuilder sb = path ( qPath , billingAccount , serviceName , number ) ; exec ( qPath , "DELETE" , sb . toString ( ) , null ) ; }
Delete an external displayed number for a given trunk
110
9
13,307
public OvhTrunkExternalDisplayedNumberValidation billingAccount_trunk_serviceName_externalDisplayedNumber_number_validate_POST ( String billingAccount , String serviceName , String number ) throws IOException { String qPath = "/telephony/{billingAccount}/trunk/{serviceName}/externalDisplayedNumber/{number}/validate" ; StringBuilder sb = path ( qPath , billingAccount , serviceName , number ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , null ) ; return convertTo ( resp , OvhTrunkExternalDisplayedNumberValidation . class ) ; }
Generate a phone call for validation . Returned validation code should be typed when asked .
145
18
13,308
public void billingAccount_transferSecurityDeposit_POST ( String billingAccount , Long amount , String billingAccountDestination ) throws IOException { String qPath = "/telephony/{billingAccount}/transferSecurityDeposit" ; StringBuilder sb = path ( qPath , billingAccount ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "amount" , amount ) ; addBody ( o , "billingAccountDestination" , billingAccountDestination ) ; exec ( qPath , "POST" , sb . toString ( ) , o ) ; }
Transfer security deposit between two billing accounts
135
7
13,309
public ArrayList < Long > billingAccount_offerTask_GET ( String billingAccount , OvhOfferTaskActionEnum action , OvhTaskStatusEnum status , OvhOfferTaskTypeEnum type ) throws IOException { String qPath = "/telephony/{billingAccount}/offerTask" ; StringBuilder sb = path ( qPath , billingAccount ) ; query ( sb , "action" , action ) ; query ( sb , "status" , status ) ; query ( sb , "type" , type ) ; String resp = exec ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t2 ) ; }
Operations on a telephony service s offer
152
9
13,310
public OvhConsumptionThreshold billingAccount_outplanNotification_POST ( String billingAccount , OvhOutplanNotificationBlockEnum block , String notifyEmail , Double percentage ) throws IOException { String qPath = "/telephony/{billingAccount}/outplanNotification" ; StringBuilder sb = path ( qPath , billingAccount ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "block" , block ) ; addBody ( o , "notifyEmail" , notifyEmail ) ; addBody ( o , "percentage" , percentage ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , o ) ; return convertTo ( resp , OvhConsumptionThreshold . class ) ; }
Add an outplan notification on the billing account
177
9
13,311
public OvhHistoryRepaymentConsumption billingAccount_historyRepaymentConsumption_POST ( String billingAccount , String billingNumber ) throws IOException { String qPath = "/telephony/{billingAccount}/historyRepaymentConsumption" ; StringBuilder sb = path ( qPath , billingAccount ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "billingNumber" , billingNumber ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , o ) ; return convertTo ( resp , OvhHistoryRepaymentConsumption . class ) ; }
Ask for a new repayment
146
5
13,312
public OvhTask billingAccount_ddi_serviceName_changeDestination_POST ( String billingAccount , String serviceName , String destination ) throws IOException { String qPath = "/telephony/{billingAccount}/ddi/{serviceName}/changeDestination" ; StringBuilder sb = path ( qPath , billingAccount , serviceName ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "destination" , destination ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , o ) ; return convertTo ( resp , OvhTask . class ) ; }
Change the destination of the DDI
148
7
13,313
public ArrayList < OvhAccessoryOffer > accessories_GET ( OvhNumberCountryEnum country ) throws IOException { String qPath = "/telephony/accessories" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; String resp = exec ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t19 ) ; }
Get all available accessories
95
4
13,314
public ArrayList < OvhTelephonySearchService > searchServices_GET ( String axiom ) throws IOException { String qPath = "/telephony/searchServices" ; StringBuilder sb = path ( qPath ) ; query ( sb , "axiom" , axiom ) ; String resp = exec ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t20 ) ; }
Search a service with its domain to get its billing account and type
95
13
13,315
public ArrayList < OvhNumberDetailedZone > number_detailedZones_GET ( String axiom , OvhNumberCountryEnum country ) throws IOException { String qPath = "/telephony/number/detailedZones" ; StringBuilder sb = path ( qPath ) ; query ( sb , "axiom" , axiom ) ; query ( sb , "country" , country ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t21 ) ; }
Get all available geographic zone with some details from a country
123
11
13,316
public ArrayList < OvhSpecificNumber > number_specificNumbers_GET ( OvhNumberCountryEnum country , String range , OvhNumberTypeEnum type , String zone ) throws IOException { String qPath = "/telephony/number/specificNumbers" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; query ( sb , "range" , range ) ; query ( sb , "type" , type ) ; query ( sb , "zone" , zone ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t22 ) ; }
Get all available specific number from a country
150
8
13,317
public ArrayList < OvhCity > directories_cities_GET ( OvhNumberCountryEnum country , String zipCode ) throws IOException { String qPath = "/telephony/directories/cities" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; query ( sb , "zipCode" , zipCode ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t23 ) ; }
Get city informations from a zip code
118
8
13,318
public ArrayList < String > directories_availableZipCodes_GET ( OvhNumberCountryEnum country , String number ) throws IOException { String qPath = "/telephony/directories/availableZipCodes" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; query ( sb , "number" , number ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t4 ) ; }
Get all zip codes compatible for a number
117
8
13,319
public OvhSound sounds_POST ( String description , String filename ) throws IOException { String qPath = "/telephony/sounds" ; StringBuilder sb = path ( qPath ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "description" , description ) ; addBody ( o , "filename" , filename ) ; String resp = exec ( qPath , "POST" , sb . toString ( ) , o ) ; return convertTo ( resp , OvhSound . class ) ; }
Create a new sound
122
4
13,320
public ArrayList < OvhLinePhone > line_offer_phones_GET ( OvhNumberCountryEnum country , String offer ) throws IOException { String qPath = "/telephony/line/offer/phones" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; query ( sb , "offer" , offer ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t8 ) ; }
Get all available phone brands compatible with lines
117
8
13,321
public ArrayList < OvhLineOffer > fax_offers_GET ( OvhNumberCountryEnum country ) throws IOException { String qPath = "/telephony/fax/offers" ; StringBuilder sb = path ( qPath ) ; query ( sb , "country" , country ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t15 ) ; }
Get all available fax offer compatible
101
6
13,322
public void spare_spare_replace_POST ( String spare , String domain , String ip ) throws IOException { String qPath = "/telephony/spare/{spare}/replace" ; StringBuilder sb = path ( qPath , spare ) ; HashMap < String , Object > o = new HashMap < String , Object > ( ) ; addBody ( o , "domain" , domain ) ; addBody ( o , "ip" , ip ) ; exec ( qPath , "POST" , sb . toString ( ) , o ) ; }
Replace the phone by its spare . The broken phone became a spare if it was bought . An RMA is created if the broken phone is under securitydeposit .
121
34
13,323
public ArrayList < String > spare_brands_GET ( ) throws IOException { String qPath = "/telephony/spare/brands" ; StringBuilder sb = path ( qPath ) ; String resp = execN ( qPath , "GET" , sb . toString ( ) , null ) ; return convertTo ( resp , t4 ) ; }
Get all available spare brands
79
5
13,324
void removeResourceModels ( final Bundle bundle ) { this . logger . info ( "Removing resource models of bundle " + displayNameOf ( bundle ) + "..." ) ; MatchedBundlesPredicate sourcesWithBundles = new MatchedBundlesPredicate ( bundle ) ; for ( Collection < OsgiModelSource < ? > > values : this . typeNameToModelSourcesMap . values ( ) ) { CollectionUtils . filter ( values , sourcesWithBundles ) ; } clearLookupCaches ( ) ; this . logger . info ( "Removed " + sourcesWithBundles . getFilteredElements ( ) + " resource models of bundle " + displayNameOf ( bundle ) + "..." ) ; }
Removes all resource models originating from the given bundle from this registry .
157
14
13,325
public synchronized void removeMetadataForModelsIn ( Bundle bundle ) { if ( bundle == null ) { throw new IllegalArgumentException ( "method parameter bundle must not be null" ) ; } Map < Class < ? > , ResourceModelMetadataHolder > newCache = copyCache ( ) ; Iterator < Map . Entry < Class < ? > , ResourceModelMetadataHolder > > it = newCache . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { OsgiModelSource < ? > source = it . next ( ) . getValue ( ) . source ; if ( source . getBundleId ( ) == bundle . getBundleId ( ) ) { it . remove ( ) ; } } this . cache = newCache ; }
Removes the metadata of all models contained in the provided bundle from the registrar .
166
17
13,326
private static boolean isPropertyType ( Class < ? > type ) { return type . isPrimitive ( ) || type == String . class || type == Date . class || type == Calendar . class || ClassUtils . wrapperToPrimitive ( type ) != null ; }
Whether a property cannot be represented by a resource but must stem from a value map representing the properties of a resource .
56
23
13,327
public void removeValue ( V value ) { if ( value == null ) { throw new IllegalArgumentException ( "Method argument value must not be null." ) ; } for ( Collection < V > values : values ( ) ) { values . remove ( value ) ; } }
Removes the given value from all collections stored under any key .
57
13
13,328
@ Override @ Async public void onOsgiApplicationEvent ( OsgiBundleApplicationContextEvent event ) { // We need to use the generic OsgiBundleApplicationContextEvent here and test // for instanceof since gemini-blueprint does not correctly determine // the event type we are listening for. if ( event instanceof OsgiBundleContextFailedEvent ) { final Bundle bundle = event . getBundle ( ) ; handleStop ( bundle ) ; stop ( bundle ) ; } }
This method is executed asynchronously since the original extender thread may try to obtain a lock to the OSGi framework s registry state during the stop while holding the event handling lock which may result in a transitive deadlock .
104
46
13,329
void handleStop ( Bundle bundle ) { if ( bundle == null ) { throw new IllegalArgumentException ( "Method argument bundle must not be null." ) ; } this . logger . info ( "Removing infrastructure for bundle: " + bundle + "..." ) ; this . modelRegistrar . unregister ( bundle ) ; this . dispatcherServlet . disableMvc ( bundle ) ; this . logger . info ( "Infrastructure for {} removed." , bundle ) ; }
We must guarantee the order in which the event is consumed by the collaborators since subsequent operations may depend on the resulting state .
99
24
13,330
public static < K , T extends Collection < K > > Collection < K > instantiateCollectionType ( Class < T > collectionType ) { return instantiateCollectionType ( collectionType , DEFAULT_COLLECTION_SIZE ) ; }
Creates an instance with a default capacity .
49
9
13,331
public static List < Method > methodsOf ( Class < ? > type ) { if ( type == null ) { throw new IllegalArgumentException ( "Method argument type must not be null" ) ; } List < Method > methods = new LinkedList <> ( ) ; Queue < Class < ? > > classes = new LinkedList <> ( ) ; classes . add ( type ) ; while ( ! classes . isEmpty ( ) ) { Class < ? > c = classes . poll ( ) ; methods . addAll ( asList ( c . getDeclaredMethods ( ) ) ) ; if ( c . getSuperclass ( ) != null ) { classes . add ( c . getSuperclass ( ) ) ; } addAll ( classes , c . getInterfaces ( ) ) ; } return methods ; }
All methods of the given type its super types and interfaces starting with the methods of the given type .
171
20
13,332
public ResourceModelStatistics countMappingDuration ( int durationInMs ) { // The right-hand interval boundaries are pre-calculated. We start at the smallest (1) of the // interval [0, 1). Thus, when our value is less than the boundary, we know it is in the current interval (i), // as the right-hand boundary is exclusive. for ( int i = 0 ; i < this . indexBoundaries . length ; ++ i ) { if ( durationInMs < this . indexBoundaries [ i ] ) { ++ this . mappingDurationFrequencies [ i ] ; return this ; } } // The mapping duration time exceeds the frequency table boundaries. // Fallback: count it as the longest possible duration ++ this . mappingDurationFrequencies [ this . mappingDurationFrequencies . length - 1 ] ; return this ; }
Adds the mapping with the duration to the statistics .
179
10
13,333
public static String [ ] appendToAll ( String append , String [ ] appendTo ) { if ( append == null ) { throw new IllegalArgumentException ( "Method argument append must not be null." ) ; } if ( appendTo == null ) { throw new IllegalArgumentException ( "Method argument to must not be null." ) ; } String [ ] result = new String [ appendTo . length ] ; for ( int i = 0 ; i < appendTo . length ; ++ i ) { result [ i ] = appendTo [ i ] == null ? null : appendTo [ i ] + append ; } return result ; }
Appends the given String to all elements of the given array .
132
13
13,334
public static ChronoZonedDateTime zonedTime ( final Object target , final ZoneId defaultZoneId ) { Validate . notNull ( target , "Target cannot be null" ) ; Validate . notNull ( defaultZoneId , "ZoneId cannot be null" ) ; if ( target instanceof Instant ) { return ZonedDateTime . ofInstant ( ( Instant ) target , defaultZoneId ) ; } else if ( target instanceof LocalDate ) { return ZonedDateTime . of ( ( LocalDate ) target , LocalTime . MIDNIGHT , defaultZoneId ) ; } else if ( target instanceof LocalDateTime ) { return ZonedDateTime . of ( ( LocalDateTime ) target , defaultZoneId ) ; } else if ( target instanceof LocalTime ) { return ZonedDateTime . of ( LocalDate . now ( ) , ( LocalTime ) target , defaultZoneId ) ; } else if ( target instanceof OffsetDateTime ) { return ( ( OffsetDateTime ) target ) . toZonedDateTime ( ) ; } else if ( target instanceof OffsetTime ) { LocalTime localTime = ( ( OffsetTime ) target ) . toLocalTime ( ) ; return ZonedDateTime . of ( LocalDate . now ( ) , localTime , defaultZoneId ) ; } else if ( target instanceof Year ) { LocalDate localDate = ( ( Year ) target ) . atDay ( 1 ) ; return ZonedDateTime . of ( localDate , LocalTime . MIDNIGHT , defaultZoneId ) ; } else if ( target instanceof YearMonth ) { LocalDate localDate = ( ( YearMonth ) target ) . atDay ( 1 ) ; return ZonedDateTime . of ( localDate , LocalTime . MIDNIGHT , defaultZoneId ) ; } else if ( target instanceof ZonedDateTime ) { return ( ChronoZonedDateTime ) target ; } else { throw new IllegalArgumentException ( "Cannot format object of class \"" + target . getClass ( ) . getName ( ) + "\" as a date" ) ; } }
Creates a Temporal object filling the missing fields of the provided time with default values .
449
18
13,335
public boolean export ( Context context , Class < ? > spaceClass , String accessToken ) { successful = false ; final SpaceHelper helper = crateSpaceHelper ( spaceClass ) ; final String outputPath = createOutputPath ( helper ) ; final CountDownLatch countDownLatch = new CountDownLatch ( 1 ) ; final Vault vault = Vault . with ( context , spaceClass ) ; vault . requestSync ( SyncConfig . builder ( ) . setSpaceId ( helper . getSpaceId ( ) ) . setAccessToken ( accessToken ) . build ( ) , new SyncCallback ( ) { @ Override public void onResult ( SyncResult result ) { try { successful = saveResultInDatabaseFile ( result , vault , outputPath ) ; } catch ( Throwable t ) { t . printStackTrace ( System . err ) ; } finally { countDownLatch . countDown ( ) ; } } } , new Executor ( ) { @ Override public void execute ( Runnable runnable ) { runnable . run ( ) ; } } ) ; try { countDownLatch . await ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( System . err ) ; } return successful ; }
Use this method to export Contentful spaces into sqlite3 databases which can be imported later .
262
19
13,336
public static String generateSetupJavaScript ( List < String > prefixes ) { Map < String , String > webJars = new WebJarAssetLocator ( ) . getWebJars ( ) ; return generateSetupJavaScript ( prefixes , webJars ) ; }
Returns the JavaScript that is used to setup the RequireJS config . This value is not cached .
57
20
13,337
public static Map < String , ObjectNode > generateSetupJson ( List < Map . Entry < String , Boolean > > prefixes ) { Map < String , String > webJars = new WebJarAssetLocator ( ) . getWebJars ( ) ; Map < String , ObjectNode > jsonConfigs = new HashMap <> ( ) ; for ( Map . Entry < String , String > webJar : webJars . entrySet ( ) ) { jsonConfigs . put ( webJar . getKey ( ) , getWebJarSetupJson ( webJar , prefixes ) ) ; } return jsonConfigs ; }
Returns the JSON used to setup the RequireJS config for each WebJar in the CLASSPATH . This value is not cached .
133
28
13,338
private static String requireJsConfigErrorMessage ( Map . Entry < String , String > webJar ) { return "Could not read WebJar RequireJS config for: " + webJar . getKey ( ) + " " + webJar . getValue ( ) + "\n" + "Please file a bug at: http://github.com/webjars/" + webJar . getKey ( ) + "/issues/new" ; }
A generic error message for when the RequireJS config could not be parsed out of the WebJar s pom . xml meta - data .
92
29
13,339
@ Deprecated public static String getWebJarConfig ( Map . Entry < String , String > webJar ) { String webJarConfig = "" ; // read the webJarConfigs String filename = WebJarAssetLocator . WEBJARS_PATH_PREFIX + "/" + webJar . getKey ( ) + "/" + webJar . getValue ( ) + "/" + "webjars-requirejs.js" ; InputStream inputStream = RequireJS . class . getClassLoader ( ) . getResourceAsStream ( filename ) ; if ( inputStream != null ) { log . warn ( "The " + webJar . getKey ( ) + " " + webJar . getValue ( ) + " WebJar is using the legacy RequireJS config.\n" + "Please try a new version of the WebJar or file or file an issue at:\n" + "http://github.com/webjars/" + webJar . getKey ( ) + "/issues/new" ) ; StringBuilder webJarConfigBuilder = new StringBuilder ( "// WebJar config for " + webJar . getKey ( ) + "\n" ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; try { String line ; while ( ( line = br . readLine ( ) ) != null ) { webJarConfigBuilder . append ( line ) . append ( "\n" ) ; } webJarConfig = webJarConfigBuilder . toString ( ) ; } catch ( IOException e ) { log . warn ( filename + " could not be read." ) ; } finally { try { br . close ( ) ; } catch ( IOException e ) { // really? } } } return webJarConfig ; }
The legacy webJars - requirejs . js based RequireJS config for a WebJar .
375
20
13,340
@ SuppressWarnings ( "unchecked" ) public static < E extends Enum < ? extends Style . HasCssName > > E fromStyleName ( final String styleName , final Class < E > enumClass , final E defaultValue ) { if ( styleName == null || enumClass == null ) { return defaultValue ; } for ( final Enum < ? extends Style . HasCssName > constant : enumClass . getEnumConstants ( ) ) { final Style . HasCssName anEnum = ( Style . HasCssName ) constant ; final String cssClass = anEnum . getCssName ( ) ; if ( cssClass != null && StyleHelper . containsStyle ( styleName , cssClass ) ) { return ( E ) anEnum ; } } return defaultValue ; }
Returns first enum constant found in at space - separated list of style names .
177
15
13,341
public static SimpleRadioButton wrap ( Element element ) { // Assert that the element is attached. assert Document . get ( ) . getBody ( ) . isOrHasChild ( element ) ; SimpleRadioButton radioButton = new SimpleRadioButton ( InputElement . as ( element ) ) ; // Mark it attached and remember it for cleanup. radioButton . onAttach ( ) ; RootPanel . detachOnWindowClose ( radioButton ) ; return radioButton ; }
Creates a SimpleRadioButton widget that wraps an existing &lt ; input type = radio &gt ; element .
95
23
13,342
public List < EditorError > createErrorList ( Editor < T > editor , T value , String messageKey ) { List < EditorError > result = new ArrayList < EditorError > ( ) ; result . add ( new BasicEditorError ( editor , value , getInvalidMessage ( messageKey ) ) ) ; return result ; }
Creates the error list .
68
6
13,343
private void ensureId ( final Element element ) { final String id = element . getId ( ) ; if ( id == null || id . isEmpty ( ) ) { element . setId ( Document . get ( ) . createUniqueId ( ) ) ; } }
Ensures the given element has a non - empty id .
55
13
13,344
public static void setHiddenOn ( final UIObject uiObject , final DeviceSize deviceSize ) { // Split the enum up by _ to get the different devices // Separates the SM_MD into [SM, MD] so we can add the right styles final String [ ] deviceString = deviceSize . name ( ) . split ( "_" ) ; for ( final String device : deviceString ) { // Case back to basic enum (PRINT, XS, SM, MD, LG) final DeviceSize size = DeviceSize . valueOf ( device ) ; switch ( size ) { case PRINT : addEnumStyleName ( uiObject , Responsiveness . HIDDEN_PRINT ) ; break ; case XS : addEnumStyleName ( uiObject , Responsiveness . HIDDEN_XS ) ; break ; case SM : addEnumStyleName ( uiObject , Responsiveness . HIDDEN_SM ) ; break ; case MD : addEnumStyleName ( uiObject , Responsiveness . HIDDEN_MD ) ; break ; case LG : addEnumStyleName ( uiObject , Responsiveness . HIDDEN_LG ) ; break ; default : break ; } } }
Sets the ui object to be hidden on the device size
258
13
13,345
public static void setVisibleOn ( final UIObject uiObject , final DeviceSize deviceSize ) { // Split the enum up by _ to get the different devices // Separates the SM_MD into [SM, MD] so we can add the right styles final String [ ] deviceString = deviceSize . name ( ) . split ( "_" ) ; for ( final String device : deviceString ) { // Case back to basic enum (PRINT, XS, SM, MD, LG) final DeviceSize size = DeviceSize . valueOf ( device ) ; switch ( size ) { case PRINT : addEnumStyleName ( uiObject , Responsiveness . VISIBLE_PRINT ) ; break ; case XS : addEnumStyleName ( uiObject , Responsiveness . VISIBLE_XS ) ; break ; case SM : addEnumStyleName ( uiObject , Responsiveness . VISIBLE_SM ) ; break ; case MD : addEnumStyleName ( uiObject , Responsiveness . VISIBLE_MD ) ; break ; case LG : addEnumStyleName ( uiObject , Responsiveness . VISIBLE_LG ) ; break ; default : break ; } } }
Sets the ui object to be visible on the device size
254
13
13,346
public static ScrollSpy scrollSpy ( final UIObject spyOn , final String selector ) { return new ScrollSpy ( spyOn . getElement ( ) , selector ) ; }
Attaches ScrollSpy to specified object with specified target selector .
38
13
13,347
public static ScrollSpy scrollSpy ( final UIObject spyOn , final HasId target ) { return new ScrollSpy ( spyOn . getElement ( ) , target ) ; }
Attaches ScrollSpy to specified object with specified target element .
39
13
13,348
public void setIconType ( IconType type ) { IconType prevType = iconType ; iconType = type ; if ( iconType != prevType && iconElement != null ) { iconElement . removeFromParent ( ) ; iconElement = null ; DomEvent . fireNativeEvent ( Document . get ( ) . createChangeEvent ( ) , this ) ; } }
Sets the icon type . If the icon type changes programatically then the icon is removed from the dom and recreated .
76
25
13,349
public static SimpleCheckBox wrap ( Element element ) { // Assert that the element is attached. assert Document . get ( ) . getBody ( ) . isOrHasChild ( element ) ; SimpleCheckBox checkBox = new SimpleCheckBox ( InputElement . as ( element ) ) ; // Mark it attached and remember it for cleanup. checkBox . onAttach ( ) ; RootPanel . detachOnWindowClose ( checkBox ) ; return checkBox ; }
Creates a SimpleCheckBox widget that wraps an existing &lt ; input type = checkbox &gt ; element .
95
24
13,350
private void call ( final Element e , final String arg ) { JQuery . jQuery ( e ) . popover ( arg ) ; }
Call the native popover method with the given argument .
28
11
13,351
private void popover ( Element e , String content ) { e . setAttribute ( "data-content" , content ) ; JQuery . jQuery ( e ) . popover ( ) ; }
Create the popover .
40
5
13,352
public void setAttribute ( final String attributeName , final String attributeValue ) { uiObject . getElement ( ) . setAttribute ( attributeName , attributeValue ) ; }
Sets the attribute on the UiObject
36
9
13,353
private void updatePaginationState ( final SimplePager pager ) { for ( int i = 0 ; i < getWidgetCount ( ) ; i ++ ) { if ( i == 0 ) { //previous button ( ( AnchorListItem ) getWidget ( i ) ) . setEnabled ( pager . hasPreviousPage ( ) ) ; } else if ( i == getWidgetCount ( ) - 1 ) { //next button ( ( AnchorListItem ) getWidget ( i ) ) . setEnabled ( pager . hasNextPage ( ) ) ; } else { int index = i - 1 ; if ( index == pager . getPage ( ) ) { ( ( AnchorListItem ) getWidget ( i ) ) . setActive ( true ) ; } else { ( ( AnchorListItem ) getWidget ( i ) ) . setActive ( false ) ; } } } }
This updates the current active page and the enabled state of the previous and next buttons in the Pagination based on the state of the given SimplePager .
188
31
13,354
public void insert ( final Widget child , final int beforeIndex ) { insert ( child , ( Element ) getElement ( ) , beforeIndex , true ) ; }
Inserts a widget at a specific index
34
8
13,355
public < T extends Widget & HasValidators < ? > > void add ( final T field ) { fields . put ( field , field . validate ( false ) ) ; if ( field . isAttached ( ) ) { updateStateAndNotify ( ) ; } registrations . put ( field , field . addValidationChangedHandler ( new ValidationChangedHandler ( ) { @ Override public void onValidationChanged ( ValidationChangedEvent event ) { fields . put ( field , event . isValid ( ) ) ; if ( fireEvents ) { updateStateAndNotify ( ) ; } } } ) ) ; }
Adds a field to the group .
130
7
13,356
public < T extends Widget & HasValidators < ? > > boolean remove ( final T field ) { fields . remove ( ( HasValidators < ? > ) field ) ; HandlerRegistration reg = registrations . remove ( ( HasValidators < ? > ) field ) ; if ( reg != null ) { reg . removeHandler ( ) ; return true ; } return false ; }
Removes a field from the validation group .
78
9
13,357
public void setSize ( final ColumnSize firstSize , final ColumnSize ... otherSizes ) { addEnumVarargsValues ( new ColumnSize [ ] { firstSize } , ColumnSize . class , true ) ; addEnumVarargsValues ( otherSizes , ColumnSize . class , false ) ; }
Adds one or more additional column sizes .
65
8
13,358
protected Set < Radio > getRadioChildren ( final Widget widget , final Set < Radio > c ) { Set < Radio > children = c ; if ( children == null ) { children = new HashSet < Radio > ( ) ; } if ( widget instanceof Radio ) { children . add ( ( Radio ) widget ) ; } else if ( widget instanceof HasOneWidget ) { children = getRadioChildren ( ( ( HasOneWidget ) widget ) . getWidget ( ) , children ) ; } else if ( widget instanceof HasWidgets ) { for ( Widget w : ( HasWidgets ) widget ) { if ( w instanceof Radio ) { children . add ( ( Radio ) w ) ; } else { children = getRadioChildren ( w , children ) ; } } } return children ; }
Gets the radio children .
169
6
13,359
protected void updateChildren ( ) { for ( Radio child : getRadioChildren ( ) ) { HandlerRegistration reg = valueChangedRegistrations . get ( child ) ; if ( reg == null ) { valueChangedRegistrations . put ( child , child . addValueChangeHandler ( changeHandler ) ) ; } child . setName ( name ) ; } }
Update the radio children names .
74
6
13,360
private void call ( final Element e , final String arg ) { JQuery . jQuery ( e ) . tooltip ( arg ) ; }
Call the native tooltip method with the given argument .
27
10
13,361
@ Override public void setName ( final String name ) { this . name = name ; if ( name == null ) { return ; } for ( final Widget w : getChildren ( ) ) { if ( w instanceof HasName ) { ( ( HasName ) w ) . setName ( name ) ; } } }
Convenience method that will set the name of all child widgets that can have a name
68
18
13,362
private Map getCurrentStep ( Phase phase ) { String target = phase . ordinal ( ) <= Phase . match . ordinal ( ) ? Phase . match . name ( ) : Phase . result . name ( ) ; Map lastWithValue = null ; for ( Map stepOrHook : getSteps ( ) ) { if ( stepOrHook . get ( target ) == null ) { return stepOrHook ; } else { lastWithValue = stepOrHook ; } } return lastWithValue ; }
In order to handle steps being added all at once this method determines allows methods to opperator correctly if
108
21
13,363
public void syntaxError ( String state , String event , List < String > legalEvents , String uri , Integer line ) { formatter . syntaxError ( state , event , legalEvents , uri , line ) ; }
Not part of the API . Used for testing only .
46
11
13,364
public JCodeModel getCodeModel ( String basePackage , String schemaLocation , Annotator annotator ) { if ( type != null ) { return codeModel ; } else { return SchemaHelper . buildBodyJCodeModel ( schemaLocation , basePackage , name , schema , annotator ) ; } }
Builds a JCodeModel for this body
64
9
13,365
public Set < ApiResourceMetadata > extractControllers ( JCodeModel bodyCodeModel , RamlRoot raml ) { Set < ApiResourceMetadata > controllers = new LinkedHashSet <> ( ) ; if ( raml == null ) { return controllers ; } if ( bodyCodeModel == null ) { bodyCodeModel = new JCodeModel ( ) ; } Set < String > names = new LinkedHashSet <> ( ) ; Set < String > namesToDisable = new LinkedHashSet <> ( ) ; // Iterate on all parent resources // if we have child resources, just append the url and go down the chain // until we hit the first action. // if an action is found we need to for ( Entry < String , RamlResource > resource : raml . getResources ( ) . entrySet ( ) ) { Set < ApiResourceMetadata > resources = checkResource ( bodyCodeModel , startUrl , resource . getValue ( ) , null , raml ) ; for ( ApiResourceMetadata resourceMetadata : resources ) { if ( names . contains ( resourceMetadata . getResourceName ( ) ) ) { // collision has occured, lets mark this for 2nd pass namesToDisable . add ( resourceMetadata . getResourceName ( ) ) ; } names . add ( resourceMetadata . getResourceName ( ) ) ; controllers . add ( resourceMetadata ) ; } } // second pass, disabling singularisation for ( ApiResourceMetadata resourceMetadata : controllers ) { if ( namesToDisable . contains ( resourceMetadata . getResourceName ( ) ) ) { resourceMetadata . setSingularizeName ( false ) ; } } return controllers ; }
This method will extract a set of controllers from the RAML file . These controllers will contain the metadata required by the code generator including name any annotations as well as conatining methods
362
36
13,366
private Set < ApiResourceMetadata > checkResource ( JCodeModel bodyCodeModel , String baseUrl , RamlResource resource , ApiResourceMetadata controller , RamlRoot document ) { Set < ApiResourceMetadata > controllers = new LinkedHashSet <> ( ) ; // append resource URL to url. String url = baseUrl + resource . getRelativeUri ( ) ; if ( controller == null && shouldCreateController ( resource ) ) { controller = new ApiResourceMetadata ( bodyCodeModel , url , resource , document ) ; controllers . add ( controller ) ; } // extract actions for this resource if ( resource . getActions ( ) != null && ! resource . getActions ( ) . isEmpty ( ) ) { for ( RamlActionType actionType : RamlActionType . values ( ) ) { if ( resource . getActions ( ) . containsKey ( actionType ) ) { RamlAction childResource = resource . getActions ( ) . get ( actionType ) ; // if we have multiple response types in the raml, this // should produce different calls RamlResponse response = null ; if ( childResource . getResponses ( ) != null ) { response = RamlHelper . getSuccessfulResponse ( childResource ) ; } if ( Config . isSeperateMethodsByContentType ( ) && response != null && response . hasBody ( ) && response . getBody ( ) . size ( ) > 1 ) { for ( String responseType : response . getBody ( ) . keySet ( ) ) { controller . addApiCall ( resource , actionType , childResource , responseType ) ; } } else { controller . addApiCall ( resource , actionType , childResource , null ) ; } } } } if ( resource . getResources ( ) != null && ! resource . getResources ( ) . isEmpty ( ) ) { for ( Entry < String , RamlResource > childResource : resource . getResources ( ) . entrySet ( ) ) { controllers . addAll ( checkResource ( bodyCodeModel , url , childResource . getValue ( ) , controller , document ) ) ; } } return controllers ; }
Recursive method to parse resources in a Raml File . It tries to go as deep as possible before creating the root Resource . Once this is done methods and child resources will be relative to the root resource
460
41
13,367
private Set < String > getAllReferencedTypeNames ( Set < ApiResourceMetadata > controllers ) { // TODO Add nested objects as well. For now only the top level objects // are included Set < String > parametersNames = controllers . stream ( ) . flatMap ( resourceMetadata -> resourceMetadata . getParameters ( ) . stream ( ) ) . map ( apiParameter -> StringUtils . capitalize ( apiParameter . getName ( ) ) ) . collect ( Collectors . toSet ( ) ) ; Set < String > bodyNames = controllers . stream ( ) . flatMap ( resourceMetadata -> resourceMetadata . getDependencies ( ) . stream ( ) ) . map ( ApiBodyMetadata :: getName ) . collect ( Collectors . toSet ( ) ) ; bodyNames . addAll ( parametersNames ) ; return bodyNames ; }
Fetches all referenced type names so as to not generate classes multiple times
183
15
13,368
public static RamlRoot loadRamlFromFile ( String ramlFileUrl ) { try { return createRamlModelFactoryFor ( ramlFileUrl ) . buildRamlRoot ( ramlFileUrl ) ; } catch ( NullPointerException npe ) { logger . error ( "File not found at {}" , ramlFileUrl ) ; return null ; } }
Loads a RAML document from a file . This method will
79
13
13,369
private boolean doesActionTypeSupportRequestBody ( RamlActionType target ) { return target . equals ( RamlActionType . POST ) || target . equals ( RamlActionType . PUT ) || target . equals ( RamlActionType . PATCH ) || target . equals ( RamlActionType . DELETE ) ; }
Method to check if a specific action type supports payloads in the body of the request
70
17
13,370
public static String resolveSchema ( String schema , RamlRoot document ) { if ( document == null || schema == null || schema . indexOf ( "{" ) != - 1 ) { return null ; } if ( document . getSchemas ( ) != null && ! document . getSchemas ( ) . isEmpty ( ) ) { for ( Map < String , String > map : document . getSchemas ( ) ) { if ( map . containsKey ( schema ) ) { return map . get ( schema ) ; } } } return null ; }
Utility method that will return a schema if the identifier is valid and exists in the raml file definition .
115
22
13,371
public static Class < ? > mapSimpleType ( RamlParamType param , String format , String rawType ) { switch ( param ) { case BOOLEAN : return Boolean . class ; case DATE : return mapDateFormat ( rawType ) ; case INTEGER : { Class < ? > fromFormat = mapNumberFromFormat ( format ) ; if ( fromFormat == Double . class ) { throw new IllegalStateException ( ) ; } if ( fromFormat == null ) { return Long . class ; // retained for backward compatibility } else { return fromFormat ; } } case NUMBER : { Class < ? > fromFormat = mapNumberFromFormat ( format ) ; if ( fromFormat == null ) { return BigDecimal . class ; // retained for backward // compatibility } else { return fromFormat ; } } case FILE : return MultipartFile . class ; default : return String . class ; } }
Maps simple types supported by RAML into primitives and other simple Java types
190
15
13,372
private static String extractTopItem ( String searchString , String schema , int startIdx ) { String extracted = null ; int propIdx = schema . indexOf ( "\"properties\"" , startIdx ) ; if ( propIdx == - 1 ) { propIdx = Integer . MAX_VALUE ; } // check for second int idIdx = schema . indexOf ( "\"" + searchString + "\"" , startIdx ) ; int secondIdIdx = schema . indexOf ( "\"" + searchString + "\"" , idIdx + 1 ) ; if ( secondIdIdx != - 1 && propIdx > secondIdIdx ) { idIdx = secondIdIdx ; } if ( idIdx != - 1 && propIdx > idIdx ) { // make sure we're not in a nested // id // find the 1st and second " after the idx int valueStartIdx = schema . indexOf ( "\"" , idIdx + ( searchString . length ( ) + 2 ) ) ; int valueEndIdx = schema . indexOf ( "\"" , valueStartIdx + 1 ) ; extracted = schema . substring ( valueStartIdx + 1 , valueEndIdx ) ; } return extracted ; }
Extracts the value of a specified parameter in a schema
276
12
13,373
public static JCodeModel buildBodyJCodeModel ( String basePackage , String schemaLocation , String name , String schema , Annotator annotator ) { JCodeModel codeModel = new JCodeModel ( ) ; SchemaStore schemaStore = new SchemaStore ( ) ; GenerationConfig config = Config . getPojoConfig ( ) ; if ( config == null ) { config = getDefaultGenerationConfig ( ) ; } if ( annotator == null ) { annotator = new Jackson2Annotator ( config ) ; } RuleFactory ruleFactory = new RuleFactory ( config , annotator , schemaStore ) ; SchemaMapper mapper = new SchemaMapper ( ruleFactory , new SchemaGenerator ( ) ) ; boolean useParent = StringUtils . hasText ( schemaLocation ) ; try { if ( useParent ) { mapper . generate ( codeModel , name , basePackage , schema , new URI ( schemaLocation ) ) ; } else { mapper . generate ( codeModel , name , basePackage , schema ) ; } } catch ( Exception e ) { // TODO make this smarter by checking refs if ( useParent && e . getMessage ( ) . contains ( "classpath" ) ) { logger . debug ( "Referenced Schema contains self $refs or not found in classpath. Regenerating model withouth classpath: for " + name ) ; codeModel = new JCodeModel ( ) ; try { mapper . generate ( codeModel , name , basePackage , schema ) ; return codeModel ; } catch ( IOException e1 ) { // do nothing } } logger . error ( "Error generating pojo from schema" + name , e ) ; return null ; } return codeModel ; }
Builds a JCodeModel for classes that will be used as Request or Response bodies
367
17
13,374
public static GenerationConfig getGenerationConfig ( Boolean generateBuilders , Boolean includeAdditionalProperties , Boolean includeDynamicAccessors , Boolean useLongIntegers ) { return new DefaultGenerationConfig ( ) { @ Override public boolean isGenerateBuilders ( ) { // set config option by // overriding method if ( generateBuilders != null ) { return generateBuilders ; } else { return true ; } } @ Override public boolean isIncludeAdditionalProperties ( ) { if ( includeAdditionalProperties != null ) { return includeAdditionalProperties ; } else { return false ; } } @ Override public boolean isIncludeDynamicAccessors ( ) { if ( includeDynamicAccessors != null ) { return includeDynamicAccessors ; } else { return false ; } } @ Override public boolean isUseLongIntegers ( ) { if ( useLongIntegers != null ) { return useLongIntegers ; } else { return super . isUseLongIntegers ( ) ; } } } ; }
Returns a generation config with the supplied parameters . If any of these parameters are supplied null it will use the value defined in the default configuration
209
27
13,375
public static String getElementAsString ( JDeclaration type ) { StringBuilder builder = new StringBuilder ( ) ; JFormatter jFormatter = new JFormatter ( new StringBuilderWriter ( builder ) ) ; type . declare ( jFormatter ) ; return builder . toString ( ) ; }
Returns the string equivalent of the code model element
63
9
13,376
public void annotateFieldJSR303 ( JMethod getter , boolean addValidAnnotation ) { if ( isRequired ( ) ) { getter . annotate ( NotNull . class ) ; } if ( StringUtils . hasText ( getPattern ( ) ) ) { JAnnotationUse annotation = getter . annotate ( Pattern . class ) ; annotation . param ( "regexp" , getPattern ( ) ) ; } if ( getMinLength ( ) != null || getMaxLength ( ) != null ) { JAnnotationUse annotation = getter . annotate ( Size . class ) ; if ( getMinLength ( ) != null ) { annotation . param ( "min" , getMinLength ( ) ) ; } if ( getMaxLength ( ) != null ) { annotation . param ( "max" , getMaxLength ( ) ) ; } } if ( addValidAnnotation ) { getter . annotate ( Valid . class ) ; } if ( minimum != null ) { JAnnotationUse annotation = getter . annotate ( DecimalMin . class ) ; annotation . param ( "value" , String . valueOf ( minimum ) ) ; } if ( maximum != null ) { JAnnotationUse annotation = getter . annotate ( DecimalMax . class ) ; annotation . param ( "value" , String . valueOf ( maximum ) ) ; } }
Adds validation annotations to the supplied method
292
7
13,377
public static String getFirstAuthorizationGrant ( RamlAction action , RamlRoot document ) { List < String > grants = getAuthorizationGrants ( action , document ) ; if ( grants . isEmpty ( ) ) { return null ; } return grants . get ( 0 ) ; }
Returns authorization grant for provided action . It searches for authorization grants defined for provided action some of parent resources or the root of the document . If authorization grants found is a list - the method will return the first grant in the list .
60
46
13,378
public static List < String > removeDuplicates ( List < String > list ) { return list . stream ( ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; }
Remove duplicates from provided list .
41
7
13,379
public static String getFormat ( TypeDeclaration param ) { if ( param == null ) { return null ; } if ( param instanceof NumberTypeDeclaration ) { return ( ( NumberTypeDeclaration ) param ) . format ( ) ; } if ( param instanceof DateTimeTypeDeclaration ) { return ( ( DateTimeTypeDeclaration ) param ) . format ( ) ; } return null ; }
IF it has a format defined this will return it
83
10
13,380
public static String getDescription ( TypeDeclaration type ) { if ( type == null || type . description ( ) == null ) { return null ; } else { return type . description ( ) . value ( ) ; } }
Safely get description from a type with null checks
46
10
13,381
public static String getExample ( TypeDeclaration type ) { if ( type == null || type . example ( ) == null ) { return null ; } else { return type . example ( ) . value ( ) ; } }
Safely get example from a type with null checks
46
10
13,382
public static String getDisplayName ( TypeDeclaration type ) { if ( type == null || type . displayName ( ) == null ) { return null ; } else { return type . displayName ( ) . value ( ) ; } }
Safely get Display name from a type with null checks
49
11
13,383
public static boolean isRequired ( TypeDeclaration type ) { if ( type == null || type . required ( ) == null ) { return true ; } else { return type . required ( ) ; } }
Safely get required from a type with null checks
42
10
13,384
public boolean isArray ( ) { if ( type == null ) { return false ; } return type . isArray ( ) || List . class . isAssignableFrom ( type ) || Set . class . isAssignableFrom ( type ) ; }
Quick check to see if this is an array type or not
53
12
13,385
public static String convertContentTypeToQualifier ( String contentType ) { // lets start off simple since qualifers are better if they are simple // :) // if we have simple standard types lets add some heuristics if ( contentType . equals ( MediaType . APPLICATION_JSON_VALUE ) ) { return "AsJson" ; } if ( contentType . equals ( MediaType . APPLICATION_OCTET_STREAM_VALUE ) ) { return "AsBinary" ; } if ( contentType . equals ( MediaType . TEXT_PLAIN_VALUE ) || contentType . equals ( MediaType . TEXT_HTML_VALUE ) ) { return "AsText" ; } // we have a non standard type. lets see if we have a version Matcher versionMatcher = CONTENT_TYPE_VERSION . matcher ( contentType ) ; if ( versionMatcher . find ( ) ) { String version = versionMatcher . group ( 1 ) ; if ( version != null ) { return StringUtils . capitalize ( version ) . replace ( "." , "_" ) ; } } // if we got here we have some sort of funky content type. deal with it int seperatorIndex = contentType . indexOf ( "/" ) ; if ( seperatorIndex != - 1 && seperatorIndex < contentType . length ( ) ) { String candidate = contentType . substring ( seperatorIndex + 1 ) . toLowerCase ( ) ; String out = "" ; if ( candidate . contains ( "json" ) ) { candidate = candidate . replace ( "json" , "" ) ; out += "AsJson" ; } candidate = StringUtils . deleteAny ( candidate , " ,.+=-'\"\\|~`#$%^&\n\t" ) ; if ( StringUtils . hasText ( candidate ) ) { out = StringUtils . capitalize ( candidate ) + out ; } return "_" + out ; } return "" ; }
Converts an http contentType into a qualifier that can be used within a Java method
420
17
13,386
public static List < String > extractUriParams ( String url ) { List < String > outParams = new ArrayList <> ( ) ; if ( StringUtils . hasText ( url ) ) { String [ ] split = StringUtils . split ( url , "/" ) ; for ( String part : split ) { int indexOfStart = part . indexOf ( "{" ) ; int indexOfEnd = part . indexOf ( "}" ) ; if ( indexOfStart != - 1 && indexOfEnd != - 1 && indexOfStart < indexOfEnd ) { outParams . add ( part . substring ( indexOfStart + 1 , indexOfEnd ) ) ; } } } return outParams ; }
Extracts a list of URI Parameters from a url
155
11
13,387
public static boolean isValidJavaClassName ( String input ) { if ( ! StringUtils . hasText ( input ) ) { return false ; } if ( ! Character . isJavaIdentifierStart ( input . charAt ( 0 ) ) ) { return false ; } if ( input . length ( ) > 1 ) { for ( int i = 1 ; i < input . length ( ) ; i ++ ) { if ( ! Character . isJavaIdentifierPart ( input . charAt ( i ) ) ) { return false ; } } } return true ; }
Utility method to check if a string can be used as a valid class name
117
16
13,388
public static String getAllResourcesNames ( String url , boolean singularize ) { StringBuilder stringBuilder = new StringBuilder ( ) ; if ( StringUtils . hasText ( url ) ) { String [ ] resources = SLASH . split ( url ) ; int lengthCounter = 0 ; for ( int i = resources . length - 1 ; i >= Config . getResourceTopLevelInClassNames ( ) + 1 ; -- i ) { if ( StringUtils . hasText ( resources [ i ] ) ) { String resourceName = getResourceName ( resources [ i ] , singularize ) ; if ( Config . isReverseOrderInClassNames ( ) ) { stringBuilder . append ( resourceName ) ; } else { stringBuilder . insert ( 0 , resourceName ) ; } ++ lengthCounter ; } if ( Config . getResourceDepthInClassNames ( ) > 0 && lengthCounter >= Config . getResourceDepthInClassNames ( ) ) { break ; } } } return stringBuilder . toString ( ) ; }
Attempts to infer the name of a resource from a resources s full URL .
213
15
13,389
public static String singularize ( String target ) { // TODO we should add this as an issue in the RamlBase project and // provide a pull request String result = Inflector . singularize ( target ) ; if ( ( target . endsWith ( "ss" ) ) && ( result . equals ( target . substring ( 0 , target . length ( ) - 1 ) ) ) ) { result = target ; } return result ; }
Singularises a string . uses underlying raml parser system
92
12
13,390
public static String cleanNameForJavaEnum ( String enumConstant ) { if ( ! StringUtils . hasText ( enumConstant ) ) { return enumConstant ; } List < String > nameGroups = new ArrayList <> ( asList ( splitByCharacterTypeCamelCase ( enumConstant ) ) ) ; nameGroups . removeIf ( s -> containsOnly ( s . replaceAll ( ILLEGAL_CHARACTER_REGEX , "_" ) , "_" ) ) ; String enumName = upperCase ( join ( nameGroups , "_" ) ) ; if ( isEmpty ( enumName ) ) { enumName = "_DEFAULT_" ; } else if ( Character . isDigit ( enumName . charAt ( 0 ) ) ) { enumName = "_" + enumName ; } return filterKeywords ( enumName ) ; }
Cleans a string with characters that are not valid as a java identifier enum
186
15
13,391
private static String convertActionTypeToIntent ( RamlActionType actionType , boolean isIdInPath ) { switch ( actionType ) { case DELETE : return "delete" ; case GET : return "get" ; case POST : if ( ! isIdInPath ) { return "create" ; } case PUT : return "update" ; case PATCH : return "modify" ; default : return "do" ; } }
Attempts to convert the Http Verb into a textual representation of Intent based on REST conventions
94
17
13,392
private void loadInfosFromSettings ( ScmProviderRepositoryWithHost repo ) { if ( username == null || password == null ) { String host = repo . getHost ( ) ; int port = repo . getPort ( ) ; if ( port > 0 ) { host += ":" + port ; } Server server = this . settings . getServer ( host ) ; if ( server != null ) { setPasswordIfNotEmpty ( repo , decrypt ( server . getPassword ( ) , host ) ) ; setUserIfNotEmpty ( repo , server . getUsername ( ) ) ; } } }
Load username password from settings .
125
6
13,393
protected InfoScmResult info ( ScmRepository repository , ScmFileSet fileSet ) throws ScmException { CommandParameters commandParameters = new CommandParameters ( ) ; // only for Git, we will make a test for shortRevisionLength parameter if ( GitScmProviderRepository . PROTOCOL_GIT . equals ( scmManager . getProviderByRepository ( repository ) . getScmType ( ) ) && this . shortRevisionLength > 0 ) { getLog ( ) . info ( "ShortRevision tag detected. The value is '" + this . shortRevisionLength + "'." ) ; if ( shortRevisionLength >= 0 && shortRevisionLength < 4 ) { getLog ( ) . warn ( "shortRevision parameter less then 4. ShortRevisionLength is relaying on 'git rev-parese --short=LENGTH' command, accordingly to Git rev-parse specification the LENGTH value is miminum 4. " ) ; } commandParameters . setInt ( CommandParameter . SCM_SHORT_REVISION_LENGTH , this . shortRevisionLength ) ; } if ( ! StringUtils . isBlank ( scmTag ) && ! "HEAD" . equals ( scmTag ) ) { commandParameters . setScmVersion ( CommandParameter . SCM_VERSION , new ScmTag ( scmTag ) ) ; } return scmManager . getProviderByRepository ( repository ) . info ( repository . getProviderRepository ( ) , fileSet , commandParameters ) ; }
Get info from scm .
330
6
13,394
private String format ( Object [ ] arguments ) { Locale l = Locale . getDefault ( ) ; if ( locale != null ) { String [ ] parts = locale . split ( "_" , 3 ) ; if ( parts . length <= 1 ) { l = new Locale ( locale ) ; } else if ( parts . length == 2 ) { l = new Locale ( parts [ 0 ] , parts [ 1 ] ) ; } else { l = new Locale ( parts [ 0 ] , parts [ 1 ] , parts [ 2 ] ) ; } } return new MessageFormat ( format , l ) . format ( arguments ) ; }
Formats the given argument using the configured format template and locale .
133
13
13,395
public String getScmBranch ( ) throws MojoExecutionException { try { ScmRepository repository = getScmRepository ( ) ; ScmProvider provider = scmManager . getProviderByRepository ( repository ) ; /* git branch can be obtained directly by a command */ if ( GitScmProviderRepository . PROTOCOL_GIT . equals ( provider . getScmType ( ) ) ) { ScmFileSet fileSet = new ScmFileSet ( scmDirectory ) ; return GitBranchCommand . getCurrentBranch ( getLogger ( ) , ( GitScmProviderRepository ) repository . getProviderRepository ( ) , fileSet ) ; } else if ( provider instanceof HgScmProvider ) { /* hg branch can be obtained directly by a command */ HgOutputConsumer consumer = new HgOutputConsumer ( getLogger ( ) ) ; ScmResult result = HgUtils . execute ( consumer , logger , scmDirectory , new String [ ] { "id" , "-b" } ) ; checkResult ( result ) ; if ( StringUtils . isNotEmpty ( consumer . getOutput ( ) ) ) { return consumer . getOutput ( ) ; } } } catch ( ScmException e ) { getLog ( ) . warn ( "Cannot get the branch information from the git repository: \n" + e . getLocalizedMessage ( ) ) ; } return getScmBranchFromUrl ( ) ; }
Get the branch info for this revision from the repository . For svn it is in svn info .
316
21
13,396
public String getRevision ( ) throws MojoExecutionException { if ( format != null && ! useScm ) { return revision ; } useScm = false ; try { return this . getScmRevision ( ) ; } catch ( ScmException e ) { if ( ! StringUtils . isEmpty ( revisionOnScmFailure ) ) { getLog ( ) . warn ( "Cannot get the revision information from the scm repository, proceeding with " + "revision of " + revisionOnScmFailure + " : \n" + e . getLocalizedMessage ( ) ) ; setDoCheck ( false ) ; setDoUpdate ( false ) ; return revisionOnScmFailure ; } throw new MojoExecutionException ( "Cannot get the revision information from the scm repository : \n" + e . getLocalizedMessage ( ) , e ) ; } }
Get the revision info from the repository . For svn it is svn info
189
16
13,397
public CreateIssueParams estimatedHours ( BigDecimal estimatedHours ) { if ( estimatedHours == null ) { parameters . add ( new NameValuePair ( "estimatedHours" , "" ) ) ; } else { parameters . add ( new NameValuePair ( "estimatedHours" , estimatedHours . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) . toPlainString ( ) ) ) ; } return this ; }
Sets the issue estimate hours .
98
7
13,398
public CreateIssueParams actualHours ( BigDecimal actualHours ) { if ( actualHours == null ) { parameters . add ( new NameValuePair ( "actualHours" , "" ) ) ; } else { parameters . add ( new NameValuePair ( "actualHours" , actualHours . setScale ( 2 , BigDecimal . ROUND_HALF_UP ) . toPlainString ( ) ) ) ; } return this ; }
Sets the issue actual hours .
96
7
13,399
public CreateIssueParams milestoneIds ( List milestoneIds ) { for ( Object milestoneId : milestoneIds ) { parameters . add ( new NameValuePair ( "milestoneId[]" , milestoneId . toString ( ) ) ) ; } return this ; }
Sets the issue milestones .
58
6