idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
40,900 | private File getKeenCacheDirectory ( ) throws IOException { File file = new File ( root , "keen" ) ; if ( ! file . exists ( ) ) { boolean dirMade = file . mkdir ( ) ; if ( ! dirMade ) { throw new IOException ( "Could not make keen cache directory at: " + file . getAbsolutePath ( ) ) ; } } return file ; } | Gets the root directory of the Keen cache based on the root directory passed to the constructor of this file store . If necessary this method will attempt to create the directory . |
40,901 | private File [ ] getSubDirectories ( File parent ) throws IOException { return parent . listFiles ( new FileFilter ( ) { public boolean accept ( File file ) { return file . isDirectory ( ) ; } } ) ; } | Gets an array containing all of the sub - directories in the given parent directory . |
40,902 | private File [ ] getFilesInDir ( File dir ) { return dir . listFiles ( new FileFilter ( ) { public boolean accept ( File file ) { return file . isFile ( ) && ! file . getName ( ) . equals ( ATTEMPTS_JSON_FILE_NAME ) ; } } ) ; } | Gets an array containing all of the files in the given directory . |
40,903 | private File getProjectDir ( String projectId , boolean create ) throws IOException { File projectDir = new File ( getKeenCacheDirectory ( ) , projectId ) ; if ( create && ! projectDir . exists ( ) ) { KeenLogging . log ( "Cache directory for project '" + projectId + "' doesn't exist. " + "Creating it." ) ; if ( ! proj... | Gets the cache directory for the given project . Optionally creates the directory if it doesn t exist . |
40,904 | private File getFileForEvent ( File collectionDir , Calendar timestamp ) throws IOException { int counter = 0 ; File eventFile = getNextFileForEvent ( collectionDir , timestamp , counter ) ; while ( eventFile . exists ( ) ) { eventFile = getNextFileForEvent ( collectionDir , timestamp , counter ) ; counter ++ ; } retur... | Gets the file to use for a new event in the given collection with the given timestamp . If there are multiple events with identical timestamps this method will use a counter to create a unique file name for each . |
40,905 | private File getNextFileForEvent ( File dir , Calendar timestamp , int counter ) { long timestampInMillis = timestamp . getTimeInMillis ( ) ; String name = Long . toString ( timestampInMillis ) ; return new File ( dir , name + "." + counter ) ; } | Gets the file to use for a new event in the given collection with the given timestamp using the provided counter . |
40,906 | private File prepareCollectionDir ( String projectId , String eventCollection ) throws IOException { File collectionDir = getCollectionDir ( projectId , eventCollection ) ; File [ ] eventFiles = getFilesInDir ( collectionDir ) ; if ( eventFiles . length >= getMaxEventsPerCollection ( ) ) { KeenLogging . log ( String . ... | Prepares the file cache for the given event collection for another event to be added . This method checks to make sure that the maximum number of events per collection hasn t been exceeded and if it has this method discards events to make room . |
40,907 | void clear ( ) { nextId = 0 ; collectionIds = new HashMap < String , List < Long > > ( ) ; events = new HashMap < Long , String > ( ) ; } | Clears all events from the store effectively resetting it to its initial state . This method is intended for use during unit testing and should generally not be called by production code . |
40,908 | public static int randomInt ( int startInclusive , int endExclusive ) { checkArgument ( startInclusive <= endExclusive , "End must be greater than or equal to start" ) ; if ( startInclusive == endExclusive ) { return startInclusive ; } return RANDOM . ints ( 1 , startInclusive , endExclusive ) . sum ( ) ; } | Returns a random int within the specified range . |
40,909 | public static int randomIntGreaterThan ( int minExclusive ) { checkArgument ( minExclusive < Integer . MAX_VALUE , "Cannot produce int greater than %s" , Integer . MAX_VALUE ) ; return randomInt ( minExclusive + 1 , Integer . MAX_VALUE ) ; } | Returns a random int that is greater than the given int . |
40,910 | public static int randomIntLessThan ( int maxExclusive ) { checkArgument ( maxExclusive > Integer . MIN_VALUE , "Cannot produce int less than %s" , Integer . MIN_VALUE ) ; return randomInt ( Integer . MIN_VALUE , maxExclusive ) ; } | Returns a random int that is less than the given int . |
40,911 | public static long randomLong ( long startInclusive , long endExclusive ) { checkArgument ( startInclusive <= endExclusive , "End must be greater than or equal to start" ) ; if ( startInclusive == endExclusive ) { return startInclusive ; } return RANDOM . longs ( 1 , startInclusive , endExclusive ) . sum ( ) ; } | Returns a random long within the specified range . |
40,912 | public static long randomLongGreaterThan ( long minExclusive ) { checkArgument ( minExclusive < Long . MAX_VALUE , "Cannot produce long greater than %s" , Long . MAX_VALUE ) ; return randomLong ( minExclusive + 1 , Long . MAX_VALUE ) ; } | Returns a random long that is greater than the given long . |
40,913 | public static long randomLongLessThan ( long maxExclusive ) { checkArgument ( maxExclusive > Long . MIN_VALUE , "Cannot produce long less than %s" , Long . MIN_VALUE ) ; return randomLong ( Long . MIN_VALUE , maxExclusive ) ; } | Returns a random long that is less than the given long . |
40,914 | public static double randomDouble ( double startInclusive , double endExclusive ) { checkArgument ( startInclusive <= endExclusive , "End must be greater than or equal to start" ) ; if ( startInclusive == endExclusive ) { return startInclusive ; } return RANDOM . doubles ( 1 , startInclusive , endExclusive ) . sum ( ) ... | Returns a random double within the specified range . |
40,915 | public static double randomDoubleGreaterThan ( double minExclusive ) { checkArgument ( minExclusive < Double . MAX_VALUE , "Cannot produce double greater than %s" , Double . MAX_VALUE ) ; return randomDouble ( minExclusive + 1 , Double . MAX_VALUE ) ; } | Returns a random double that is greater than the given double . |
40,916 | public static double randomDoubleLessThan ( double maxExclusive ) { checkArgument ( maxExclusive > - Double . MAX_VALUE , "Cannot produce double less than %s" , - Double . MAX_VALUE ) ; return randomDouble ( - Double . MAX_VALUE , maxExclusive ) ; } | Returns a random double that is less than the given double . |
40,917 | public static < T extends Enum < T > > T random ( Class < T > enumClass ) { EnumSet < T > enums = EnumSet . allOf ( enumClass ) ; return IterableUtils . randomFrom ( enums ) ; } | Returns a random element from the given enum class . |
40,918 | @ SuppressWarnings ( "unchecked" ) public static < T > T [ ] randomArrayFrom ( Supplier < T > elementSupplier , int size ) { checkArgument ( size >= 0 , "Size must be greater than or equal to zero" ) ; return ( T [ ] ) Stream . generate ( elementSupplier ) . limit ( size ) . toArray ( Object [ ] :: new ) ; } | Returns an array filled from the given element supplier . |
40,919 | protected void stop ( ) throws Exception { this . started = false ; for ( ManagementEventListener lstr : this . management . getManagementEventListeners ( ) ) { try { lstr . onAssociationStopped ( this ) ; } catch ( Throwable ee ) { logger . error ( "Exception while invoking onAssociationStopped" , ee ) ; } } if ( this... | Stops this Association . If the underlying SctpChannel is open marks the channel for close |
40,920 | public static < T > T randomFrom ( T [ ] array ) { checkArgument ( isNotEmpty ( array ) , "Array cannot be empty" ) ; return IterableUtils . randomFrom ( Arrays . asList ( array ) ) ; } | Returns a random element from the given array . |
40,921 | public static < T > List < T > randomListFrom ( Iterable < T > elements , Range < Integer > size ) { checkArgument ( ! isEmpty ( elements ) , "Elements to populate from must not be empty" ) ; return randomListFrom ( ( ) -> IterableUtils . randomFrom ( elements ) , size ) ; } | Returns a list filled randomly from the given elements . |
40,922 | public SortedSet < NotificationsByObservable < ? > > getNotificationsByObservable ( ) { SortedSet < NotificationsByObservable < ? > > notificationsByObservableSnapshot = new TreeSet < NotificationsByObservable < ? > > ( ) ; for ( Entry < Subscriber < ? > , Queue < SimpleContext < ? > > > notificationsForObservable : no... | a copy sorted by time of the all the state useful for analysis . |
40,923 | private String getType ( String propertyName , String explicitTargetEntity , ElementKind expectedElementKind ) { for ( Element elem : element . getEnclosedElements ( ) ) { if ( ! expectedElementKind . equals ( elem . getKind ( ) ) ) { continue ; } TypeMirror mirror ; String name = elem . getSimpleName ( ) . toString ( ... | Returns the entity type for a property . |
40,924 | private static AccessType getAccessTypeInCaseElementIsRoot ( TypeElement searchedElement , Context context ) { List < ? extends Element > myMembers = searchedElement . getEnclosedElements ( ) ; for ( Element subElement : myMembers ) { List < ? extends AnnotationMirror > entityAnnotations = context . getElementUtils ( )... | Iterates all elements of a type to check whether they contain the id annotation . If so the placement of this annotation determines the access type |
40,925 | private static StringBuffer generateBody ( MetaEntity entity , Context context ) { StringWriter sw = new StringWriter ( ) ; PrintWriter pw = null ; try { pw = new PrintWriter ( sw ) ; if ( context . addGeneratedAnnotation ( ) ) { pw . println ( writeGeneratedAnnotation ( entity , context ) ) ; } if ( context . isAddSup... | Generate everything after import statements . |
40,926 | public MonetaryAmount apply ( MonetaryAmount amount ) { Objects . requireNonNull ( amount , "Amount required." ) ; return amount . multiply ( permilValue ) ; } | Gets the permil of the amount . |
40,927 | public CurrencyUnit getCurrency ( CurrencyQuery query ) { Set < CurrencyUnit > currencies = getCurrencies ( query ) ; if ( currencies . isEmpty ( ) ) { return null ; } if ( currencies . size ( ) == 1 ) { return currencies . iterator ( ) . next ( ) ; } throw new MonetaryException ( "Ambiguous request for CurrencyUnit: "... | Access a single currency by query . |
40,928 | public static LocalDate from ( Calendar cal ) { int year = cal . get ( Calendar . YEAR ) ; int month = cal . get ( Calendar . MONTH ) + 1 ; int dayOfMonth = cal . get ( Calendar . DAY_OF_MONTH ) ; return new LocalDate ( year , month , dayOfMonth ) ; } | Cerates a new instance from the given Calendar . |
40,929 | public static Comparator < MonetaryAmount > sortCurrencyUnitDesc ( ) { return new Comparator < MonetaryAmount > ( ) { public int compare ( MonetaryAmount o1 , MonetaryAmount o2 ) { return sortCurrencyUnit ( ) . compare ( o1 , o2 ) * - 1 ; } } ; } | Get a comparator for sorting CurrencyUnits descending . |
40,930 | public static Comparator < MonetaryAmount > sortNumberDesc ( ) { return new Comparator < MonetaryAmount > ( ) { public int compare ( MonetaryAmount o1 , MonetaryAmount o2 ) { return sortNumber ( ) . compare ( o1 , o2 ) * - 1 ; } } ; } | Get a comparator for sorting amount by number value descending . |
40,931 | public String lookupNextToken ( ) { skipWhitespace ( ) ; int start = index ; for ( int end = index ; end < originalInput . length ( ) ; end ++ ) { if ( Character . isWhitespace ( originalInput . charAt ( end ) ) ) { if ( end > start ) { return originalInput . subSequence ( start , end ) . toString ( ) ; } return null ;... | This method skips all whitespaces and returns the full text until another whitespace area or the end of the input is reached . The method will not update any index pointers . |
40,932 | public static CurrencyUnit registerCurrencyUnit ( CurrencyUnit currencyUnit ) { Objects . requireNonNull ( currencyUnit ) ; return ConfigurableCurrencyUnitProvider . currencyUnits . put ( currencyUnit . getCurrencyCode ( ) , currencyUnit ) ; } | Registers a bew currency unit under its currency code . |
40,933 | public static CurrencyUnit registerCurrencyUnit ( CurrencyUnit currencyUnit , Locale locale ) { Objects . requireNonNull ( locale ) ; Objects . requireNonNull ( currencyUnit ) ; return ConfigurableCurrencyUnitProvider . currencyUnitsByLocale . put ( locale , currencyUnit ) ; } | Registers a bew currency unit under the given Locale . |
40,934 | public static DbTypeRegister getRegistry ( final Connection connection ) throws SQLException { Preconditions . checkNotNull ( connection ) ; final String connectionURL = connection . getMetaData ( ) . getURL ( ) ; Preconditions . checkNotNull ( connection . getMetaData ( ) . getURL ( ) , "connection URL is null" ) ; Db... | situation because we are not expecting so many different jdbc urls . |
40,935 | @ SuppressWarnings ( "unchecked" ) private Map < Integer , Object [ ] > partitionArguments ( final DataSourceProvider dataSourceProvider , final Object [ ] args ) { final Map < Integer , Object [ ] > argumentsByShardId = Maps . newTreeMap ( ) ; final Map < DataSource , Integer > shardIdByDataSource = Maps . newHashMap ... | split arguments by shard . |
40,936 | public GenericTemplateElementBuilder addLoginButton ( String url ) { Button button = ButtonFactory . createLoginButton ( url ) ; this . element . addButton ( button ) ; return this ; } | Adds a login button on a generic template . |
40,937 | public GenericTemplateElementBuilder addBuyButton ( String payload , PaymentSummary paymentSummary ) { Button button = ButtonFactory . createBuyButton ( payload , paymentSummary ) ; this . element . addButton ( button ) ; return this ; } | Adds a buy button on a generic template . |
40,938 | public static void setWhitelistedDomains ( List < String > whitelistedDomains ) { SetWhitelistedDomainsRequest request = new SetWhitelistedDomainsRequest ( whitelistedDomains ) ; FbBotMillNetworkController . postMessengerProfile ( request ) ; } | Adds a list of domains that needs to be whitelisted . |
40,939 | public static void setAccountLinkingUrl ( String accountLinkingUrl ) { SetAccountLinkingUrlRequest request = new SetAccountLinkingUrlRequest ( accountLinkingUrl ) ; FbBotMillNetworkController . postMessengerProfile ( request ) ; } | Adds an URL used for account linking . |
40,940 | public static void setPersistentMenus ( List < PersistentMenu > persistentMenu ) { PersistentMenuRequest persistentMenuRequest = new PersistentMenuRequest ( ) ; persistentMenuRequest . addAllPersistentMenu ( persistentMenu ) ; FbBotMillNetworkController . postMessengerProfile ( persistentMenuRequest ) ; } | Sets the persistent menus . |
40,941 | public static void setHomeUrl ( HomeUrl homeUrl ) { HomeUrlRequest homeUrlRequest = new HomeUrlRequest ( ) ; homeUrlRequest . setHomeUrl ( homeUrl ) ; FbBotMillNetworkController . postMessengerProfile ( homeUrlRequest ) ; } | This sets the home url of the Bot |
40,942 | private void buildFbBotConfig ( ) { FbBotMillContext . getInstance ( ) . setup ( ConfigurationUtils . getEncryptedConfiguration ( ) . getProperty ( FB_BOTMILL_PAGE_TOKEN ) , ConfigurationUtils . getEncryptedConfiguration ( ) . getProperty ( FB_BOTMILL_VALIDATION_TOKEN ) ) ; } | Builds the Fb bot config . |
40,943 | protected boolean verifyStringMatch ( String text ) { if ( text == null ) { return false ; } if ( ! this . caseSensitive ) { text = text . toLowerCase ( ) ; } return text . equals ( this . expectedString ) ; } | Verify string match . |
40,944 | public static void addPaymentSettings ( PaymentSettings paymentSettings ) { if ( paymentSettings == null ) { logger . error ( "FbBotMill validation error: Payment Settings can't be null or empty!" ) ; return ; } FbBotMillNetworkController . postThreadSetting ( paymentSettings ) ; } | This method is used to add any payment settings needed . |
40,945 | public static void deleteGetStartedButton ( ) { CallToActionsRequest request = new CallToActionsRequest ( ThreadState . NEW_THREAD , null ) ; FbBotMillNetworkController . deleteThreadSetting ( request ) ; } | Removes the current Get Started Button . |
40,946 | public static void setPersistentMenu ( List < Button > buttons ) { if ( buttons == null || buttons . isEmpty ( ) || buttons . size ( ) > 5 ) { logger . error ( "FbBotMill validation error: Persistent Menu Buttons can't be null or empty and must be less than 5!" ) ; return ; } CallToActionsRequest request = new CallToAc... | Sets a Persistent Menu of buttons which is always available to the user . This menu should contain top - level actions that users can enact at any point . Having a persistent menu easily communicates the basic capabilities of your bot for first - time and returning users . The menu can be invoked by a user by tapping o... |
40,947 | public static void deletePersistentMenu ( ) { CallToActionsRequest request = new CallToActionsRequest ( ThreadState . EXISTING_THREAD , null ) ; FbBotMillNetworkController . deleteThreadSetting ( request ) ; } | Removes the current Persistent Menu . |
40,948 | public static void setWhiteListDomains ( List < String > whiteListDomains ) { WhitelistDomainRequest request = new WhitelistDomainRequest ( whiteListDomains , DomainActionType . ADD ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Adds a list of domains that needs to be white listed . |
40,949 | public static void addWhiteListDomain ( String domain ) { WhitelistDomainRequest request = new WhitelistDomainRequest ( ) ; request . addWhiteListedDomain ( domain ) ; request . setDomainActionType ( DomainActionType . ADD ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Adds a single domain on the list of domains that needs to be white listed . |
40,950 | public static void deleteWhiteListDomain ( String domain ) { WhitelistDomainRequest request = new WhitelistDomainRequest ( ) ; request . addWhiteListedDomain ( domain ) ; request . setDomainActionType ( DomainActionType . REMOVE ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Removes a single domain on the list of domains that needs to be white listed . |
40,951 | public static void deleteWhiteListDomains ( List < String > whiteListDomains ) { WhitelistDomainRequest request = new WhitelistDomainRequest ( whiteListDomains , DomainActionType . REMOVE ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Removes a list of domains that are currently white listed . |
40,952 | public static void setPaymentsPublicKey ( String publicKey ) { PaymentSettings request = new PaymentSettings ( ) ; request . setPrivacyUrl ( publicKey ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Sets the payment public key . The payment_public_key is used to encrypt sensitive payment data sent to you . |
40,953 | public static void setPaymentsPrivacyUrl ( String privacyUrl ) { PaymentSettings request = new PaymentSettings ( ) ; request . setPrivacyUrl ( privacyUrl ) ; FbBotMillNetworkController . postThreadSetting ( request ) ; } | Sets the payment privacy Url . The payment_privacy_url will appear in Facebook s payment dialogs and people will be able to view these terms . |
40,954 | public void reply ( MessageEnvelope envelope ) { FbBotMillResponse response = createResponse ( envelope ) ; if ( response != null ) { if ( validate ( response ) ) { FbBotMillNetworkController . postJsonMessage ( response ) ; } } } | Method which defines the reply flow . |
40,955 | public boolean process ( MessageEnvelope envelope ) { if ( this . event == null ) { return false ; } boolean triggered = this . event . verifyEventCondition ( envelope ) ; if ( triggered ) { beforeReply ( envelope ) ; if ( this . reply != null ) { this . reply . reply ( envelope ) ; } afterReply ( envelope ) ; } return... | Executes the reply if the event is triggered . |
40,956 | public boolean processMultipleReply ( MessageEnvelope envelope ) { if ( this . event == null ) { return false ; } boolean triggered = this . event . verifyEventCondition ( envelope ) ; if ( triggered ) { beforeReply ( envelope ) ; if ( this . replies != null ) { synchronized ( replies ) { for ( AutoReply reply : replie... | Executes multiple replies when multiple autoreply is set . |
40,957 | public static Button createUrlButton ( String title , String url , WebViewHeightRatioType ratioType ) { return new WebUrlButton ( title , url , ratioType ) ; } | Creates a web view button . |
40,958 | public static Button createPostbackButton ( String title , String payload ) { return new PostbackButton ( title , ButtonType . POSTBACK , payload ) ; } | Creates a button which sends a payload back when clicked . |
40,959 | public static Button createPhoneNumberButton ( String title , String phoneNumber ) { return new PostbackButton ( title , ButtonType . PHONE_NUMBER , phoneNumber ) ; } | Creates a button with a phone number . |
40,960 | public static DailyUniqueActiveThreadCounts getDailyUniqueActiveThreadCounts ( ) { String pageToken = FbBotMillContext . getInstance ( ) . getPageToken ( ) ; BotMillNetworkResponse response = NetworkUtils . get ( FbBotMillNetworkConstants . FACEBOOK_BASE_URL + FbBotMillNetworkConstants . FACEBOOK_MESSAGING_INSIGHT_ACTI... | GETs the daily unique active thread counts . |
40,961 | public static DailyUniqueConversationCounts getDailyUniqueConversationCounts ( ) { String pageToken = FbBotMillContext . getInstance ( ) . getPageToken ( ) ; BotMillNetworkResponse response = NetworkUtils . get ( FbBotMillNetworkConstants . FACEBOOK_BASE_URL + FbBotMillNetworkConstants . FACEBOOK_MESSAGING_INSIGHT_CONV... | GETs the daily unique conversation counts . |
40,962 | public static void postThreadSetting ( StringEntity input ) { String pageToken = FbBotMillContext . getInstance ( ) . getPageToken ( ) ; if ( ! validatePageToken ( pageToken ) ) { return ; } String url = FbBotMillNetworkConstants . FACEBOOK_BASE_URL + FbBotMillNetworkConstants . FACEBOOK_THREAD_SETTINGS_URL + pageToken... | POSTs a thread setting as a JSON string to Facebook . |
40,963 | public static void postMessengerProfile ( StringEntity input ) { String pageToken = FbBotMillContext . getInstance ( ) . getPageToken ( ) ; if ( ! validatePageToken ( pageToken ) ) { return ; } String url = FbBotMillNetworkConstants . FACEBOOK_BASE_URL + FbBotMillNetworkConstants . FACEBOOK_MESSENGER_PROFILE + pageToke... | Post messenger profile . |
40,964 | private static BotMillNetworkResponse postInternal ( String url , StringEntity input ) { BotMillNetworkResponse response = NetworkUtils . post ( url , input ) ; propagateResponse ( response ) ; return response ; } | Performs a POST and propagates it to the registered monitors . |
40,965 | public static void deleteMessengerProfile ( StringEntity input ) { String pageToken = FbBotMillContext . getInstance ( ) . getPageToken ( ) ; if ( ! validatePageToken ( pageToken ) ) { return ; } String url = FbBotMillNetworkConstants . FACEBOOK_BASE_URL + FbBotMillNetworkConstants . FACEBOOK_MESSENGER_PROFILE + pageTo... | DELETEs a JSON string as a Facebook s Messenger Profile . |
40,966 | private static boolean validatePageToken ( String pageToken ) { if ( pageToken == null || "" . equals ( pageToken ) ) { logger . error ( "FbBotMill validation error: Page token can't be null or empty! Have you called the method FbBotMillContext.getInstance().setup(String, String)?" ) ; return false ; } return true ; } | Validates a Facebook Page Token . |
40,967 | private static StringEntity toStringEntity ( Object object ) { StringEntity input = null ; try { String json = FbBotMillJsonUtils . toJson ( object ) ; input = new StringEntity ( json , "UTF-8" ) ; input . setContentType ( "application/json" ) ; logger . debug ( "Request: {}" , inputStreamToString ( input . getContent ... | Utility method that converts an object to its StringEntity representation . |
40,968 | private static String inputStreamToString ( InputStream stream ) throws IOException { ByteArrayOutputStream result = new ByteArrayOutputStream ( ) ; byte [ ] buffer = new byte [ 1024 ] ; int length ; String resultString = null ; while ( ( length = stream . read ( buffer ) ) != - 1 ) { result . write ( buffer , 0 , leng... | Utility method which converts an InputStream to a String . |
40,969 | private FbBotMillEvent toEventActionFrame ( FbBotMillController botMillController ) throws BotMillEventMismatchException { boolean caseSensitive = botMillController . caseSensitive ( ) ; switch ( botMillController . eventType ( ) ) { case MESSAGE : if ( ! botMillController . text ( ) . equals ( "" ) ) { return new Mess... | To event action frame . |
40,970 | protected String safeGetQuickReplyPayload ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getQuickReply ( ) != null && envelope . getMessage ( ) . getQuickReply ( ) . getPayload ( ) != null ) { return envelope . getMessage ( ) . getQuickReply ( ) ... | Retrieves a quick reply payload from an envelope . It never returns null . |
40,971 | protected String safeGetRecipientId ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getRecipient ( ) != null && envelope . getRecipient ( ) . getId ( ) != null ) { return envelope . getRecipient ( ) . getId ( ) ; } return "" ; } | Retrieves the recipient ID from an envelope . It never returns null . |
40,972 | protected String safeGetSenderId ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getSender ( ) != null && envelope . getSender ( ) . getId ( ) != null ) { return envelope . getSender ( ) . getId ( ) ; } return "" ; } | Retrieves the sender ID from an envelope . It never returns null . |
40,973 | protected User safeGetRecipient ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getRecipient ( ) != null && envelope . getRecipient ( ) . getId ( ) != null ) { return envelope . getRecipient ( ) ; } return new User ( ) ; } | Retrieves the recipient from an envelope . It never returns null . |
40,974 | protected LocationCoordinates getLocationMessage ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getAttachments ( ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) != null && envelope . getMessage ( ) . getAttachments ( ) . g... | Retrieves the location from an envelope . It return nulls if none was retrieved . |
40,975 | protected Attachment getImageMessage ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getAttachments ( ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) . g... | Gets the image message . |
40,976 | protected Attachment getAudioMessage ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getAttachments ( ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) . g... | Gets the audio message . |
40,977 | protected Attachment getVideoMessage ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getAttachments ( ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) . g... | Gets the video message . |
40,978 | protected Attachment getFileMessage ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getMessage ( ) != null && envelope . getMessage ( ) . getAttachments ( ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) != null && envelope . getMessage ( ) . getAttachments ( ) . get ( 0 ) . ge... | Gets the file message . |
40,979 | protected User safeGetSender ( MessageEnvelope envelope ) { if ( envelope != null && envelope . getSender ( ) != null && envelope . getSender ( ) . getId ( ) != null ) { return envelope . getSender ( ) ; } return new User ( ) ; } | Retrieves the sender from an envelope . It never returns null . |
40,980 | protected FbBotMillEventType eventKind ( MessageEnvelope envelope ) { IncomingMessage message = envelope . getMessage ( ) ; if ( message != null ) { if ( message instanceof ReceivedMessage ) { if ( getLocationMessage ( envelope ) != null ) { return FbBotMillEventType . LOCATION ; } if ( getImageMessage ( envelope ) != ... | Returns the kind of callback received for the current envelope . |
40,981 | public static UploadAttachmentResponse uploadAttachment ( AttachmentType attachmentType , String attachmentUrl ) { AttachmentPayload payload = new AttachmentPayload ( attachmentUrl , true ) ; Attachment attachment = new Attachment ( attachmentType , payload ) ; AttachmentMessage message = new AttachmentMessage ( attach... | Method to upload an attachment to Facebook s server in order to use it later . Requires the pages_messaging permission . |
40,982 | public ButtonTemplateBuilder addUrlButton ( String title , String url , WebViewHeightRatioType ratioType ) { Button button = ButtonFactory . createUrlButton ( title , url , ratioType ) ; this . payload . addButton ( button ) ; return this ; } | Adds a button which redirects to an URL when clicked to the current template . There can be at most 3 buttons . |
40,983 | public ButtonTemplateBuilder addPhoneNumberButton ( String title , String phoneNumber ) { Button button = ButtonFactory . createPhoneNumberButton ( title , phoneNumber ) ; this . payload . addButton ( button ) ; return this ; } | Adds a button with a phone number to the current template . There can be at most 3 buttons . |
40,984 | public ButtonTemplateBuilder addPostbackButton ( String title , String payload ) { Button button = ButtonFactory . createPostbackButton ( title , payload ) ; this . payload . addButton ( button ) ; return this ; } | Adds a button which sends a payload back when clicked to the current template . There can be at most 3 buttons . |
40,985 | public void sendTextMessage ( String message ) { MessageEnvelope envelope = new MessageEnvelope ( ) ; ReceivedMessage body = new ReceivedMessage ( ) ; body . setText ( message ) ; envelope . setMessage ( body ) ; envelope . setSender ( new User ( facebookMockId ) ) ; System . out . println ( "Sending message: [" + mess... | Sends a text message to all the registered bots . Used to simulate a user typing in chat with your bot . |
40,986 | public void sendPayload ( String payload ) { MessageEnvelope envelope = new MessageEnvelope ( ) ; Postback postback = new Postback ( ) ; postback . setPayload ( payload ) ; envelope . setPostback ( postback ) ; envelope . setSender ( new User ( facebookMockId ) ) ; System . out . println ( "Sending payload: [" + payloa... | Sends a payload to all the registered bots . Used to simulate a user interacting with buttons . |
40,987 | public void sendQuickReplyPayload ( String payload ) { MessageEnvelope envelope = new MessageEnvelope ( ) ; QuickReply quickReply = new QuickReply ( "Sample" , payload ) ; ReceivedMessage message = new ReceivedMessage ( ) ; message . setQuickReply ( quickReply ) ; envelope . setMessage ( message ) ; envelope . setSende... | Sends a quickreply to all the registered bots . Used to simulate a user interacting with buttons . |
40,988 | public void forward ( MessageEnvelope envelope ) { List < FbBot > bots = FbBotMillContext . getInstance ( ) . getRegisteredBots ( ) ; for ( FbBot b : bots ) { b . processMessage ( envelope ) ; } } | Forwards an envelope to the registered bots . |
40,989 | public JsonElement serialize ( Enum < ? > src , Type typeOfSrc , JsonSerializationContext context ) { if ( src . getDeclaringClass ( ) . equals ( PaymentType . class ) ) { return context . serialize ( src . name ( ) ) ; } return context . serialize ( src . name ( ) . toLowerCase ( ) ) ; } | Serializes an Enum as its lowercase name . |
40,990 | protected boolean verifyPatternMatch ( String text ) { if ( this . expectedPattern == null ) { return false ; } return this . expectedPattern . matcher ( text ) . matches ( ) ; } | Verify pattern match . |
40,991 | private static Gson getGson ( ) { if ( gson == null ) { GsonBuilder builder = new GsonBuilder ( ) ; builder . registerTypeHierarchyAdapter ( Enum . class , new EnumLowercaseSerializer ( ) ) ; builder . registerTypeHierarchyAdapter ( Calendar . class , new CalendarSerializer ( ) ) ; builder . registerTypeAdapter ( Attac... | Initializes the current Gson object if null and returns it . The Gson object has custom adapters to manage datatypes according to Facebook formats . |
40,992 | public static < T > T fromJson ( String json , Class < T > T ) { return getGson ( ) . fromJson ( json , T ) ; } | From json . |
40,993 | private void buildAnnotatedInitBehaviour ( ) { Method [ ] methods = this . getClass ( ) . getMethods ( ) ; for ( Method method : methods ) { if ( method . isAnnotationPresent ( FbBotMillInit . class ) ) { try { method . invoke ( this ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) ) ; } } } } | Builds the annotated init behaviour . |
40,994 | protected void addReply ( AutoReply reply ) { if ( actionFrame == null ) { actionFrame = new ActionFrame ( this . getEvent ( ) ) ; } actionFrame . addReply ( reply ) ; } | Adds the reply . |
40,995 | protected void executeReplies ( ) { if ( actionFrame . getEvent ( ) . verifyEventCondition ( this . getEnvelope ( ) ) ) { if ( actionFrame . getReplies ( ) != null && actionFrame . getReplies ( ) . size ( ) > 0 ) { if ( actionFrame . processMultipleReply ( envelope ) && this . botMillPolicy . equals ( BotMillPolicy . F... | Execute replies . |
40,996 | public static AttachmentMessageBuilder getReusableImageAttachment ( String attachmentId ) { AttachmentPayload payload = new AttachmentPayload ( ) ; payload . setAttachmentId ( attachmentId ) ; return new AttachmentMessageBuilder ( AttachmentType . IMAGE , payload ) ; } | Get the reusable image attachment |
40,997 | public static AttachmentMessageBuilder getReusableAudioAttachment ( String attachmentId ) { AttachmentPayload payload = new AttachmentPayload ( ) ; payload . setAttachmentId ( attachmentId ) ; return new AttachmentMessageBuilder ( AttachmentType . AUDIO , payload ) ; } | Get the reusable audio attachment |
40,998 | public static AttachmentMessageBuilder getReusableFileAttachment ( String attachmentId ) { AttachmentPayload payload = new AttachmentPayload ( ) ; payload . setAttachmentId ( attachmentId ) ; return new AttachmentMessageBuilder ( AttachmentType . VIDEO , payload ) ; } | Get the reusable file attachment |
40,999 | public static AirlineItineraryTemplateBuilder addAirlineItineraryTemplate ( String introMessage , String locale , String pnrNumber , BigDecimal totalPrice , String currency ) { return new AirlineItineraryTemplateBuilder ( introMessage , locale , pnrNumber , totalPrice , currency ) ; } | Adds an Airline Itinerary Template to the response . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.