signature:
public class MustacheEngineBuilder { /** * Sets a configuration property .
 * @ param configurationKey
 * @ param value
 * @ param < T >
 * The type of configuration key
 * @ return self */
public < T extends ConfigurationKey > MustacheEngineBuilder setProperty ( T configurationKey , Object value ) { } }

implementation: checkArgumentsNotNull ( configurationKey , value ) ; checkNotBuilt ( ) ; setProperty ( configurationKey . get ( ) , value ) ; return this ;


signature:
public class MustacheEngineBuilder { /** * Callback is useful to configure a component instantiated before the
 * engine is built .
 * @ param callback
 * @ return self */
public MustacheEngineBuilder registerCallback ( EngineBuiltCallback callback ) { } }

implementation: checkArgumentNotNull ( callback ) ; checkNotBuilt ( ) ; this . engineReadyCallbacks . add ( callback ) ; return this ;


signature:
public class MustacheEngineBuilder { /** * Adds a { @ link Mustache } listener . Manually added listeners are always
 * registered before listeners added via configuration extensions .
 * @ param listener
 * @ return self */
public MustacheEngineBuilder addMustacheListener ( MustacheListener listener ) { } }

implementation: checkArgumentNotNull ( listener ) ; checkNotBuilt ( ) ; this . mustacheListeners . add ( listener ) ; return this ;


signature:
public class MustacheEngineBuilder { /** * Each helper must be registered with a unique name . If there are more
 * helpers registered with the same name an { @ link IllegalArgumentException }
 * is thrown . Use { @ link # registerHelper ( String , Helper , boolean ) } to
 * overwrite the helper .
 * @ param name
 * @ param helper
 * @ return self */
public MustacheEngineBuilder registerHelper ( String name , Helper helper ) { } }

implementation: return registerHelper ( name , helper , false ) ;


signature:
public class MustacheEngineBuilder { /** * Each helper must be registered with a unique name . If there is a helper
 * registered with the same name and the param < code > overwrite < / code > is
 * < code > true < / code > the previous instance is replaced , otherwise an
 * { @ link IllegalArgumentException } is thrown .
 * @ param name
 * @ param helper
 * @ param overwrite
 * @ return self */
public MustacheEngineBuilder registerHelper ( String name , Helper helper , boolean overwrite ) { } }

implementation: checkArgumentsNotNull ( name , helper ) ; checkNotBuilt ( ) ; if ( ! overwrite && helpers . containsKey ( name ) ) { throw new IllegalArgumentException ( "A helper with this name is already registered: " + name ) ; } helpers . put ( name , helper ) ; return this ;


signature:
public class MustacheEngineBuilder { /** * Each helper must be registered with a unique name . If there is a helper
 * registered with the same name and the param < code > overwrite < / code > is
 * < code > true < / code > the previous instance is replaced , otherwise an
 * { @ link IllegalArgumentException } is thrown .
 * @ param helpers
 * @ param overwrite
 * @ return */
public MustacheEngineBuilder registerHelpers ( Map < String , Helper > helpers , boolean overwrite ) { } }

implementation: checkArgumentNotNull ( helpers ) ; checkNotBuilt ( ) ; for ( Entry < String , Helper > entry : helpers . entrySet ( ) ) { registerHelper ( entry . getKey ( ) , entry . getValue ( ) , overwrite ) ; } return this ;


signature:
public class MustacheEngineBuilder { /** * Add a value converter .
 * @ param converter
 * @ return self */
public MustacheEngineBuilder addValueConverter ( ValueConverter converter ) { } }

implementation: checkArgumentNotNull ( converter ) ; checkNotBuilt ( ) ; this . valueConverters . add ( converter ) ; return this ;


signature:
public class MustacheEngineBuilder { /** * Add a context converter .
 * @ param converter
 * @ return self */
public MustacheEngineBuilder addContextConverter ( ContextConverter converter ) { } }

implementation: checkArgumentNotNull ( converter ) ; checkNotBuilt ( ) ; this . contextConverters . add ( converter ) ; return this ;


signature:
public class Strings { /** * Capitalizes all the delimiter separated words .
 * @ param text
 * @ param delimiter
 * @ return the capitalized input */
public static String capitalizeFully ( String text , Character delimiter ) { } }

implementation: if ( isEmpty ( text ) ) { return text ; } text = text . toLowerCase ( ) ; boolean capitalizeNext = true ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { final char ch = text . charAt ( i ) ; if ( delimiter . equals ( ch ) ) { capitalizeNext = true ; builder . append ( ch ) ; } else if ( capitalizeNext ) { builder . append ( Character . toTitleCase ( ch ) ) ; capitalizeNext = false ; } else { builder . append ( ch ) ; } } return builder . toString ( ) ;


signature:
public class AbstractHelper { /** * Escape appended sequence if needed .
 * @ param options
 * @ param sequence
 * @ see TextSupport */
protected void append ( Options options , CharSequence sequence ) { } }

implementation: TextSupport textSupport = this . textSupport ; if ( textSupport == null || isUnescapeVariable ( options ) ) { options . append ( sequence ) ; } else { try { textSupport . appendEscapedHtml ( sequence . toString ( ) , options . getAppendable ( ) ) ; } catch ( IOException e ) { throw new MustacheException ( MustacheProblem . RENDER_IO_ERROR , e ) ; } }


signature:
public class DefaultMustacheEngine { /** * Properties of the source cache are dependent on that of the template
 * cache . */
private ComputingCache < String , Optional < String > > buildSourceCache ( ) { } }

implementation: return buildCache ( "Source" , key -> Optional . ofNullable ( locateAndRead ( key ) ) , ( key , cause ) -> LOGGER . debug ( "Removed template source from cache [templateId: {}, cause: {}]" , key , cause ) ) ;


signature:
public class DefaultParsingHandler { /** * E . g . = < % % > = , = [ ] =
 * @ param key */
private void changeDelimiters ( String key ) { } }

implementation: if ( key . charAt ( 0 ) != MustacheTagType . DELIMITER . getCommand ( ) || key . charAt ( key . length ( ) - 1 ) != MustacheTagType . DELIMITER . getCommand ( ) ) { throw new MustacheException ( MustacheProblem . COMPILE_INVALID_DELIMITERS , "Invalid set delimiters tag: %s [line: %s]" , key , line ) ; } Matcher matcher = Patterns . newSetDelimitersContentPattern ( ) . matcher ( key . substring ( 1 , key . length ( ) - 1 ) ) ; if ( matcher . find ( ) ) { delimiters . setNewValues ( matcher . group ( 1 ) , matcher . group ( 3 ) ) ; } else { throw new MustacheException ( MustacheProblem . COMPILE_INVALID_DELIMITERS , "Invalid delimiters set: %s [line: %s]" , key , line ) ; }


signature:
public class DefaultParsingHandler { /** * Push the container wrapper on the stack .
 * @ param container */
private void push ( ContainerSegmentBase container ) { } }

implementation: containerStack . addFirst ( container ) ; LOGGER . trace ( "Push {} [name: {}]" , container . getType ( ) , container . getContent ( ) ) ;


signature:
public class DefaultParsingHandler { /** * Add the segment to the container on the stack .
 * @ param segment */
private void addSegment ( SegmentBase segment ) { } }

implementation: containerStack . peekFirst ( ) . addSegment ( segment ) ; LOGGER . trace ( "Add {}" , segment ) ;


signature:
public class DefaultParsingHandler { /** * Validate the compiled template . */
private RootSegmentBase validate ( ) { } }

implementation: ContainerSegmentBase root = containerStack . peekFirst ( ) ; if ( ! ( root instanceof RootSegmentBase ) ) { throw new MustacheException ( MustacheProblem . COMPILE_INVALID_TEMPLATE , "Incorrect last container segment on the stack: %s" , containerStack . peekFirst ( ) . toString ( ) , line ) ; } return ( RootSegmentBase ) root ;


signature:
public class HelperExecutionHandler { /** * Extracts parts from an input string . This implementation is quite naive
 * and should be possibly rewritten . Note that we can ' t use a simple
 * splitter because of string literals may contain whitespace chars .
 * @ param name
 * @ param segment
 * @ return the parts of the helper name
 * @ throws MustacheException
 * If a compilation problem occurs */
static Iterator < String > splitHelperName ( String name , Segment segment ) { } }

implementation: boolean stringLiteral = false ; boolean arrayLiteral = false ; boolean space = false ; List < String > parts = new ArrayList < > ( ) ; StringBuilder buffer = new StringBuilder ( ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { if ( name . charAt ( i ) == ' ' ) { if ( ! space ) { if ( ! stringLiteral && ! arrayLiteral ) { if ( buffer . length ( ) > 0 ) { parts . add ( buffer . toString ( ) ) ; buffer = new StringBuilder ( ) ; } space = true ; } else { buffer . append ( name . charAt ( i ) ) ; } } } else { if ( ! arrayLiteral && Strings . isStringLiteralSeparator ( name . charAt ( i ) ) ) { stringLiteral = ! stringLiteral ; } else if ( ! stringLiteral && Strings . isListLiteralStart ( name . charAt ( i ) ) ) { arrayLiteral = true ; } else if ( ! stringLiteral && Strings . isListLiteralEnd ( name . charAt ( i ) ) ) { arrayLiteral = false ; } space = false ; buffer . append ( name . charAt ( i ) ) ; } } if ( buffer . length ( ) > 0 ) { if ( stringLiteral || arrayLiteral ) { throw new MustacheException ( MustacheProblem . COMPILE_HELPER_VALIDATION_FAILURE , "Unterminated string or array literal detected: %s" , segment ) ; } parts . add ( buffer . toString ( ) ) ; } return parts . iterator ( ) ;


signature:
public class Expressions { /** * Note that we have to use a separate { @ link ELProcessor } for each evaluation
 * as the { @ link OptionsELResolver } may not be reused .
 * @ param expression
 * @ param options
 * @ param configuration
 * @ return the result of the expression evaluation */
static Object eval ( String expression , Options options , Configuration configuration ) { } }

implementation: ELProcessorFactory elpFactory = ( ELProcessorFactory ) configuration . getPropertyValue ( ELProcessorFactory . EL_PROCESSOR_FACTORY_KEY ) ; ELProcessor elp = elpFactory . createELProcessor ( configuration ) ; elp . getELManager ( ) . addELResolver ( new OptionsELResolver ( options ) ) ; return elp . eval ( expression ) ;


signature:
public class HelpersBuilder { /** * Add an instance of { @ link IfHelper } with the { @ value # IF } name and the given else delimiters .
 * @ return self */
public HelpersBuilder addIf ( String elseStartDelimiter , String elseEndDelimiter ) { } }

implementation: builder . put ( IF , new IfHelper ( elseStartDelimiter , elseEndDelimiter ) ) ; return this ;


signature:
public class HelpersBuilder { /** * Add an instance of { @ link ChooseHelper } with the { @ value # CHOOSE } name .
 * Also adds the dependent helpers .
 * @ return self */
public HelpersBuilder addChoose ( ) { } }

implementation: builder . put ( CHOOSE , new ChooseHelper ( ) ) ; builder . put ( WHEN , new ChooseHelper . WhenHelper ( ) ) ; builder . put ( OTHERWISE , new ChooseHelper . OtherwiseHelper ( ) ) ; return this ;


signature:
public class HelpersBuilder { /** * Add an instance of { @ link SwitchHelper } with the { @ value # SWITCH } name .
 * Also adds the dependent helpers .
 * @ param caseDefaultIsBreak
 * If < code > true < / code > the matching case helper terminates the flow by
 * default .
 * @ return self */
public HelpersBuilder addSwitch ( boolean caseDefaultIsBreak ) { } }

implementation: builder . put ( SWITCH , new SwitchHelper ( ) ) ; builder . put ( CASE , new SwitchHelper . CaseHelper ( caseDefaultIsBreak ) ) ; builder . put ( DEFAULT , new SwitchHelper . DefaultHelper ( ) ) ; return this ;


signature:
public class DecoratorConverter { /** * Returns a decorator converter builder for the specified delegate type .
 * @ param delegateType
 * @ return a new builder instance */
public static < T > Builder < T > decorate ( Class < T > delegateType ) { } }

implementation: return decorate ( o -> ( delegateType . isAssignableFrom ( Decorator . unwrap ( o ) . getClass ( ) ) ) ) ;


signature:
public class AsyncAppendable { /** * Append the result to the parent . */
private void flush ( ) { } }

implementation: try { parent . append ( future . get ( 60 , TimeUnit . SECONDS ) . collect ( this ) ) ; parent . append ( buffer ) ; if ( parent instanceof AsyncAppendable ) { ( ( AsyncAppendable ) parent ) . flush ( ) ; } } catch ( Exception e ) { throw new MustacheException ( MustacheProblem . RENDER_ASYNC_PROCESSING_ERROR , e ) ; }


signature:
public class AbstractConfigurationAware { /** * When overriding this method , always call < code > super . init ( config ) < / code > . */
@ Override public void init ( Configuration configuration ) { } }

implementation: checkNotInitialized ( this . configuration != null ) ; this . configuration = configuration ; this . init ( ) ;


signature:
public class ReflectionResolver { /** * The member cache may theoretically cause memory leaks due to using hard
 * references to { @ link Class } and { @ link Member } instances . As a temporary
 * workaround we provide a way to invalidate the cache or some of its
 * entries ( e . g . for a concrete classloader ) .
 * @ param predicate
 * If null , all cache entries are discarded , otherwise an entry
 * is only discarded if the given predicate returns
 * < code > true < / code > for the { @ link MemberKey # getClass ( ) } */
public void invalidateMemberCache ( Predicate < Class < ? > > predicate ) { } }

implementation: if ( memberCache == null ) { return ; } if ( predicate == null ) { memberCache . clear ( ) ; } else { memberCache . invalidate ( ( key ) -> predicate . test ( key . getClazz ( ) ) ) ; }


signature:
public class ReflectionResolver { /** * First tries to find a valid method with the same name , afterwards method
 * following JavaBean naming convention ( the method starts with
 * < b > get / is < / b > prefix ) .
 * @ param clazz
 * @ param name
 * @ return the found method or < code > null < / code > */
static Method findMethod ( Class < ? > clazz , String name ) { } }

implementation: checkArgumentNotNull ( clazz ) ; checkArgumentNotNull ( name ) ; Method foundMatch = null ; Method foundGetMatch = null ; Method foundIsMatch = null ; for ( Method method : SecurityActions . getMethods ( clazz ) ) { if ( ! isMethodValid ( method ) ) { continue ; } if ( method . isBridge ( ) ) { LOGGER . debug ( "Skipping bridge method {}" , method ) ; continue ; } if ( name . equals ( method . getName ( ) ) ) { foundMatch = method ; } else if ( Reflections . matchesPrefix ( name , method . getName ( ) , GET_PREFIX ) ) { foundGetMatch = method ; } else if ( Reflections . matchesPrefix ( name , method . getName ( ) , IS_PREFIX ) ) { foundIsMatch = method ; } } if ( foundMatch == null ) { foundMatch = ( foundGetMatch != null ? foundGetMatch : foundIsMatch ) ; } LOGGER . debug ( "Method for [{}] {}found on type {}: {}" , name , foundMatch != null ? "" : "not " , clazz . getName ( ) , foundMatch ) ; return foundMatch ;


signature:
public class ReflectionResolver { /** * Tries to find a public field with the given name on the given class .
 * @ param clazz
 * @ param name
 * @ return the found field or < code > null < / code > */
static Field findField ( Class < ? > clazz , String name ) { } }

implementation: checkArgumentNotNull ( clazz ) ; checkArgumentNotNull ( name ) ; Field found = null ; for ( Field field : SecurityActions . getFields ( clazz ) ) { if ( field . getName ( ) . equals ( name ) ) { found = field ; } } LOGGER . debug ( "Field {} {}found on type: {}" , name , found != null ? "" : "not " , clazz . getName ( ) ) ; return found ;


signature:
public class ReflectionResolver { /** * A valid method :
 * < ul >
 * < li > is public < / li >
 * < li > has no parameters < / li >
 * < li > has non - void return type < / li >
 * < li > its declaring class is not { @ link Object } < / li >
 * < / ul >
 * @ param method
 * @ return < code > true < / code > if the given method is considered a read method */
private static boolean isMethodValid ( Method method ) { } }

implementation: return method != null && Modifier . isPublic ( method . getModifiers ( ) ) && method . getParameterTypes ( ) . length == 0 && ! method . getReturnType ( ) . equals ( Void . TYPE ) && ! Object . class . equals ( method . getDeclaringClass ( ) ) ;


signature:
public class ConfigurationExtensions { /** * Register helper and do nothing if a helper with the same name is already registered .
 * @ param builder
 * @ param helpers */
public static void registerHelpers ( ConfigurationExtensionBuilder builder , Map < String , Helper > helpers ) { } }

implementation: Checker . checkArgumentsNotNull ( builder , helpers ) ; for ( Entry < String , Helper > entry : helpers . entrySet ( ) ) { registerHelper ( builder , entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class ConfigurationExtensions { /** * Register helpers and do nothing if a helper with the same name is already registered .
 * @ param builder
 * @ param name
 * @ param helper */
public static void registerHelper ( ConfigurationExtensionBuilder builder , String name , Helper helper ) { } }

implementation: Checker . checkArgumentsNotNull ( builder , name , helper ) ; try { builder . registerHelper ( name , helper ) ; } catch ( IllegalArgumentException ignored ) { }


signature:
public class Segments { /** * Read segment lines before rendering .
 * @ param container
 * @ return */
static List < List < Segment > > readSegmentLinesBeforeRendering ( AbstractContainerSegment container ) { } }

implementation:
List < List < Segment > > lines = new ArrayList < > ( ) ; List < Segment > currentLine = new ArrayList < > ( ) ; for ( Segment segment : container ) { if ( ! SegmentType . LINE_SEPARATOR . equals ( segment . getType ( ) ) ) { currentLine . add ( segment ) ; } else { // New line separator - flush the line
currentLine . add ( segment ) ; lines . add ( currentLine ) ; currentLine = new ArrayList < > ( ) ; } } // Add the last line manually - there is no line separator to trigger
// flush
if ( ! currentLine . isEmpty ( ) ) { lines . add ( currentLine ) ; } return lines ;


signature:
public class CacheHelper { /** * Invalidate the cache fragments whose key contains the given part of the
 * key .
 * @ param keyPart */
public void invalidateFragments ( final String keyPart ) { } }

implementation: if ( fragments == null || keyPart == null ) { return ; } fragments . invalidate ( fragmentKey -> fragmentKey . getKey ( ) . contains ( keyPart ) ) ;


signature:
public class DefaultExecutionContext { /** * Resolve the leading context object ( the first part of the key ) . E . g .
 * < code > foo < / code > in < code > { { foo . bar . name } } < / code > may identify a property
 * of some context object on the stack ( passed data , section iteration ,
 * nested context , . . . ) , or some context and data unrelated object ( e . g . CDI
 * bean ) .
 * @ param name
 * @ param value
 * The value wrapper - ResolutionContext
 * @ param hintRef
 * @ return the resolved leading context object
 * @ see Hint */
private Object resolveLeadingContextObject ( String name , ValueWrapper value , AtomicReference < Hint > hintRef ) { } }

implementation:
Object leading = resolveContextObject ( name , value , hintRef ) ; if ( leading == null ) { // Leading context object not found - try to resolve context
// unrelated objects ( JNDI lookup , CDI , etc . )
Hint hint = hintRef != null ? hintRef . get ( ) : null ; if ( hint != null ) { leading = hint . resolve ( null , name , value ) ; } if ( leading == null ) { leading = resolve ( null , name , value , hint == null && hintRef != null ) ; } } return leading ;


signature:
public class TimeFormatHelper { /** * should be safe */
protected TemporalAccessor getFormattableObject ( Object value , Locale locale , TimeZone timeZone , MustacheTagInfo tagInfo ) { } }

implementation: if ( value instanceof TemporalAccessor ) { return ( TemporalAccessor ) value ; } else if ( value instanceof Date ) { return LocalDateTime . ofInstant ( ( ( Date ) value ) . toInstant ( ) , timeZone . toZoneId ( ) ) ; } else if ( value instanceof Calendar ) { return LocalDateTime . ofInstant ( ( ( Calendar ) value ) . toInstant ( ) , timeZone . toZoneId ( ) ) ; } else if ( value instanceof Number ) { return LocalDateTime . ofInstant ( Instant . ofEpochMilli ( ( ( Number ) value ) . longValue ( ) ) , timeZone . toZoneId ( ) ) ; } else { throw valueNotAFormattableObject ( value , tagInfo ) ; }


signature:
public class ConfigurationProperties { /** * Build the property key for the given name and prefix parts . The name is
 * converted to CamelCase ( underscore is used as a delimiter ) :
 * < pre >
 * MY _ PROPERTY _ NAME
 * < / pre >
 * becomes
 * < pre >
 * myPropertyName
 * < / pre >
 * @ param propertyName
 * @ param prefixParts
 * @ return the key */
static String buildPropertyKey ( String propertyName , String [ ] prefixParts ) { } }

implementation: return buildPropertyKey ( propertyName , Strings . UNDERSCORE , prefixParts ) ;


signature:
public class ConfigurationProperties { /** * Build the property key for the given name and prefix parts . The name is
 * converted to CamelCase ( using the specified delimiter ; delimiters are
 * removed in the end ) .
 * @ param propertyName
 * @ param delimiter
 * @ param prefixParts
 * @ return the key */
static String buildPropertyKey ( String propertyName , String delimiter , String [ ] prefixParts ) { } }

implementation: StringBuilder key = new StringBuilder ( ) ; for ( final String prefixPart : prefixParts ) { key . append ( prefixPart ) ; key . append ( Strings . DOT ) ; } key . append ( Strings . uncapitalize ( Strings . replace ( Strings . capitalizeFully ( propertyName , delimiter . toCharArray ( ) [ 0 ] ) , delimiter , "" ) ) ) ; return key . toString ( ) ;


signature:
public class StorageExt { /** * Returns a Local Storage .
 * @ return the localStorage instance , or < code > null < / code > if Web Storage is NOT supported . */
public static StorageExt getLocalStorage ( ) { } }

implementation: if ( localStorage == null && Storage . isLocalStorageSupported ( ) ) { localStorage = new StorageExt ( Storage . getLocalStorageIfSupported ( ) ) ; } return localStorage ;


signature:
public class StorageExt { /** * Returns a Session Storage .
 * @ return the sessionStorage instance , or < code > null < / code > if Web Storage is NOT supported . */
public static StorageExt getSessionStorage ( ) { } }

implementation: if ( sessionStorage == null && Storage . isSessionStorageSupported ( ) ) { sessionStorage = new StorageExt ( Storage . getSessionStorageIfSupported ( ) ) ; } return sessionStorage ;


signature:
public class StorageExt { /** * Registers an event handler for { @ link StorageChangeEvent }
 * @ param handler an event handler instance
 * @ return { @ link HandlerRegistration } used to remove this handler */
public HandlerRegistration addStorageChangeHandler ( final StorageChangeEvent . Handler handler ) { } }

implementation: if ( handler == null ) throw new IllegalArgumentException ( "Handler can not be null" ) ; ensureHandlerSet ( ) . add ( handler ) ; return new HandlerRegistration ( ) { @ Override public void removeHandler ( ) { if ( handlers != null ) { handlers . remove ( handler ) ; if ( handlers . isEmpty ( ) ) { handlers = null ; } } } } ;


signature:
public class StorageExt { /** * Removes all items in the Storage , and its cache if activated
 * @ see < a href = " http : / / www . w3 . org / TR / webstorage / # dom - storage - clear " > W3C Web
 * Storage - Storage . clear ( ) < / a > */
public void clear ( ) { } }

implementation: storage . clear ( ) ; cache . clear ( ) ; fireEvent ( StorageChangeEvent . ChangeType . CLEAR , null , null , null , null , null ) ;


signature:
public class StorageExt { /** * Test if this storage contains a value for the specified key .
 * { @ link StorageKeyFactory } is preferred to get a { @ link StorageKey } instance for primitive types .
 * @ param key the key whose presence in this storage is to be tested
 * @ param < T > the type of stored value
 * @ return < tt > true < / tt > if this storage contains a value for the specified key . */
public < T > boolean containsKey ( StorageKey < T > key ) { } }

implementation: return storage . getItem ( key . name ( ) ) != null ;


signature:
public class StorageExt { /** * Returns the value in the Storage associated with the specified key ,
 * or { @ code null } if this Storage contains no mapping for the key .
 * Note : Deserialization will be performed to return a correct value type . < br / >
 * { @ link StorageKeyFactory } is preferred to get a { @ link StorageKey } instance for primitive types .
 * @ param key the key to a value in the Storage
 * @ param < T > the type of stored value
 * @ return the value associated with the given key
 * @ throws SerializationException
 * @ see < a href = " http : / / www . w3 . org / TR / webstorage / # dom - storage - getitem " > W3C Web
 * Storage - Storage . getItem ( k ) < / a > */
public < T > T get ( StorageKey < T > key ) throws SerializationException { } }

implementation: T item = cache . get ( key ) ; if ( item == null ) { item = StorageUtils . deserialize ( key . getClazz ( ) , storage . getItem ( key . name ( ) ) ) ; cache . put ( key , item ) ; } return item ;


signature:
public class StorageExt { /** * Store the specified value with the specified key in this storage .
 * Note : < code > null < / code > value is not allowed . < br / >
 * If the storage previously contained a mapping for the key , the old
 * value is replaced . < br / >
 * { @ link StorageKeyFactory } is preferred to get a { @ link StorageKey } instance for primitive types .
 * @ param key key with which the specified value is to be associated
 * @ param value value to be associated with the specified key
 * @ throws SerializationException
 * @ throws StorageQuotaExceededException */
public < T > void put ( StorageKey < T > key , T value ) throws SerializationException , StorageQuotaExceededException { } }

implementation:
if ( value == null ) { throw new NullPointerException ( ) ; } try { String data = StorageUtils . serialize ( key . getClazz ( ) , value ) ; // Update store and cache
String oldData = storage . getItem ( key . name ( ) ) ; storage . setItem ( key . name ( ) , data ) ; T oldValue = cache . put ( key , value ) ; fireEvent ( StorageChangeEvent . ChangeType . PUT , key , value , oldValue , data , oldData ) ; } catch ( JavaScriptException e ) { String msg = e . getMessage ( ) ; if ( msg != null && msg . contains ( "QUOTA" ) && msg . contains ( "DOM" ) ) { throw new StorageQuotaExceededException ( key , e ) ; } throw e ; }


signature:
public class StorageExt { /** * Removes the record for the specified key from this storage if present .
 * { @ link StorageKeyFactory } is preferred to get a { @ link StorageKey } instance for primitive types
 * @ param key key whose mapping is to be removed from the map
 * @ param < T > the type of stored value */
public < T extends Serializable > void remove ( StorageKey < T > key ) { } }

implementation: String data = storage . getItem ( key . name ( ) ) ; storage . removeItem ( key . name ( ) ) ; T value = cache . remove ( key ) ; fireEvent ( StorageChangeEvent . ChangeType . REMOVE , key , null , value , null , data ) ;


signature:
public class StorageExt { /** * Fire { @ link StorageChangeEvent } */
private < T > void fireEvent ( StorageChangeEvent . ChangeType changeType , StorageKey < T > key , T value , T oldVal , String data , String oldData ) { } }

implementation: UncaughtExceptionHandler ueh = GWT . getUncaughtExceptionHandler ( ) ; if ( handlers != null && ! handlers . isEmpty ( ) ) { T oldValue = oldVal ; if ( oldValue == null && oldData != null && StorageChangeEvent . Level . OBJECT . equals ( eventLevel ) ) { try { oldValue = StorageUtils . deserialize ( key . getClazz ( ) , data ) ; } catch ( SerializationException e ) { if ( ueh != null ) ueh . onUncaughtException ( e ) ; oldValue = null ; } } final StorageChangeEvent event = new StorageChangeEvent ( changeType , key , value , oldValue , data , oldData ) ; for ( StorageChangeEvent . Handler handler : handlers ) { try { handler . onStorageChange ( event ) ; } catch ( Exception e ) { if ( ueh != null ) { ueh . onUncaughtException ( e ) ; } } } }


signature:
public class StorageSerializationStreamWriter { /** * Copy from { @ link com . google . gwt . user . client . rpc . impl . AbstractSerializationStream # longToBase64 ( long ) }
 * Return an optionally single - quoted string containing a base - 64 encoded
 * version of the given long value .
 * Keep this synchronized with the version in Base64Utils . */
static String longToBase64 ( long value ) { } }

implementation:
// Convert to ints early to avoid need for long ops
int low = ( int ) ( value & 0xffffffff ) ; int high = ( int ) ( value >> 32 ) ; StringBuilder sb = new StringBuilder ( ) ; boolean haveNonZero = base64Append ( sb , ( high >> 28 ) & 0xf , false ) ; haveNonZero = base64Append ( sb , ( high >> 22 ) & 0x3f , haveNonZero ) ; haveNonZero = base64Append ( sb , ( high >> 16 ) & 0x3f , haveNonZero ) ; haveNonZero = base64Append ( sb , ( high >> 10 ) & 0x3f , haveNonZero ) ; haveNonZero = base64Append ( sb , ( high >> 4 ) & 0x3f , haveNonZero ) ; int v = ( ( high & 0xf ) << 2 ) | ( ( low >> 30 ) & 0x3 ) ; haveNonZero = base64Append ( sb , v , haveNonZero ) ; haveNonZero = base64Append ( sb , ( low >> 24 ) & 0x3f , haveNonZero ) ; haveNonZero = base64Append ( sb , ( low >> 18 ) & 0x3f , haveNonZero ) ; haveNonZero = base64Append ( sb , ( low >> 12 ) & 0x3f , haveNonZero ) ; base64Append ( sb , ( low >> 6 ) & 0x3f , haveNonZero ) ; base64Append ( sb , low & 0x3f , true ) ; return sb . toString ( ) ;


signature:
public class StorageKeyFactory { /** * Returns non - primitive type value ' s storage key .
 * @ param keyName name of storage key
 * @ param < T > type of value
 * @ return non - primitive type value ' s storage key
 * @ deprecated use { @ link # isSerializableKey ( String ) } or { @ link # serializableKey ( String ) } instead */
@ Deprecated public static < T > StorageKey < T > objectKey ( String keyName ) { } }

implementation: return new StorageKey < > ( keyName , Object . class ) ;


signature:
public class StorageKeyFactory { /** * Returns IsSerializable type value ' s storage key .
 * @ param keyName name of storage key
 * @ param < T > type of value
 * @ return IsSerializable type value ' s storage key */
public static < T extends IsSerializable > StorageKey < T > isSerializableKey ( String keyName ) { } }

implementation: return new StorageKey < > ( keyName , IsSerializable . class ) ;


signature:
public class StorageKeyFactory { /** * Returns Serializable type value ' s storage key .
 * @ param keyName name of storage key
 * @ param < T > type of value
 * @ return Serializable type value ' s storage key */
public static < T extends Serializable > StorageKey < T > serializableKey ( String keyName ) { } }

implementation: return new StorageKey < > ( keyName , Serializable . class ) ;


signature:
public class StorageTypeFinder { /** * Returns a simple types , including classes and
 * interfaces , parameterized , and raw types . Null is returned for other types
 * such as arrays and type parameters ( e . g . , ' E ' in java . util . List < E > ) because
 * filtering is meaningless for such types . */
protected String getBaseTypeName ( JClassType type ) { } }

implementation: if ( type == null ) { return null ; } if ( type instanceof JRealClassType ) { return type . getQualifiedSourceName ( ) ; } else if ( type . isParameterized ( ) != null ) { return type . isParameterized ( ) . getBaseType ( ) . getQualifiedSourceName ( ) ; } else if ( type . isRawType ( ) != null ) { return type . isRawType ( ) . getQualifiedSourceName ( ) ; } return type . getQualifiedSourceName ( ) ;


signature:
public class FloatingActionButton { /** * Initializes the view .
 * @ param attributeSet
 * The attribute set , the view ' s attributes should be obtained from , as an instance of
 * the type { @ link AttributeSet } or null , if no attributes should be obtained */
private void initialize ( @ Nullable final AttributeSet attributeSet ) { } }

implementation: inflateLayout ( ) ; obtainStyledAttributes ( attributeSet ) ; adaptShadow ( ) ; adaptImageButtonSize ( ) ; adaptImageButtonBackground ( ) ;


signature:
public class FloatingActionButton { /** * Inflates the view ' s layout . */
private void inflateLayout ( ) { } }

implementation: imageButton = new ImageButton ( getContext ( ) ) ; LayoutParams layoutParams = new LayoutParams ( 0 , 0 ) ; layoutParams . addRule ( RelativeLayout . CENTER_IN_PARENT , RelativeLayout . TRUE ) ; addView ( imageButton , layoutParams ) ;


signature:
public class FloatingActionButton { /** * Obtains the view ' s attributes from a specific attribute set .
 * @ param attributeSet
 * The attribute set , the view ' s attributes should be obtained from , as an instance of
 * the type { @ link AttributeSet } or null , if no attributes should be obtained */
private void obtainStyledAttributes ( @ Nullable final AttributeSet attributeSet ) { } }

implementation: TypedArray typedArray = getContext ( ) . obtainStyledAttributes ( attributeSet , R . styleable . FloatingActionButton ) ; try { obtainSize ( typedArray ) ; obtainColor ( typedArray ) ; obtainActivatedColor ( typedArray ) ; obtainPressedColor ( typedArray ) ; obtainDisabledColor ( typedArray ) ; obtainIcon ( typedArray ) ; obtainVisibilityAnimationDuration ( typedArray ) ; } finally { typedArray . recycle ( ) ; }


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s size from a specific typed array .
 * @ param typedArray
 * The typed array , the color should be obtained from , as an instance of the class
 * { @ link TypedArray } . The typed array may not be null */
private void obtainSize ( @ NonNull final TypedArray typedArray ) { } }

implementation: Size defaultSize = Size . NORMAL ; size = Size . fromValue ( typedArray . getInt ( R . styleable . FloatingActionButton_size , defaultSize . getValue ( ) ) ) ;


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s color from a specific typed array .
 * @ param typedArray
 * The typed array , the color should be obtained from , as an instance of the class
 * { @ link TypedArray } . The typed array may not be null */
private void obtainColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultColor = ThemeUtil . getColor ( getContext ( ) , R . attr . colorAccent ) ; color = typedArray . getColor ( R . styleable . FloatingActionButton_android_color , defaultColor ) ;


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s activated color from a specific typed array .
 * @ param typedArray
 * The typed array , the activated color should be obtained from , as an instance of the
 * class { @ link TypedArray } . The typed array may not be null */
private void obtainActivatedColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultActivatedColor = getControlActivatedColor ( ) ; activatedColor = typedArray . getColor ( R . styleable . FloatingActionButton_activatedColor , defaultActivatedColor ) ;


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s pressed color from a specific typed array .
 * @ param typedArray
 * The typed array , the pressed color should be obtained from , as an instance of the
 * class { @ link TypedArray } . The typed array may not be null */
private void obtainPressedColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultPressedColor = getControlHighlightColor ( ) ; pressedColor = typedArray . getColor ( R . styleable . FloatingActionButton_pressedColor , defaultPressedColor ) ;


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s disabled color from a specific typed array .
 * @ param typedArray
 * The typed array , the disabled color should be obtained from , as an instance of the
 * class { @ link TypedArray } . The typed array may not be null */
private void obtainDisabledColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultDisabledColor = ContextCompat . getColor ( getContext ( ) , R . color . floating_action_button_disabled_color ) ; disabledColor = typedArray . getColor ( R . styleable . FloatingActionButton_disabledColor , defaultDisabledColor ) ;


signature:
public class FloatingActionButton { /** * Obtains the floating action button ' s icon from a specific typed array .
 * @ param typedArray
 * The typed array , the ripple color should be obtained from , as an instance of the
 * class { @ link TypedArray } . The typed array may not be null */
private void obtainIcon ( @ NonNull final TypedArray typedArray ) { } }

implementation: Drawable icon = typedArray . getDrawable ( R . styleable . FloatingActionButton_android_icon ) ; setIcon ( icon ) ;


signature:
public class FloatingActionButton { /** * Obtains the duration of the animation , which may be used to changed the visibility of the
 * floating action button , from a specific typed array .
 * @ param typedArray
 * The typed array , the animation duration should be obtained from , as an instance of
 * the class { @ link TypedArray } . The typed array may not be null */
private void obtainVisibilityAnimationDuration ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultAnimationDuration = getResources ( ) . getInteger ( R . integer . floating_action_button_visibility_animation_duration ) ; int duration = typedArray . getInteger ( R . styleable . FloatingActionButton_visibilityAnimationDuration , defaultAnimationDuration ) ; setVisibilityAnimationDuration ( duration ) ;


signature:
public class FloatingActionButton { /** * Adapts the shadow of the floating action button , depending on its size . */
private void adaptShadow ( ) { } }

implementation: if ( getSize ( ) == Size . NORMAL ) { setBackgroundResource ( R . drawable . floating_action_button_shadow_normal ) ; } else if ( getSize ( ) == Size . SMALL ) { setBackgroundResource ( R . drawable . floating_action_button_shadow_small ) ; } else { setBackgroundResource ( R . drawable . floating_action_button_shadow_large ) ; }


signature:
public class FloatingActionButton { /** * Adapts the size of the image button , which is used to show the floating image button ' s
 * background and icon , depending on the floating button ' s size . */
private void adaptImageButtonSize ( ) { } }

implementation: int pixelSize = getPixelSize ( ) ; LayoutParams layoutParams = ( LayoutParams ) imageButton . getLayoutParams ( ) ; layoutParams . width = pixelSize ; layoutParams . height = pixelSize ; imageButton . setLayoutParams ( layoutParams ) ; imageButton . requestLayout ( ) ;


signature:
public class FloatingActionButton { /** * Adapts the background of the image button , which is used to show the floating image button ' s
 * background and icon , depending on the floating button ' s colors . */
@ SuppressLint ( "NewApi" ) private void adaptImageButtonBackground ( ) { } }

implementation: Drawable background = createStateListBackgroundDrawable ( ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { Drawable rippleDrawable = new RippleDrawable ( new ColorStateList ( new int [ ] [ ] { { } } , new int [ ] { getPressedColor ( ) } ) , background , null ) ; ViewUtil . setBackground ( imageButton , rippleDrawable ) ; } else { ViewUtil . setBackground ( imageButton , background ) ; }


signature:
public class FloatingActionButton { /** * Creates and returns a state list drawable , which can be used as the floating action button
 * background and adapts the background color depending on the button ' s current state .
 * @ return The drawable , which has been created , as an instance of the class { @ link Drawable } */
private Drawable createStateListBackgroundDrawable ( ) { } }

implementation: StateListDrawable drawable = new StateListDrawable ( ) ; if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { drawable . addState ( new int [ ] { android . R . attr . state_enabled , android . R . attr . state_pressed } , createPressedBackgroundDrawable ( ) ) ; } drawable . addState ( new int [ ] { android . R . attr . state_enabled , android . R . attr . state_activated } , createActivatedBackgroundDrawable ( ) ) ; drawable . addState ( new int [ ] { android . R . attr . state_enabled } , createBackgroundDrawable ( getColor ( ) ) ) ; drawable . addState ( new int [ ] { } , createDisabledBackgroundDrawable ( ) ) ; return drawable ;


signature:
public class FloatingActionButton { /** * Creates and returns a drawable , which can be used as the floating action button ' s background ,
 * when it is activated .
 * @ return The drawable , which has been created , as an instance of the class { @ link Drawable } */
private Drawable createActivatedBackgroundDrawable ( ) { } }

implementation: Drawable drawable = createBackgroundDrawable ( getColor ( ) ) ; Drawable hoverDrawable = createBackgroundDrawable ( getActivatedColor ( ) ) ; return new LayerDrawable ( new Drawable [ ] { drawable , hoverDrawable } ) ;


signature:
public class FloatingActionButton { /** * Creates and returns a drawable , which can be used as the floating action button ' s background ,
 * when it is pressed .
 * @ return The drawable , which has been created , as an instance of the class { @ link Drawable } */
private Drawable createPressedBackgroundDrawable ( ) { } }

implementation: Drawable drawable = createBackgroundDrawable ( getColor ( ) ) ; Drawable hoverDrawable = createBackgroundDrawable ( getPressedColor ( ) ) ; return new LayerDrawable ( new Drawable [ ] { drawable , hoverDrawable } ) ;


signature:
public class FloatingActionButton { /** * Creates and returns a drawable , which can be used as the floating action button ' s background ,
 * when it is disabled .
 * @ return The drawable , which has been created , as an instance of the class { @ link Drawable } */
private Drawable createDisabledBackgroundDrawable ( ) { } }

implementation: Drawable drawable = createBackgroundDrawable ( getColor ( ) ) ; Drawable hoverDrawable = createBackgroundDrawable ( getDisabledColor ( ) ) ; return new LayerDrawable ( new Drawable [ ] { drawable , hoverDrawable } ) ;


signature:
public class FloatingActionButton { /** * Creates and returns a drawable with a specific color , which can be used as the floating
 * action button ' s background .
 * @ param color
 * The color of the background as an { @ link Integer } value
 * @ return The drawable , which has been created , as an instance of the class { @ link Drawable } */
private Drawable createBackgroundDrawable ( @ ColorInt final int color ) { } }

implementation: OvalShape shape = new OvalShape ( ) ; ShapeDrawable drawable = new ShapeDrawable ( shape ) ; drawable . getPaint ( ) . setColor ( color ) ; return drawable ;


signature:
public class FloatingActionButton { /** * Returns the size of the floating action button in pixels , depending on its current size .
 * @ return The size of the floating action button in pixels as an { @ link Integer } value */
private int getPixelSize ( ) { } }

implementation: if ( getSize ( ) == Size . NORMAL ) { return getResources ( ) . getDimensionPixelSize ( R . dimen . floating_action_button_size_normal ) ; } else if ( getSize ( ) == Size . SMALL ) { return getResources ( ) . getDimensionPixelSize ( R . dimen . floating_action_button_size_small ) ; } else { return getResources ( ) . getDimensionPixelSize ( R . dimen . floating_action_button_size_large ) ; }


signature:
public class FloatingActionButton { /** * Returns the color of the theme attribute < code > R . attr . colorControlHighlight < / code > .
 * @ return The color of the theme attribute < code > R . attr . colorControlHighlight < / code > as an
 * { @ link Integer } value */
private int getControlHighlightColor ( ) { } }

implementation: TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( new int [ ] { R . attr . colorControlHighlight } ) ; return typedArray . getColor ( 0 , 0 ) ;


signature:
public class FloatingActionButton { /** * Returns the color of the theme attribute < code > R . attr . colorControlActivated < / code > .
 * @ return The color of the theme attribute < code > R . attr . colorControlActivated < / code > as an
 * { @ link Integer } value */
private int getControlActivatedColor ( ) { } }

implementation: TypedArray typedArray = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( new int [ ] { R . attr . colorControlActivated } ) ; return typedArray . getColor ( 0 , 0 ) ;


signature:
public class FloatingActionButton { /** * Animates changing the visibility of the floating action button .
 * @ param visibility
 * The visibility , which should be set , as an { @ link Integer } value . The visibility may
 * be < code > View . VISIBLE < / code > , < code > View . INVISIBLE < / code > or < code > View . GONE < / code >
 * @ param duration
 * The duration of the animation in milliseconds as a { @ link Long } value */
private void animateVisibility ( final int visibility , final long duration ) { } }

implementation: if ( visibilityAnimator != null ) { visibilityAnimator . cancel ( ) ; } AnimatorListener listener = createVisibilityAnimatorListener ( visibility ) ; float targetScale = visibility == View . VISIBLE ? 1 : 0 ; long animationDuration = Math . round ( Math . abs ( getScaleX ( ) - targetScale ) * duration ) ; Interpolator interpolator = new AccelerateDecelerateInterpolator ( ) ; visibilityAnimator = animate ( ) . setInterpolator ( interpolator ) . scaleX ( targetScale ) . scaleY ( targetScale ) . setDuration ( animationDuration ) . setListener ( listener ) ;


signature:
public class FloatingActionButton { /** * Creates and returns a listener , which allows to adapt the visibility of the floating action
 * button , depending on the progress of an animation , which is used to change the visibility .
 * @ param visibility
 * The visibility , which is set by the observed animation , as an { @ link Integer } value .
 * The visibility may be < code > View . VISIBLE < / code > , < code > View . INVISIBLE < / code > or
 * < code > View . GONE < / code >
 * @ return The listener , which has been created , as an instance of the type { @ link
 * AnimatorListener } */
private AnimatorListener createVisibilityAnimatorListener ( final int visibility ) { } }

implementation: return new AnimatorListener ( ) { @ Override public void onAnimationStart ( final Animator animation ) { if ( visibility == View . VISIBLE ) { FloatingActionButton . super . setVisibility ( visibility ) ; } } @ Override public void onAnimationRepeat ( final Animator animation ) { } @ Override public void onAnimationEnd ( final Animator animation ) { FloatingActionButton . super . setVisibility ( visibility ) ; visibilityAnimator = null ; } @ Override public void onAnimationCancel ( final Animator animation ) { visibilityAnimator = null ; } } ;


signature:
public class FloatingActionButton { /** * Sets the floating action button ' s size .
 * @ param size
 * The size , which should be set , as a value of the enum { @ link Size } . The size must
 * either be < code > NORMAL < / code > or < code > SMALL < / code > */
public final void setSize ( @ NonNull final Size size ) { } }

implementation: Condition . INSTANCE . ensureNotNull ( size , "The size may not be null" ) ; this . size = size ; adaptShadow ( ) ; adaptImageButtonSize ( ) ; requestLayout ( ) ;


signature:
public class CircularProgressBar { /** * Obtains the view ' s attributes from a specific attribute set .
 * @ param attributeSet
 * The attribute set , the view ' s attributes should be obtained from , as an instance of
 * the type { @ link AttributeSet } or null , if no attributes should be obtained */
private void obtainStyledAttributes ( @ Nullable final AttributeSet attributeSet ) { } }

implementation: TypedArray typedArray = getContext ( ) . obtainStyledAttributes ( attributeSet , R . styleable . CircularProgressBar ) ; try { obtainColor ( typedArray ) ; obtainThickness ( typedArray ) ; } finally { typedArray . recycle ( ) ; }


signature:
public class CircularProgressBar { /** * Obtains the progress bar ' s thickness from a specific typed array .
 * @ param typedArray
 * The typed array , the thickness should be obtained from , as an instance of the class
 * { @ link TypedArray } . The typed array may not be null */
private void obtainThickness ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultThickness = getContext ( ) . getResources ( ) . getDimensionPixelSize ( R . dimen . circular_progress_bar_thickness_normal ) ; thickness = typedArray . getDimensionPixelSize ( R . styleable . CircularProgressBar_android_thickness , defaultThickness ) ;


signature:
public class CircularProgressDrawable { /** * Initializes the paint , which is used for drawing . */
private void initializePaint ( ) { } }

implementation: paint = new Paint ( ) ; paint . setAntiAlias ( true ) ; paint . setStyle ( Paint . Style . STROKE ) ; paint . setStrokeWidth ( getThickness ( ) ) ; paint . setColor ( getColor ( ) ) ;


signature:
public class CircularProgressDrawable { /** * Initializes the angle animator . */
private void initializeAngleAnimator ( ) { } }

implementation: angleAnimator = ObjectAnimator . ofFloat ( this , createAngleProperty ( ) , MAX_DEGREES ) ; angleAnimator . setInterpolator ( new LinearInterpolator ( ) ) ; angleAnimator . setDuration ( ANGLE_ANIMATION_DURATION ) ; angleAnimator . setRepeatMode ( ValueAnimator . RESTART ) ; angleAnimator . setRepeatCount ( ValueAnimator . INFINITE ) ;


signature:
public class CircularProgressDrawable { /** * Creates and returns a property , which allows to animate the global angle of the progress
 * drawable .
 * @ return The property , which has been created , as an instance of the class { @ link Property } */
private Property < CircularProgressDrawable , Float > createAngleProperty ( ) { } }

implementation: return new Property < CircularProgressDrawable , Float > ( Float . class , "angle" ) { @ Override public Float get ( final CircularProgressDrawable object ) { return currentGlobalAngle ; } @ Override public void set ( final CircularProgressDrawable object , final Float value ) { currentGlobalAngle = value ; invalidateSelf ( ) ; } } ;


signature:
public class CircularProgressDrawable { /** * Initializes the sweep animator . */
private void initializeSweepAnimator ( ) { } }

implementation: sweepAnimator = ObjectAnimator . ofFloat ( this , createSweepProperty ( ) , MAX_DEGREES - MIN_SWEEP_ANGLE * 2 ) ; sweepAnimator . setInterpolator ( new DecelerateInterpolator ( ) ) ; sweepAnimator . setDuration ( SWEEP_ANIMATION_DURATION ) ; sweepAnimator . setRepeatMode ( ValueAnimator . RESTART ) ; sweepAnimator . setRepeatCount ( ValueAnimator . INFINITE ) ; sweepAnimator . addListener ( createSweepAnimatorListener ( ) ) ;


signature:
public class CircularProgressDrawable { /** * Creates and returns a property , which allows to animate the sweep angle of the progress
 * drawable .
 * @ return The property , which has been created , as an instance of the class { @ link Property } */
private Property < CircularProgressDrawable , Float > createSweepProperty ( ) { } }

implementation: return new Property < CircularProgressDrawable , Float > ( Float . class , "arc" ) { @ Override public Float get ( final CircularProgressDrawable object ) { return currentSweepAngle ; } @ Override public void set ( final CircularProgressDrawable object , final Float value ) { currentSweepAngle = value ; invalidateSelf ( ) ; } } ;


signature:
public class CircularProgressDrawable { /** * Creates and returns a listener , which allows to restart the progress drawable ' s animation ,
 * when it has been finished .
 * @ return The listener , which has been created , as an instance of the type { @ link
 * AnimatorListener } */
private AnimatorListener createSweepAnimatorListener ( ) { } }

implementation: return new AnimatorListener ( ) { @ Override public void onAnimationStart ( final Animator animation ) { } @ Override public void onAnimationEnd ( final Animator animation ) { } @ Override public void onAnimationCancel ( final Animator animation ) { } @ Override public void onAnimationRepeat ( final Animator animation ) { appearing = ! appearing ; if ( appearing ) { currentGlobalAngleOffset = ( currentGlobalAngleOffset + MIN_SWEEP_ANGLE * 2 ) % MAX_DEGREES ; } } } ;


signature:
public class MainActivity { /** * Initializes the floating action buttons . */
private void initializeFloatingActionButtons ( ) { } }

implementation: smallFloatingActionButton = findViewById ( R . id . floating_action_button_small ) ; smallFloatingActionButton . setOnClickListener ( createFloatingActionButtonListener ( ) ) ; normalFloatingActionButton = findViewById ( R . id . floating_action_button_normal ) ; normalFloatingActionButton . setOnClickListener ( createFloatingActionButtonListener ( ) ) ; largeFloatingActionButton = findViewById ( R . id . floating_action_button_large ) ; largeFloatingActionButton . setOnClickListener ( createFloatingActionButtonListener ( ) ) ;


signature:
public class MainActivity { /** * Creates and returns a listener , which allows to show a toast when a floating action button
 * has been clicked .
 * @ return The listener , which has been created , as an instance of the type { @ link
 * OnClickListener } */
private OnClickListener createFloatingActionButtonListener ( ) { } }

implementation: return new OnClickListener ( ) { @ Override public void onClick ( final View v ) { Toast toast = Toast . makeText ( MainActivity . this , R . string . floating_action_button_toast , Toast . LENGTH_SHORT ) ; toast . show ( ) ; } } ;


signature:
public class MainActivity { /** * Initializes the button , which allows to show or hide the floating action buttons . */
private void initializeHideFloatingActionButtonsButton ( ) { } }

implementation: Button button = findViewById ( R . id . hide_floating_action_buttons ) ; button . setOnClickListener ( createHideFloatingActionButtonsListener ( ) ) ;


signature:
public class MainActivity { /** * Creates and returns a listener , which allows to show or hide the floating action buttons .
 * @ return The listener , which has been created , as an instance of the type { @ link
 * OnClickListener } */
private OnClickListener createHideFloatingActionButtonsListener ( ) { } }

implementation: return new OnClickListener ( ) { @ Override public void onClick ( final View v ) { int visibility = floatingActionButtonsVisible ? View . INVISIBLE : View . VISIBLE ; smallFloatingActionButton . setVisibility ( visibility , true ) ; normalFloatingActionButton . setVisibility ( visibility , true ) ; largeFloatingActionButton . setVisibility ( visibility , true ) ; floatingActionButtonsVisible = ! floatingActionButtonsVisible ; } } ;


signature:
public class MainActivity { /** * Initializes all closable chips . */
private void initializeChips ( ) { } }

implementation: Chip closableChipLight = findViewById ( R . id . chip_closable_light ) ; closableChipLight . addCloseListener ( createChipCloseListener ( ) ) ; Chip closableChipDark = findViewById ( R . id . chip_closable_dark ) ; closableChipDark . addCloseListener ( createChipCloseListener ( ) ) ; Chip closableIconChipLight = findViewById ( R . id . chip_icon_closable_light ) ; closableIconChipLight . addCloseListener ( createChipCloseListener ( ) ) ; Chip closableIconChipDark = findViewById ( R . id . chip_icon_closable_dark ) ; closableIconChipDark . addCloseListener ( createChipCloseListener ( ) ) ;


signature:
public class MainActivity { /** * Creates and returns a listener , which allows to show a toast , when a chip has been closed .
 * @ return The listener , which has been created , as an instance of the type { @ link
 * Chip . CloseListener } */
private Chip . CloseListener createChipCloseListener ( ) { } }

implementation: return new Chip . CloseListener ( ) { @ Override public void onChipClosed ( @ NonNull final Chip chip ) { chip . setVisibility ( View . GONE ) ; Toast . makeText ( MainActivity . this , R . string . chip_closed_toast , Toast . LENGTH_SHORT ) . show ( ) ; } } ;


signature:
public class MainActivity { /** * Adapts the activity ' s views depending on the saved instance state , which has been passed to
 * the activity .
 * @ param savedInstanceState
 * The saved instance state as an instance of the class { @ link Bundle } or null , if no
 * saved instance state is available */
private void handleSavedInstanceState ( @ Nullable final Bundle savedInstanceState ) { } }

implementation: if ( savedInstanceState != null ) { floatingActionButtonsVisible = savedInstanceState . getBoolean ( FLOATING_ACTION_BUTTONS_VISIBLE_EXTRA ) ; int visibility = floatingActionButtonsVisible ? View . VISIBLE : View . INVISIBLE ; smallFloatingActionButton . setVisibility ( visibility ) ; normalFloatingActionButton . setVisibility ( visibility ) ; largeFloatingActionButton . setVisibility ( visibility ) ; }


signature:
public class Chip { /** * Initializes the view .
 * @ param attributeSet
 * The attribute set , the view ' s attributes should be obtained from , as an instance of
 * the type { @ link AttributeSet } or null , if no attributes should be obtained */
private void initialize ( @ Nullable final AttributeSet attributeSet ) { } }

implementation: listeners = new ListenerList < > ( ) ; inflateLayout ( ) ; Drawable background = ContextCompat . getDrawable ( getContext ( ) , R . drawable . chip_background ) ; ViewUtil . setBackground ( this , background ) ; obtainStyledAttributes ( attributeSet ) ;


signature:
public class Chip { /** * Inflates the view ' s layout . */
private void inflateLayout ( ) { } }

implementation: View view = View . inflate ( getContext ( ) , R . layout . chip , null ) ; imageView = view . findViewById ( android . R . id . icon ) ; textView = view . findViewById ( android . R . id . text1 ) ; closeButton = view . findViewById ( android . R . id . closeButton ) ; closeButton . setOnClickListener ( createCloseButtonListener ( ) ) ; int height = getResources ( ) . getDimensionPixelSize ( R . dimen . chip_height ) ; addView ( view , LayoutParams . WRAP_CONTENT , height ) ;


signature:
public class Chip { /** * Obtains the view ' s attributes from a specific attribute set .
 * @ param attributeSet
 * The attribute set , the view ' s attributes should be obtained from , as an instance of
 * the type { @ link AttributeSet } or null , if no attributes should be obtained */
private void obtainStyledAttributes ( @ Nullable final AttributeSet attributeSet ) { } }

implementation: TypedArray typedArray = getContext ( ) . obtainStyledAttributes ( attributeSet , R . styleable . Chip ) ; try { obtainText ( typedArray ) ; obtainTextColor ( typedArray ) ; obtainColor ( typedArray ) ; obtainIcon ( typedArray ) ; obtainClosable ( typedArray ) ; obtainCloseIcon ( typedArray ) ; } finally { typedArray . recycle ( ) ; }


signature:
public class Chip { /** * Obtains the chip ' s text from a specific typed array .
 * @ param typedArray
 * The typed array , the text should be obtained from , as an instance of the class { @ link
 * TypedArray } . The typed array may not be null */
private void obtainText ( @ NonNull final TypedArray typedArray ) { } }

implementation: setText ( typedArray . getText ( R . styleable . Chip_android_text ) ) ;


signature:
public class Chip { /** * Obtains the chip ' s text color from a specific typed array .
 * @ param typedArray
 * The typed array , the text color should be obtained from , as an instance of the class
 * { @ link TypedArray } . The typed array may not be null */
private void obtainTextColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultColor = ContextCompat . getColor ( getContext ( ) , R . color . chip_text_color_light ) ; setTextColor ( typedArray . getColor ( R . styleable . Chip_android_textColor , defaultColor ) ) ;


signature:
public class Chip { /** * Obtains the chip ' s color from a specific typed array .
 * @ param typedArray
 * The typed array , the color should be obtained from , as an instance of the class
 * { @ link TypedArray } . The typed array may not be null */
private void obtainColor ( @ NonNull final TypedArray typedArray ) { } }

implementation: int defaultColor = ContextCompat . getColor ( getContext ( ) , R . color . chip_color_light ) ; setColor ( typedArray . getColor ( R . styleable . Chip_android_color , defaultColor ) ) ;


signature:
public class Chip { /** * Obtains the chip ' s icon from a specific typed array .
 * @ param typedArray
 * The typed array , the icon should be obtained from , as an instance of the class { @ link
 * TypedArray } . The typed array may not be null */
private void obtainIcon ( @ NonNull final TypedArray typedArray ) { } }

implementation: setIcon ( typedArray . getDrawable ( R . styleable . Chip_android_icon ) ) ;


signature:
public class Chip { /** * Obtains , whether the chip should be closable , or not , from a specific typed array .
 * @ param typedArray
 * The typed array , which should be used to obtain , whether the chip should be closable ,
 * or not , as an instance of the class { @ link TypedArray } . The typed array may not be
 * null */
private void obtainClosable ( @ NonNull final TypedArray typedArray ) { } }

implementation: setClosable ( typedArray . getBoolean ( R . styleable . Chip_closable , false ) ) ;


signature:
public class Chip { /** * Obtains the icon of the button , which allows to close the chip , from a specific typed array .
 * @ param typedArray
 * The typed array , which should be used to obtain the icon of the button , which allows
 * to close the chip , as an instance of the class { @ link TypedArray } . The typed array
 * may not be null */
private void obtainCloseIcon ( @ NonNull final TypedArray typedArray ) { } }

implementation: Drawable icon = typedArray . getDrawable ( R . styleable . Chip_closeButtonIcon ) ; if ( icon != null ) { setCloseButtonIcon ( icon ) ; }


signature:
public class Chip { /** * Adds a new listener , which should be notified , when the chip has been closed .
 * @ param listener
 * The listener , which should be added , as an instance of the type { @ link
 * CloseListener } . The listener may not be null */
public final void addCloseListener ( @ NonNull final CloseListener listener ) { } }

implementation: Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; listeners . add ( listener ) ;


signature:
public class Chip { /** * Removes a specific listener , which should not be notified , when the chip has been closed ,
 * anymore .
 * @ param listener
 * The listener , which should be removed , as an instance of the type { @ link
 * CloseListener } . The listener may not be null */
public final void removeCloseListener ( @ NonNull final CloseListener listener ) { } }

implementation: Condition . INSTANCE . ensureNotNull ( listener , "The listener may not be null" ) ; listeners . remove ( listener ) ;


signature:
public class Chip { /** * Sets the chip ' s color .
 * @ param color
 * The color , which should be set , as an { @ link Integer } value */
public final void setColor ( @ ColorInt final int color ) { } }

implementation: this . color = color ; getBackground ( ) . setColorFilter ( color , PorterDuff . Mode . SRC_IN ) ;


signature:
public class Chip { /** * Sets the chip ' s icon .
 * @ param icon
 * The icon , which should be set , as an instance of the class { @ link Drawable } or null ,
 * if no icon should be set */
public final void setIcon ( @ Nullable final Drawable icon ) { } }

implementation: setIcon ( icon != null ? drawableToBitmap ( icon ) : null ) ;


signature:
public class Chip { /** * Sets the chip ' s icon .
 * @ param icon
 * The icon , which should be set , as an instance of the class { @ link Bitmap } or null , if
 * no icon should be set */
public final void setIcon ( @ Nullable final Bitmap icon ) { } }

implementation: if ( icon != null ) { int size = getResources ( ) . getDimensionPixelSize ( R . dimen . chip_height ) ; imageView . setImageBitmap ( clipCircle ( icon , size ) ) ; imageView . setVisibility ( View . VISIBLE ) ; textView . setPadding ( 0 , textView . getPaddingTop ( ) , textView . getPaddingRight ( ) , textView . getPaddingBottom ( ) ) ; } else { imageView . setImageBitmap ( null ) ; imageView . setVisibility ( View . GONE ) ; textView . setPadding ( getResources ( ) . getDimensionPixelSize ( R . dimen . chip_horizontal_padding ) , textView . getPaddingTop ( ) , textView . getPaddingRight ( ) , textView . getPaddingBottom ( ) ) ; }


signature:
public class Chip { /** * Sets , whether the chip is closable , or not .
 * @ param closable
 * True , if the chip should be closable , false otherwise */
public final void setClosable ( final boolean closable ) { } }

implementation: this . closable = closable ; if ( closable ) { closeButton . setVisibility ( View . VISIBLE ) ; textView . setPadding ( textView . getPaddingLeft ( ) , textView . getPaddingTop ( ) , 0 , textView . getPaddingBottom ( ) ) ; } else { closeButton . setVisibility ( View . GONE ) ; textView . setPadding ( textView . getPaddingLeft ( ) , textView . getPaddingTop ( ) , getResources ( ) . getDimensionPixelSize ( R . dimen . chip_horizontal_padding ) , textView . getPaddingBottom ( ) ) ; }


signature:
public class Chip { /** * Sets the icon of the button , which allows to close the chip .
 * @ param icon
 * The icon , which should be set , as an instance of the class { @ link Drawable } . The icon
 * may not be null */
public final void setCloseButtonIcon ( @ NonNull final Drawable icon ) { } }

implementation: Condition . INSTANCE . ensureNotNull ( icon , "The icon may not be null" ) ; closeButton . setImageDrawable ( icon ) ;


signature:
public class Chip { /** * Sets the icon of the button , which allows to close the chip .
 * @ param icon
 * The icon , which should be set , as an instance of the class { @ link Bitmap } . The icon
 * may not be null */
public final void setCloseButtonIcon ( @ NonNull final Bitmap icon ) { } }

implementation: Condition . INSTANCE . ensureNotNull ( icon , "The icon may not be null" ) ; closeButton . setImageBitmap ( icon ) ;


signature:
public class ModelAndMustacheView { /** * Get current partials stored in view .
 * @ return Current partials . */
@ SuppressWarnings ( "unchecked" ) public Map < String , String > getPartials ( ) { } }

implementation: final View view = this . getView ( ) ; if ( view != null && view instanceof MustacheView ) { MustacheView mustacheView = ( MustacheView ) view ; return mustacheView . getAliases ( ) ; } else { final Object object = getModelMap ( ) . get ( MustacheSettings . PARTIALS_KEY ) ; if ( object != null && ! ( object instanceof Map ) ) { throw new MustachePartialsMappingException ( ) ; } final Map < String , String > map ; if ( object == null ) { map = new HashMap < String , String > ( ) ; } else { map = ( Map < String , String > ) object ; } return map ; }


signature:
public class ModelAndMustacheView { /** * Add new partials mapping to the view .
 * @ param key Partial name .
 * @ param name Partial path . */
public void addPartial ( final String key , final String name ) { } }

implementation:
notNull ( key ) ; notNull ( name ) ; View view = this . getView ( ) ; if ( view != null && view instanceof MustacheView ) { // First try to not pollute view model object
final MustacheView mustacheView = ( MustacheView ) view ; mustacheView . addAlias ( key , name ) ; } else { // Otherwise , add partials to model object
final Map < String , String > currentPartials = getPartials ( ) ; currentPartials . put ( key , name ) ; super . addObject ( MustacheSettings . PARTIALS_KEY , currentPartials ) ; }


signature:
public class ModelAndMustacheView { /** * Add new partials mapping to the view .
 * @ param partials Partials . */
public void addPartials ( final Map < String , String > partials ) { } }

implementation:
notNull ( partials ) ; View view = this . getView ( ) ; if ( view != null && view instanceof MustacheView ) { // First try to not pollute model object
final MustacheView mustacheView = ( MustacheView ) view ; mustacheView . addAliases ( partials ) ; } else { // Otherwise , add partials to model object
final Map < String , String > currentPartials = getPartials ( ) ; for ( Map . Entry < String , String > entry : partials . entrySet ( ) ) { notNull ( entry . getKey ( ) ) ; notNull ( entry . getValue ( ) ) ; currentPartials . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } super . addObject ( MustacheSettings . PARTIALS_KEY , currentPartials ) ; }


signature:
public class PreConditions { /** * Check that a given object is not null .
 * If object is null , a { @ link java . lang . NullPointerException } is thrown
 * with given message .
 * If object is not null , it is automatically returns .
 * @ param object Object to check .
 * @ param message Exception message .
 * @ param < T > Object Generic Type .
 * @ return Non null object .
 * @ throws java . lang . NullPointerException if object is null . */
public static < T > T notNull ( T object , String message ) { } }

implementation: if ( object == null ) { throw new NullPointerException ( message ) ; } return object ;


signature:
public class PreConditions { /** * Check if a collection is not null and not empty .
 * If collection is null or empty , an { @ link java . lang . IllegalArgumentException } is thrown .
 * If collection is not null and not empty , it will be automatically returned .
 * @ param array Collection to check .
 * @ param message Exception message .
 * @ param < T > Type of array elements .
 * @ return Original collection . */
public static < T > Collection < T > notEmpty ( Collection < T > array , String message ) { } }

implementation: if ( array == null || array . size ( ) == 0 ) { throw new IllegalArgumentException ( message ) ; } return array ;


signature:
public class PreConditions { /** * Check that a given string value is not blank ( i . e . not null ,
 * not empty and does not contain only whitespaces ) .
 * If value is blank , an { @ link java . lang . IllegalArgumentException } is
 * thrown .
 * If value is not blank , original string value is automatically returned .
 * @ param value String value .
 * @ param message Error message given to exception .
 * @ return Original string value .
 * @ throws java . lang . IllegalArgumentException if value is blank . */
public static String hasText ( String value , String message ) { } }

implementation:
if ( value == null ) { throw new IllegalArgumentException ( message ) ; } for ( char c : value . toCharArray ( ) ) { if ( ! Character . isWhitespace ( c ) ) { return value ; } } // Found only whitespace characters . . .
throw new IllegalArgumentException ( message ) ;


signature:
public class NashornUtils { /** * Get new nashorn engine .
 * @ param scripts List of scripts to evaluate .
 * @ return Nashorn Engine . */
public static ScriptEngine getEngine ( Collection < InputStream > scripts ) { } }

implementation: ScriptEngine engine = getEngine ( ) ; for ( InputStream script : scripts ) { evaluate ( engine , script ) ; } return engine ;


signature:
public class MustacheWebConfiguration { /** * Build mustache view resolver .
 * This view resolver needs an instance of { @ link com . github . mjeanroy . springmvc . view . mustache . MustacheCompiler }
 * to be created .
 * @ return Mustache view resolver instance . */
@ Bean public MustacheViewResolver mustacheViewResolver ( ) { } }

implementation: String prefix = getPrefix ( ) ; String suffix = getSuffix ( ) ; int order = getOrder ( ) ; boolean cache = getCache ( ) ; String [ ] viewNames = getViewNames ( ) ; String defaultLayout = getDefaultLayout ( ) ; String layoutKey = getLayoutKey ( ) ; Map < String , String > mappings = getLayoutMappings ( ) ; log . info ( "Create mustache view resolver" ) ; log . trace ( "  => Cache: {}" , cache ) ; log . trace ( "  => Prefix: {}" , prefix ) ; log . trace ( "  => Suffix: {}" , suffix ) ; log . trace ( "  => Order: {}" , order ) ; log . trace ( "  => View Names: {}" , viewNames ) ; log . trace ( "  => Default layout: {}" , defaultLayout ) ; log . trace ( "  => Layout key: {}" , layoutKey ) ; log . trace ( "  => Mappings: {}" , mappings ) ; MustacheViewResolver resolver = new MustacheViewResolver ( mustacheCompiler ) ; resolver . setCache ( cache ) ; resolver . setPrefix ( prefix ) ; resolver . setSuffix ( suffix ) ; resolver . setOrder ( order ) ; resolver . setViewNames ( viewNames ) ; resolver . setLayoutKey ( layoutKey ) ; if ( defaultLayout != null && ! defaultLayout . isEmpty ( ) ) { resolver . setDefaultLayout ( defaultLayout ) ; } if ( ! mappings . isEmpty ( ) ) { resolver . setLayoutMappings ( mappings ) ; } return resolver ;


signature:
public class MustacheWebConfiguration { /** * Resolve view names matchers of mustache view resolver .
 * Default is to look for " mustache . viewNames " property or use { @ link MustacheSettings # VIEW _ NAMES } if
 * property cannot be resolved .
 * @ return View names patterns . */
public String [ ] getViewNames ( ) { } }

implementation: String viewNames = environment . getProperty ( "mustache.viewNames" , valueOf ( MustacheSettings . VIEW_NAMES ) ) . trim ( ) ; String [ ] names = viewNames . split ( "," ) ; for ( int i = 0 ; i < names . length ; i ++ ) { names [ i ] = names [ i ] . trim ( ) ; } return names ;


signature:
public class MustacheWebConfiguration { /** * Get mappings to use with resolvers .
 * @ return Layouts mappings */
public Map < String , String > getLayoutMappings ( ) { } }

implementation: String mappingsValues = environment . getProperty ( "mustache.layoutMappings" , MustacheSettings . LAYOUT_MAPPINGS ) . trim ( ) ; if ( mappingsValues . isEmpty ( ) ) { return emptyMap ( ) ; } Map < String , String > mappings = new HashMap < String , String > ( ) ; String [ ] values = mappingsValues . split ( ";" ) ; if ( values . length > 0 ) { for ( String value : values ) { String val = value == null ? "" : value . trim ( ) ; if ( val . isEmpty ( ) ) { continue ; } String [ ] mapping = val . split ( ":" ) ; if ( mapping . length != 2 ) { throw new IllegalArgumentException ( "Mapping must use [viewName]:[layout] format!" ) ; } mappings . put ( mapping [ 0 ] . trim ( ) , mapping [ 1 ] . trim ( ) ) ; } } return unmodifiableMap ( mappings ) ;


signature:
public class JMustacheConfiguration { /** * Build mustache compiler .
 * This compiler use an instance of { @ link com . samskivert . mustache . Mustache . Compiler }
 * under the hood .
 * @ param compiler JMustache compiler .
 * @ param templateLoader Template loader .
 * @ return Mustache compiler implementation . */
@ Bean public MustacheCompiler mustacheCompiler ( Mustache . Compiler compiler , MustacheTemplateLoader templateLoader ) { } }

implementation: log . info ( "Create JMustache compiler" ) ; return new JMustacheCompiler ( compiler , templateLoader ) ;


signature:
public class JMustacheConfiguration { /** * Build original jmustache { @ link Compiler } that will be used
 * internally to compile and render templates .
 * @ return JMustache compiler . */
@ Bean public JMustacheCompilerFactoryBean jMustacheCompiler ( ) { } }

implementation: JMustacheCompilerFactoryBean factoryBean = new JMustacheCompilerFactoryBean ( ) ; factoryBean . setNullValue ( "" ) ; factoryBean . setDefaultValue ( "" ) ; factoryBean . setEmptyStringIsFalse ( true ) ; factoryBean . setZeroIsFalse ( true ) ; factoryBean . setEscapeHTML ( true ) ; return factoryBean ;


signature:
public class ClassUtils { /** * Check that a given class is available on
 * classpath .
 * @ param klass Class name .
 * @ return True if class is available , false otherwise . */
public static boolean isPresent ( String klass ) { } }

implementation: hasText ( klass , "Class name must not be empty" ) ; try { Class . forName ( klass ) ; return true ; } catch ( Exception ex ) { return false ; }


signature:
public class ClassUtils { /** * Get annotation method value .
 * @ param importingClassMetadata Metadata .
 * @ param annotationClass Annotation class to look for .
 * @ param name Name of method .
 * @ param defaultValue Default value if original value is null .
 * @ param < T > Type of returned value .
 * @ return Annotation value , or default value if original value is null . */
@ SuppressWarnings ( "unchecked" ) public static < T > T getAnnotationValue ( AnnotationMetadata importingClassMetadata , Class annotationClass , String name , T defaultValue ) { } }

implementation: Map < String , Object > attributes = importingClassMetadata . getAnnotationAttributes ( annotationClass . getName ( ) ) ; return attributes != null && attributes . containsKey ( name ) ? ( T ) attributes . get ( name ) : defaultValue ;


signature:
public class IOUtils { /** * Read input reader : extract content and return it as
 * a String .
 * @ param reader Reader input .
 * @ return String content .
 * @ throws MustacheIOException If an IO exception occurs during reading operation . */
public static String read ( final Reader reader ) { } }

implementation:
final BufferedReader buffer = new BufferedReader ( reader , BUFFER_SIZE ) ; try { StringBuilder sb = new StringBuilder ( ) ; String line ; boolean started = false ; // Read line by line
while ( ( line = buffer . readLine ( ) ) != null ) { if ( started ) { sb . append ( LINE_SEPARATOR ) ; } sb . append ( line ) ; started = true ; } return sb . toString ( ) ; } catch ( IOException ex ) { throw new MustacheIOException ( ex ) ; } finally { closeQuietly ( buffer ) ; }


signature:
public class IOUtils { /** * Return an input stream from given name .
 * Name is searched into the classpath .
 * Name can contains ant style pattern .
 * @ param name Name .
 * @ return Input Stream . */
public static InputStream getStream ( String name ) { } }

implementation:
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver ( IOUtils . class . getClassLoader ( ) ) ; InputStream stream = getInputStreamWithResolver ( resolver , name ) ; // Not Found
if ( stream == null ) { throw new MustacheIOException ( "Unable to locate {}" + name ) ; } return stream ;


signature:
public class IOUtils { /** * Return an input stream from given names .
 * First result returning a valid stream is returned .
 * Names are searched into the classpath .
 * Names can contains ant style pattern .
 * @ param names Names collection .
 * @ return Input Stream .
 * @ throws MustacheIOException If everything fail . */
public static InputStream getFirstAvailableStream ( Collection < String > names ) { } }

implementation:
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver ( IOUtils . class . getClassLoader ( ) ) ; for ( String name : names ) { try { InputStream stream = getInputStreamWithResolver ( resolver , name ) ; if ( stream != null ) { return stream ; } } catch ( MustacheIOException ex ) { // Go to the next test
} } throw new MustacheIOException ( "Unable to locate one of: " + names ) ;


signature:
public class IOUtils { /** * Close a { @ link java . io . Closeable } object and do not throws a Checked Exception
 * if an exception occurs .
 * @ param stream Closeable stream . */
private static void closeQuietly ( Closeable stream ) { } }

implementation:
try { stream . close ( ) ; } catch ( IOException ex ) { // Just log .
log . debug ( ex . getMessage ( ) , ex ) ; }


signature:
public class HandlebarsConfiguration { /** * Build mustache compiler .
 * This compiler use an instance of { @ link com . github . jknack . handlebars . Handlebars }
 * under the hood .
 * @ param handlebars Handlebars instance .
 * @ param templateLoader Template loader .
 * @ return Mustache compiler implementation . */
@ Bean public MustacheCompiler mustacheCompiler ( Handlebars handlebars , MustacheTemplateLoader templateLoader ) { } }

implementation: log . info ( "Create handlebar compiler" ) ; return new HandlebarsCompiler ( handlebars , templateLoader ) ;


signature:
public class MustacheViewResolver { /** * Replace current layout mappings by new mappings .
 * @ param layoutMappings New mappings . */
public void setLayoutMappings ( Map < String , String > layoutMappings ) { } }

implementation: notNull ( layoutMappings , "Layout mappings must not be null" ) ; log . debug ( "Set view resolver layout mappings" ) ; this . layoutMappings . clear ( ) ; for ( Map . Entry < String , String > entry : layoutMappings . entrySet ( ) ) { addLayoutMapping ( entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class MustacheViewResolver { /** * Replace current layout mappings by new mappings .
 * @ param viewName View name to map .
 * @ param layoutName Layout name to use for given view . */
public void addLayoutMapping ( String viewName , String layoutName ) { } }

implementation: log . debug ( "Add new layout mapping" ) ; log . trace ( "  => {} -> {}" , viewName , layoutName ) ; notNull ( viewName , "View name must not be null" ) ; notNull ( layoutName , "Layout name must not be null" ) ; this . layoutMappings . put ( viewName , layoutName ) ;


signature:
public class MustacheEngine { /** * Render template with given model object .
 * @ param template Template .
 * @ param model Model object .
 * @ return Rendered template . */
public String render ( String template , Map < String , Object > model ) { } }

implementation: try { Invocable invocable = ( Invocable ) engine ; return ( String ) invocable . invokeFunction ( "render" , template , model , partials ) ; } catch ( ScriptException ex ) { throw new NashornException ( ex ) ; } catch ( NoSuchMethodException ex ) { throw new NashornException ( ex ) ; }


signature:
public class MustacheView { /** * Add partials mapping .
 * @ param aliases New aliases . */
public void addAliases ( Map < String , String > aliases ) { } }

implementation: notNull ( aliases , "Aliases must not be null" ) ; for ( Map . Entry < String , String > entry : aliases . entrySet ( ) ) { addAlias ( entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class MustacheView { /** * Add alias mapping .
 * @ param key Partial key .
 * @ param value Partial name . */
public void addAlias ( String key , String value ) { } }

implementation: this . aliases . put ( notNull ( key , "Key must not be null" ) , notNull ( value , "Value must not be null" ) ) ;


signature:
public class ChronosListenerManager { /** * Creates a new ServiceConnector instance . Do not call this method twice for a same object ,
 * instead use { @ link # getListener ( int ) } method .
 * @ return a created ServiceConnector */
@ NonNull public final synchronized ChronosListener createListener ( ) { } }

implementation: final int connectorId = mNextConnectorId . getAndIncrement ( ) ; final ChronosListener result = new ChronosListener ( connectorId ) ; mListeners . put ( connectorId , result ) ; return result ;


signature:
public class ChronosListenerManager { /** * Gets previously created ServiceConnector by its id .
 * @ param id an id of the saved ServiceConnector
 * @ return a restored ServiceConnector , or a new one , if there is no saved instance with a given
 * id
 * @ see { @ link ChronosListener # getId ( ) }
 * @ see # createListener ( ) */
@ NonNull public final synchronized ChronosListener getListener ( final int id ) { } }

implementation: ChronosListener chronosListener = mListeners . get ( id ) ; if ( chronosListener == null ) { chronosListener = new ChronosListener ( id ) ; mListeners . put ( id , chronosListener ) ; } return chronosListener ;


signature:
public class Chronos { /** * Runs operation synchronously .
 * @ param operation Operation to be executed .
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method
 * @ return OperationResult which contains the result of the Operation , or the error , occurred
 * during the execution */
@ NonNull public static < Output > ChronosOperationResult < Output > run ( @ NonNull final ChronosOperation < Output > operation ) { } }

implementation: return ChronosService . getInstance ( ) . runSync ( operation , false ) ;


signature:
public class Chronos { /** * Runs operation synchronously . The result will be broadcasted to all objects , connected to
 * Chronos via { @ link ChronosListener } .
 * @ param operation Operation to be executed .
 * @ param < Output > class of the result , returned by the Operations ' { @ code run } method
 * @ return OperationResult which contains the result of the Operation , or the error , occurred
 * during the execution */
@ NonNull public static < Output > ChronosOperationResult < Output > runBroadcast ( @ NonNull final ChronosOperation < Output > operation ) { } }

implementation: return ChronosService . getInstance ( ) . runSync ( operation , true ) ;


signature:
public class ChronosListener { /** * Checks if a method can be used as a callback to handle operation result .
 * @ param method a method to be checked
 * @ param resultClass an operation result class
 * @ param methodName a required method name
 * @ return { @ code true } if method can be used as a callback ; { @ code false } otherwise */
@ Contract ( pure = true ) private static boolean isCallback ( @ NonNull final Method method , @ NonNull final Class < ? > resultClass , @ NonNull final String methodName ) { } }

implementation: if ( method . getName ( ) . equals ( methodName ) ) { if ( method . getReturnType ( ) == Void . TYPE ) { final Class < ? > [ ] parameters = method . getParameterTypes ( ) ; if ( parameters . length == 1 && parameters [ 0 ] . isAssignableFrom ( resultClass ) ) { return true ; } } } return false ;


signature:
public class ChronosListener { /** * This method must be called by a bound GUI element when it passes its own onResume state .
 * @ param serviceListener a GUI element that wants to connect to Chronos via the
 * ServiceConnector . In fact , it could be any object , no matter it is an
 * Activity , Fragment , or something else , but Chronos is designed to work
 * with GUI elements .
 * @ see # onPause ( ) */
public final void onResume ( @ NonNull final Object serviceListener ) { } }

implementation: logd ( "onResume" ) ; mServiceListener = serviceListener ; mState = State . RESUMED ; if ( ! mStoredResults . isEmpty ( ) ) { logd ( "has undelivered results" ) ; final List < SoftReference < OperationDelivery < ? > > > oldResults = new ArrayList < > ( mStoredResults ) ; mStoredResults . clear ( ) ; for ( SoftReference < OperationDelivery < ? > > result : oldResults ) { final OperationDelivery < ? > delivery = result . get ( ) ; if ( delivery != null ) { deliverResult ( delivery ) ; } } logd ( "no more undelivered results" ) ; } else { logd ( "has no undelivered results" ) ; }


signature:
public class ChronosListener { /** * This method is used to listening to results stream and operate with them . User should never
 * call this method manually .
 * @ param operationResult the result to process */
@ SuppressWarnings ( "unused" ) public final void onEventMainThread ( @ Nullable final ChronosOperationResult < ? > operationResult ) { } }

implementation:
if ( operationResult == null ) { // somehow the bus delivered us a null object , it should be ignored
return ; } final int operationId = operationResult . getId ( ) ; DeliveryMode deliveryMode = null ; if ( ! RunningOperationStorage . getInstance ( ) . isOperationCancelled ( operationId ) ) { if ( mTaggedRequests . containsValue ( operationId ) ) { deliveryMode = DeliveryMode . NORMAL ; } else if ( mUntaggedRequests . contains ( operationResult . getId ( ) ) ) { mUntaggedRequests . remove ( Integer . valueOf ( operationId ) ) ; deliveryMode = DeliveryMode . NORMAL ; } else if ( operationResult . isBroadcast ( ) ) { deliveryMode = DeliveryMode . BROADCAST ; } } if ( deliveryMode != null ) { final OperationDelivery < ? > operationDelivery = new OperationDelivery < > ( operationResult , deliveryMode ) ; logd ( "operation delivery: " + operationDelivery ) ; onOperationFinished ( operationDelivery ) ; }


signature:
public class ChronosListener { /** * Launches an operation in background thread .
 * @ param operation an operation to be launched
 * @ param broadcastResult { @ code true } if the result should be broadcasted , { @ code false }
 * otherwise
 * @ return a unique launch id
 * @ see # invoke ( ChronosOperation , String , boolean )
 * @ see # cancel ( int , boolean ) */
public final int invoke ( @ NonNull final ChronosOperation < ? > operation , final boolean broadcastResult ) { } }

implementation: logd ( "invoking untagged operation" ) ; final int id = ChronosService . getInstance ( ) . runAsync ( operation , broadcastResult ) ; mUntaggedRequests . add ( id ) ; return id ;


signature:
public class ChronosListener { /** * Launches an operation in background thread . If operation , launched with the same tag from the
 * same ServiceConnector is running , new operation launch will not be triggered .
 * @ param operation an operation to be launched
 * @ param tag a pre - cache key of the launch
 * @ param broadcastResult { @ code true } if the result should be broadcasted , { @ code false }
 * otherwise
 * @ return a launch id , may be the same with the previous call of the method , if the operation
 * with the same tag is still running
 * @ see # invoke ( ChronosOperation , boolean )
 * @ see # cancel ( int , boolean )
 * @ see # cancel ( String , boolean ) */
public final int invoke ( @ NonNull final ChronosOperation < ? > operation , @ NonNull final String tag , final boolean broadcastResult ) { } }

implementation: logd ( "invoking tagged operation, tag=" + tag ) ; final Integer savedId = mTaggedRequests . get ( tag ) ; if ( savedId != null && isRunning ( savedId ) ) { logd ( "operation with tag=" + tag + " is running, do nothing" ) ; return savedId ; } logd ( "operation with tag=" + tag + " is not running, start it" ) ; final int id = ChronosService . getInstance ( ) . runAsync ( operation , broadcastResult ) ; mTaggedRequests . put ( tag , id ) ; return id ;


signature:
public class ChronosListener { /** * Cancels operation launch by its id . May not physically kill the background thread , but it is
 * guaranteed that the result of the operation will not be delivered to any ServiceConnector .
 * @ param id an id of the operation launch that should be cancelled
 * @ param mayInterrupt { @ code true } if threads executing operations task should be interrupted ;
 * otherwise , in - progress tasks are allowed to complete
 * @ return { @ code false } if the task could not be cancelled , typically because it has already
 * completed normally ; { @ code true } otherwise
 * @ see # invoke ( ChronosOperation , boolean )
 * @ see # invoke ( ChronosOperation , String , boolean )
 * @ see # cancel ( String , boolean )
 * @ see Chronos # cancelAll ( boolean ) */
public final boolean cancel ( final int id , final boolean mayInterrupt ) { } }

implementation:
// noinspection SimplifiableIfStatement
if ( mUntaggedRequests . contains ( id ) || mTaggedRequests . containsValue ( id ) ) { return RunningOperationStorage . getInstance ( ) . cancel ( id , mayInterrupt ) ; } else { return false ; }


signature:
public class ChronosListener { /** * Cancels operation launch by its tag . May not physically kill the background thread , but it is
 * guaranteed that the result of the operation will not be delivered to any ServiceConnector .
 * @ param tag a pre - cache key of the operation launch that should be cancelled
 * @ param mayInterrupt { @ code true } if threads executing operations task should be interrupted ;
 * otherwise , in - progress tasks are allowed to complete
 * @ return { @ code false } if the task could not be cancelled , typically because it has already
 * completed normally or there is no running operation with a given tag ; { @ code true } otherwise
 * @ see # invoke ( ChronosOperation , boolean )
 * @ see # invoke ( ChronosOperation , String , boolean )
 * @ see # cancel ( int , boolean )
 * @ see Chronos # cancelAll ( boolean ) */
public final boolean cancel ( @ NonNull final String tag , final boolean mayInterrupt ) { } }

implementation:
final Integer id = mTaggedRequests . get ( tag ) ; // noinspection SimplifiableIfStatement
if ( id != null ) { return cancel ( id , mayInterrupt ) ; } else { return false ; }


signature:
public class ChronosListener { /** * Checks if an operation with given launch tag is running .
 * @ param tag a pre - cache key of the operation launch
 * @ return { @ code true } if the operation is running , { @ code false } if it is not running , or
 * there was no operation launch with the tag at all */
@ Contract ( pure = true ) public final boolean isRunning ( @ NonNull final String tag ) { } }

implementation:
final Integer id = mTaggedRequests . get ( tag ) ; // noinspection SimplifiableIfStatement
if ( id != null ) { return isRunning ( id ) ; } else { return false ; }


signature:
public class ChronosListener { /** * A dispatcher method which decides what to do with an operation result .
 * @ param operationResult an operation result which needs to be dispatched */
private void onOperationFinished ( @ NonNull final OperationDelivery < ? > operationResult ) { } }

implementation: logd ( "onOperationFinished " + operationResult ) ; switch ( mState ) { case PAUSED : storeResult ( operationResult ) ; break ; case RESUMED : deliverResult ( operationResult ) ; break ; default : throw new IllegalStateException ( "Unknown state: " + mState ) ; }


signature:
public class ChronosListener { /** * Storing an operation result to use it later .
 * @ param operationDelivery an operation result to be stored
 * @ see # deliverResult ( OperationDelivery ) */
private void storeResult ( @ NonNull final OperationDelivery < ? > operationDelivery ) { } }

implementation: logd ( "store delivery " + operationDelivery ) ; mStoredResults . add ( new SoftReference < OperationDelivery < ? > > ( operationDelivery ) ) ;


signature:
public class ChronosListener { /** * Delivers an operation result to the bound client .
 * @ param operationDelivery an operation result to be delivered
 * @ see # onResume ( Object )
 * @ see # storeResult ( OperationDelivery ) */
private void deliverResult ( @ NonNull final OperationDelivery < ? > operationDelivery ) { } }

implementation: logd ( "deliver delivery " + operationDelivery ) ; switch ( operationDelivery . getDeliveryMode ( ) ) { case NORMAL : deliverResult ( operationDelivery . getResult ( ) , Chronos . OWN_CALLBACK_METHOD_NAME , true ) ; break ; case BROADCAST : deliverResult ( operationDelivery . getResult ( ) , Chronos . BROADCAST_CALLBACK_METHOD_NAME , false ) ; break ; default : break ; }


signature:
public class ChronosListener { /** * Call bound client methods to pass an operation result .
 * @ param operationResult an operation result to be delivered
 * @ param methodName a name of a method that will be called
 * @ param warnIfNoCallback { @ code true } if a warning message should be posted to LogCat if there
 * is no suitable method in the bound client ; { @ code false } otherwise */
@ SuppressWarnings ( "TryWithIdenticalCatches" ) private void deliverResult ( @ NonNull final ChronosOperationResult < ? > operationResult , @ NonNull final String methodName , final boolean warnIfNoCallback ) { } }

implementation: final Class listenerClass = mServiceListener . getClass ( ) ; final Method [ ] listenerMethods = listenerClass . getMethods ( ) ; Method callbackMethod = null ; final Class resultClass = operationResult . getClass ( ) ; for ( Method method : listenerMethods ) { if ( isCallback ( method , resultClass , methodName ) ) { callbackMethod = method ; try { callbackMethod . invoke ( mServiceListener , operationResult ) ; } catch ( IllegalAccessException e ) { Log . w ( LOG_TAG , Log . getStackTraceString ( e ) ) ; } catch ( InvocationTargetException e ) { Log . w ( LOG_TAG , Log . getStackTraceString ( e ) ) ; } } } if ( warnIfNoCallback && callbackMethod == null ) { Log . w ( LOG_TAG , "Operation result (id=" + operationResult . getId ( ) + "; class=" + operationResult . getClass ( ) . getName ( ) + ") was obtained, but there is no method in " + mServiceListener + " to get it" ) ; Log . w ( LOG_TAG , "Method should look like" ) ; Log . w ( LOG_TAG , "public void " + methodName + "(" + resultClass . getName ( ) + " result) {}" ) ; }


signature:
public class ChronosListener { /** * Logs debug message .
 * @ param message сообщение для вывода в лог .
 * @ see # LOG _ ENABLED */
private void logd ( @ NonNull final String message ) { } }

implementation: if ( LOG_ENABLED ) { Log . d ( LOG_TAG , this . toString ( ) + " " + message ) ; }


signature:
public class RunningOperationStorage { /** * Cancels running operation .
 * @ param id the unique id of operations ' launch
 * @ param mayInterrupt { @ code true } if thread executing operation task should be interrupted ;
 * otherwise , in - progress tasks are allowed to complete
 * @ param removeOperation { @ code true } if the operation should be marked as removed
 * @ return { @ code false } if the task could not be cancelled , typically because it has already
 * completed normally ; { @ code true } otherwise */
private synchronized boolean cancel ( final int id , final boolean mayInterrupt , final boolean removeOperation ) { } }

implementation: final RunningOperation runningOperation = mRunningOperations . get ( id ) ; if ( runningOperation != null ) { if ( removeOperation ) { mRunningOperations . remove ( id ) ; } mCancelledOperations . add ( id ) ; return runningOperation . cancel ( mayInterrupt ) ; } else { return false ; }


signature:
public class RunningOperationStorage { /** * Stores the future as a running operation with a given runs ' id .
 * @ param id the unique id of an operation launch
 * @ param future the object that represents a running operation */
synchronized final void operationStarted ( final int id , @ NonNull final ChronosOperation < ? > operation , @ NonNull final Future < ? > future ) { } }

implementation: mRunningOperations . put ( id , new RunningOperation ( operation , future ) ) ;


signature:
public class RunningOperationStorage { /** * Cancels all running operations .
 * @ param mayInterrupt { @ code true } if threads executing operations task should be interrupted ;
 * otherwise , in - progress tasks are allowed to complete */
synchronized final void cancelAll ( final boolean mayInterrupt ) { } }

implementation: for ( final Integer key : mRunningOperations . keySet ( ) ) { cancel ( key , mayInterrupt , false ) ; } mRunningOperations . clear ( ) ;


signature:
public class RunningOperationStorage { /** * Checks if operation launch with given id was cancelled .
 * @ param id the unique id of operations ' launch
 * @ return { @ code true } if the operation was cancelled , { @ code false } otherwise */
@ Contract ( pure = true ) synchronized final boolean isOperationCancelled ( final int id ) { } }

implementation: return mCancelledOperations . contains ( Integer . valueOf ( id ) ) ;