signature:
public class SetAPI { /** * Gets a list of { @ link MtgSet } based on the provided filters in the
 * < a href = " https : / / docs . magicthegathering . io / # sets " > web API documentation . < / a >
 * @ param filters List of string filters
 * @ return The list of { @ link MtgSet } s that was found by the filter . */
public static List < MtgSet > getAllSets ( List < String > filters ) { } }

implementation: return getList ( RESOURCE_PATH , "sets" , MtgSet . class , filters ) ;


signature:
public class SetAPI { /** * Gets a list of { @ link MtgSet } with all the card objects populated .
 * Performance will be degraded because of all the Api calls that will
 * happen .
 * @ return A list of all the sets with cards populated . */
public static List < MtgSet > getAllSetsWithCards ( ) { } }

implementation: List < MtgSet > returnList = getList ( RESOURCE_PATH , "sets" , MtgSet . class ) ; for ( MtgSet set : returnList ) { set . setCards ( CardAPI . getAllCards ( new LinkedList < > ( Collections . singletonList ( "set=" + set . getCode ( ) ) ) ) ) ; } return returnList ;


signature:
public class ExtentCucumberFormatter { /** * When running cucumber tests in parallel Klov reporter should be attached only once , in order to avoid duplicate builds on klov server . */
private static synchronized void setKlovReport ( ) { } }

implementation:
if ( extentReports == null ) { // Extent reports object not found . call setExtentReport ( ) first
return ; } ExtentProperties extentProperties = ExtentProperties . INSTANCE ; // if reporter is not null that means it is already attached
if ( klovReporter != null ) { // Already attached , attaching it again will create a new build / klov report
return ; } if ( extentProperties . getKlovServerUrl ( ) != null ) { String hostname = extentProperties . getMongodbHost ( ) ; int port = extentProperties . getMongodbPort ( ) ; String database = extentProperties . getMongodbDatabase ( ) ; String username = extentProperties . getMongodbUsername ( ) ; String password = extentProperties . getMongodbPassword ( ) ; try { // Create a new KlovReporter object
klovReporter = new KlovReporter ( ) ; if ( username != null && password != null ) { MongoClientURI uri = new MongoClientURI ( "mongodb://" + username + ":" + password + "@" + hostname + ":" + port + "/?authSource=" + database ) ; klovReporter . initMongoDbConnection ( uri ) ; } else { klovReporter . initMongoDbConnection ( hostname , port ) ; } klovReporter . setProjectName ( extentProperties . getKlovProjectName ( ) ) ; klovReporter . setReportName ( extentProperties . getKlovReportName ( ) ) ; klovReporter . setKlovUrl ( extentProperties . getKlovServerUrl ( ) ) ; extentReports . attachReporter ( klovReporter ) ; } catch ( Exception ex ) { klovReporter = null ; throw new IllegalArgumentException ( "Error setting up Klov Reporter" , ex ) ; } }


signature:
public class Reporter { /** * Adds the screenshot from the given path with the given title to the current step
 * @ param imagePath The image path
 * @ param title The title for the image
 * @ throws IOException Exception if imagePath is erroneous */
public static void addScreenCaptureFromPath ( String imagePath , String title ) throws IOException { } }

implementation: getCurrentStep ( ) . addScreenCaptureFromPath ( imagePath , title ) ;


signature:
public class Reporter { /** * Sets the system information with the given key value pair
 * @ param key The name of the key
 * @ param value The value of the given key */
public static void setSystemInfo ( String key , String value ) { } }

implementation: if ( systemInfoKeyMap . isEmpty ( ) || ! systemInfoKeyMap . containsKey ( key ) ) { systemInfoKeyMap . put ( key , false ) ; } if ( systemInfoKeyMap . get ( key ) ) { return ; } getExtentReport ( ) . setSystemInfo ( key , value ) ; systemInfoKeyMap . put ( key , true ) ;


signature:
public class Syslog4jAppender { /** * Convert a level to equivalent syslog severity . Only levels for printing
 * methods i . e DEBUG , WARN , INFO and ERROR are converted .
 * @ see ch . qos . logback . core . net . SyslogAppenderBase # getSeverityForEvent ( java . lang . Object ) */
public int getSeverityForEvent ( Object eventObject ) { } }

implementation: if ( eventObject instanceof ILoggingEvent ) { ILoggingEvent event = ( ILoggingEvent ) eventObject ; return LevelToSyslogSeverity . convert ( event ) ; } else { return SyslogIF . LEVEL_INFO ; }


signature:
public class FloatList { /** * Creates a primitive list based on an input list and a property path
 * @ param inputList input list
 * @ param propertyPath property path
 * @ return primitive list */
public static FloatList toFloatList ( Collection < ? > inputList , String propertyPath ) { } }

implementation: if ( inputList . size ( ) == 0 ) { return new FloatList ( 0 ) ; } FloatList outputList = new FloatList ( inputList . size ( ) ) ; if ( propertyPath . contains ( "." ) || propertyPath . contains ( "[" ) ) { String [ ] properties = StringScanner . splitByDelimiters ( propertyPath , ".[]" ) ; for ( Object o : inputList ) { outputList . add ( BeanUtils . getPropertyFloat ( o , properties ) ) ; } } else { Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( inputList . iterator ( ) . next ( ) ) ; FieldAccess fieldAccess = fields . get ( propertyPath ) ; for ( Object o : inputList ) { outputList . add ( fieldAccess . getFloat ( o ) ) ; } } return outputList ;


signature:
public class FloatList { /** * Add a new value to the list but don ' t employ a wrapper .
 * @ param integer new value
 * @ return was able to add . */
public FloatList add ( float integer ) { } }

implementation: if ( end + 1 >= values . length ) { values = grow ( values ) ; } values [ end ] = integer ; end ++ ; return this ;


signature:
public class FloatList { /** * Set a value in the list .
 * @ param index index
 * @ param element new value
 * @ return old value at this index */
@ Override public Float set ( int index , Float element ) { } }

implementation: float oldValue = values [ index ] ; values [ index ] = element ; return oldValue ;


signature:
public class FloatList { /** * Set a value in the list .
 * @ param index index
 * @ param element new value
 * @ return old value at this index */
public float idx ( int index , float element ) { } }


signature:
public class FloatList { /** * Set a value in the list .
 * @ param index index
 * @ param element new value
 * @ return old value at this index */
public float atIndex ( int index , float element ) { } }


signature:
public class FloatList { /** * Set in a new value no wrapper
 * @ param index index
 * @ param element new value
 * @ return old value at this index */
public float setFloat ( int index , float element ) { } }


signature:
public class FloatList { /** * This would be a good opportunity to reintroduce dynamic invoke
 * @ param function function
 * @ return */
public double reduceBy ( Object function , String name ) { } }

implementation: return Flt . reduceBy ( values , end , function , name ) ;


signature:
public class Selector { /** * Performs collections from the results .
 * @ param selectors list of selectors
 * @ param results results we are selecting from
 * @ return map of selected items per row */
public static void collectFrom ( List < Selector > selectors , Collection < ? > results ) { } }

implementation: if ( results . size ( ) == 0 ) { return ; } Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( results . iterator ( ) . next ( ) ) ; collectFrom ( selectors , results , fields ) ;


signature:
public class Selector { /** * Performs collections from the results .
 * @ param selectors list of selectors
 * @ param results results we are selecting from
 * @ param fields fields
 * @ return map of selected items per row */
public static void collectFrom ( List < Selector > selectors , Collection < ? > results , Map < String , FieldAccess > fields ) { } }

implementation: for ( Selector s : selectors ) { s . handleStart ( results ) ; } int index = 0 ; for ( Object item : results ) { for ( Selector s : selectors ) { s . handleRow ( index , null , item , fields ) ; } index ++ ; } for ( Selector s : selectors ) { s . handleComplete ( null ) ; }


signature:
public class Selector { /** * Performs the actual selection from the results .
 * @ param selectors list of selectors
 * @ param results results we are selecting from
 * @ param < ITEM > List of items
 * @ return map of selected items per row */
public static < ITEM > List < Map < String , Object > > selectFrom ( List < Selector > selectors , Collection < ITEM > results ) { } }

implementation: if ( results . size ( ) == 0 ) { return Collections . EMPTY_LIST ; } Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( results . iterator ( ) . next ( ) ) ; return selectFrom ( selectors , results , fields ) ;


signature:
public class Selector { /** * Performs the actual selection from the results .
 * @ param selectors list of selectors
 * @ param results results we are selecting from
 * @ param fields fields
 * @ param < ITEM > List of items
 * @ return map of selected items per row */
public static < ITEM > List < Map < String , Object > > selectFrom ( List < Selector > selectors , Collection < ITEM > results , Map < String , FieldAccess > fields ) { } }

implementation: List < Map < String , Object > > rows = new ArrayList < > ( results . size ( ) ) ; for ( Selector s : selectors ) { s . handleStart ( results ) ; } int index = 0 ; for ( ITEM item : results ) { Map < String , Object > row = new LinkedHashMap < > ( ) ; for ( Selector s : selectors ) { s . handleRow ( index , row , item , fields ) ; } index ++ ; rows . add ( row ) ; } for ( Selector s : selectors ) { s . handleComplete ( rows ) ; } return rows ;


signature:
public class Selector { /** * Allows you to select a property or property path .
 * @ param propName name of property or property path
 * @ return returns a Selector */
public static Selector select ( final String propName ) { } }

implementation: return new Selector ( propName , propName ) { @ Override public void handleRow ( int index , Map < String , Object > row , Object item , Map < String , FieldAccess > fields ) { getPropertyValueAndPutIntoRow ( row , item , fields ) ; } @ Override public void handleStart ( Collection < ? > results ) { } @ Override public void handleComplete ( List < Map < String , Object > > rows ) { } } ;


signature:
public class Selector { /** * Selects but allows having a different alias for the output .
 * @ param propName name of property or property path to select
 * @ param alias name that the value will be selected as .
 * @ param transform Function that allows you to convert from an object into another object
 * @ return selector */
public static Selector selectAs ( final String propName , final String alias , final Function transform ) { } }

implementation: return new Selector ( propName , alias ) { @ Override public void handleRow ( int index , Map < String , Object > row , Object item , Map < String , FieldAccess > fields ) { if ( ! path && fields != null ) { row . put ( this . name , transform . apply ( fields . get ( this . name ) . getValue ( item ) ) ) ; } else { row . put ( alias , transform . apply ( BeanUtils . atIndex ( item , propName ) ) ) ; } } @ Override public void handleStart ( Collection < ? > results ) { } @ Override public void handleComplete ( List < Map < String , Object > > rows ) { } } ;


signature:
public class Selector { /** * Selects but allows having a different alias for the output .
 * \ * @ param alias name that the value will be selected as .
 * @ param transform Function that allows you to convert from an object into another object
 * @ return selector */
public static Selector selectAsTemplate ( final String alias , final String template , final Template transform ) { } }

implementation: return new Selector ( alias , alias ) { @ Override public void handleRow ( int index , Map < String , Object > row , Object item , Map < String , FieldAccess > fields ) { if ( ! path && fields != null ) { row . put ( this . name , transform . replace ( template , item ) ) ; } else { row . put ( alias , transform . replace ( template , item ) ) ; } } @ Override public void handleStart ( Collection < ? > results ) { } @ Override public void handleComplete ( List < Map < String , Object > > rows ) { } } ;


signature:
public class MySQLDataStore { /** * Will flush to secondary storage if needed . This is used mostly by REMOTE _ DB at the moment . */
protected void flushReadsIfNeeded ( ) throws InterruptedException { } }

implementation:
long now = timer . time ( ) ; /* Every 250 ms flush the read queue . */
if ( now - lastReadFlushTime > flushQueueInterval && readList . size ( ) > 0 ) { if ( ! loadQueue . offer ( new ArrayList < > ( readList ) ) ) { logger . warn ( "MySQL LOAD QUEUE IS FULL" , loadQueue . size ( ) ) ; } else { readList . clear ( ) ; } lastReadFlushTime = now ; }


signature:
public class MySQLDataStore { /** * Will flush to secondary storage if needed . This is used mostly by REMOTE _ DB at the moment . */
protected void flushWritesIfNeeded ( ) throws InterruptedException { } }

implementation:
long now = timer . time ( ) ; /* Every 30 seconds flush the write queue . */
if ( now - lastWriteFlushTime > dataStoreConfig . dbWriteFlushQueueIntervalMS ( ) ) { if ( outputMap . size ( ) > 0 ) { if ( ! writeQueue . offer ( new LinkedHashMap ( outputMap ) ) ) { logger . warn ( "MySQL STORE QUEUE IS FULL" , writeQueue . size ( ) ) ; } else { outputMap . clear ( ) ; } lastWriteFlushTime = now ; } if ( removeList . size ( ) > 0 ) { if ( ! writeQueue . offer ( new ArrayList < > ( removeList ) ) ) { logger . warn ( "MySQL LOAD QUEUE IS FULL" , writeQueue . size ( ) ) ; } else { removeList . clear ( ) ; } } }


signature:
public class Annotations { /** * Create an annotation data list .
 * @ param annotations list of annotation .
 * @ return */
public static List < AnnotationData > extractValidationAnnotationData ( Annotation [ ] annotations , Set < String > allowedPackages ) { } }

implementation: List < AnnotationData > annotationsList = new ArrayList < > ( ) ; for ( Annotation annotation : annotations ) { AnnotationData annotationData = new AnnotationData ( annotation , allowedPackages ) ; if ( annotationData . isAllowed ( ) ) { annotationsList . add ( annotationData ) ; } } return annotationsList ;


signature:
public class Annotations { /** * Extract all annotation for a given property .
 * Searches current class and if none found searches
 * super class for annotation . We do this because the class
 * could be proxied with AOP .
 * @ param clazz Class containing the property .
 * @ param propertyName The name of the property .
 * @ return */
private static Annotation [ ] extractAllAnnotationsForProperty ( Class < ? > clazz , String propertyName , boolean useRead ) { } }

implementation:
try { Annotation [ ] annotations = findPropertyAnnotations ( clazz , propertyName , useRead ) ; /* In the land of dynamic proxied AOP classes ,
 * this class could be a proxy . This seems like a bug
 * waiting to happen . So far it has worked . . . */
if ( annotations . length == 0 ) { annotations = findPropertyAnnotations ( clazz . getSuperclass ( ) , propertyName , useRead ) ; } return annotations ; } catch ( Exception ex ) { return Exceptions . handle ( Annotation [ ] . class , sputs ( "Unable to extract annotation for property" , propertyName , " of class " , clazz , "  useRead " , useRead ) , ex ) ; }


signature:
public class Annotations { /** * Find annotation given a particular property name and clazz . This figures
 * out the writeMethod for the property , and uses the write method
 * to look up the annotation .
 * @ param clazz The class that holds the property .
 * @ param propertyName The name of the property .
 * @ return
 * @ throws java . beans . IntrospectionException */
private static Annotation [ ] findPropertyAnnotations ( Class < ? > clazz , String propertyName , boolean useRead ) throws IntrospectionException { } }

implementation: PropertyDescriptor propertyDescriptor = getPropertyDescriptor ( clazz , propertyName ) ; if ( propertyDescriptor == null ) { return new Annotation [ ] { } ; } Method accessMethod = null ; if ( useRead ) { accessMethod = propertyDescriptor . getReadMethod ( ) ; } else { accessMethod = propertyDescriptor . getWriteMethod ( ) ; } if ( accessMethod != null ) { Annotation [ ] annotations = accessMethod . getAnnotations ( ) ; return annotations ; } else { return new Annotation [ ] { } ; }


signature:
public class Annotations { /** * This needs to be refactored and put into Reflection or something . */
private static PropertyDescriptor doGetPropertyDescriptor ( final Class < ? > type , final String propertyName ) { } }

implementation: try { BeanInfo beanInfo = Introspector . getBeanInfo ( type ) ; PropertyDescriptor [ ] propertyDescriptors = beanInfo . getPropertyDescriptors ( ) ; for ( PropertyDescriptor pd : propertyDescriptors ) { if ( pd . getName ( ) . equals ( propertyName ) ) { return pd ; } } Class < ? > superclass = type . getSuperclass ( ) ; if ( superclass != null ) { return doGetPropertyDescriptor ( superclass , propertyName ) ; } return null ; } catch ( Exception ex ) { throw new RuntimeException ( "Unable to get property " + propertyName + " for class " + type , ex ) ; }


signature:
public class Sys { /** * / * Everything that has a cache you need to hold on to , should use this so they can
 * all be stuffed into application context of web - app or ear if you use Java EE . */
public static Object contextToHold ( ) { } }

implementation: return Lists . list ( Reflection . contextToHold ( ) , Annotations . contextToHold ( ) , Logging . contextToHold ( ) ) ;


signature:
public class BoonExpressionContext { /** * Lookup an object and supply a default value .
 * @ param objectExpression
 * @ param defaultValue
 * @ return */
private Object doLookup ( String objectExpression , Object defaultValue , boolean searchChildren ) { } }

implementation: if ( Str . isEmpty ( objectExpression ) ) { return defaultValue ; } char firstChar = Str . idx ( objectExpression , 0 ) ; char secondChar = Str . idx ( objectExpression , 1 ) ; char lastChar = Str . idx ( objectExpression , - 1 ) ; boolean escape = false ; switch ( firstChar ) { case '$' : if ( lastChar == '}' ) { objectExpression = slc ( objectExpression , 2 , - 1 ) ; } else { objectExpression = slc ( objectExpression , 1 ) ; } break ; case '{' : if ( secondChar == '{' && lastChar == '}' ) { char thirdChar = Str . idx ( objectExpression , 2 ) ; if ( thirdChar == '{' ) { escape = true ; objectExpression = slc ( objectExpression , 3 , - 3 ) ; } else { objectExpression = slc ( objectExpression , 2 , - 2 ) ; } } else { if ( lastChar == '}' ) { return jsonParser . parse ( objectExpression ) ; } else { escape = true ; objectExpression = slc ( objectExpression , 1 ) ; } } break ; case '[' : return jsonParser . parse ( objectExpression ) ; case '.' : if ( secondChar == '.' ) { String newExp = slc ( objectExpression , 2 ) ; return parent . doLookup ( newExp , newExp , false ) ; } } Object value ; lastChar = Str . idx ( objectExpression , - 1 ) ; if ( lastChar == ')' ) { value = handleFunction ( objectExpression , searchChildren ) ; } else { value = findProperty ( objectExpression , searchChildren ) ; value = value == null ? defaultValue : value ; } if ( ! escape ) { return value ; } else { return StandardFunctions . escapeXml ( value ) ; }


signature:
public class MasterDataStore { /** * THIS IS THE DELEGATE FOR SETTING DATA . For instance
 * set ( SetRequest request ) and setSource ( SetRequest request )
 * will both call this method instead of processing the set themself ,
 * therefore providing a common and consistent way to handle the set - SFF */
protected void _set ( DataStoreSource source , SetRequest request ) { } }

implementation: switch ( source ) { case MEMORY : _setMemory ( request ) ; break ; case LOCAL_DB : _setLocal ( request , true ) ; break ; case REMOTE_DB : _setRemote ( request , true ) ; break ; case TRANSACTION_LOG : _setTransactionLog ( request ) ; break ; case LOCAL_STORES : _setMemory ( request ) ; _setLocal ( request , true ) ; break ; case ALL : _setTransactionLog ( request ) ; _setReplication ( request ) ; _setMemory ( request ) ; _setLocal ( request , false ) ; _setRemote ( request , false ) ; break ; case REPLICATION : _setMemory ( request ) ; _setLocal ( request , false ) ; _setRemote ( request , false ) ; break ; default : queueInvalidSource ( request ) ; logger . error ( "Master Data Store:: Unable to handle Set Source" , request ) ; }


signature:
public class MapObjectConversion { /** * Convert an item from a list into a class using the classes constructor .
 * REFACTOR : Can ' t this just be from collection ?
 * REFACTOR
 * @ param argList list if arguments
 * @ param clazz the type of the object we are creating
 * @ param < T > generics
 * @ return the new object that we just created . */
public static < T > T fromList ( List < ? > argList , Class < T > clazz ) { } }

implementation: return mapper . fromList ( argList , clazz ) ;


signature:
public class MapObjectConversion { /** * Convert an item from a list into a class using the classes constructor .
 * REFACTOR : Can ' t this just be from collection ?
 * REFACTOR
 * @ param respectIgnore honor @ JsonIgnore , transients , etc . of the field
 * @ param view honor views for fields
 * @ param fieldsAccessor how we are going to access the fields ( by field , by property , combination )
 * @ param argList list if arguments
 * @ param clazz the type of the object we are creating
 * @ param ignoreSet a set of properties to ignore
 * @ param < T > generics
 * @ return the new object that we just created . */
public static < T > T fromList ( boolean respectIgnore , String view , FieldsAccessor fieldsAccessor , List < ? > argList , Class < T > clazz , Set < String > ignoreSet ) { } }

implementation: return new MapperComplex ( fieldsAccessor , ignoreSet , view , respectIgnore ) . fromList ( argList , clazz ) ;


signature:
public class MapObjectConversion { /** * Convert an item from a list into a class using the classes constructor .
 * REFACTOR : Can ' t this just be from collection ?
 * REFACTOR
 * @ param fieldsAccessor how we are going to access the fields ( by field , by property , combination )
 * @ param argList list if arguments
 * @ param clazz the type of the object we are creating
 * @ param < T > generics
 * @ return the new object that we just created . */
public static < T > T fromList ( FieldsAccessor fieldsAccessor , List < ? > argList , Class < T > clazz ) { } }

implementation: return new MapperComplex ( fieldsAccessor , null , null , false ) . fromList ( argList , clazz ) ;


signature:
public class MapObjectConversion { /** * From map .
 * @ param map map to create the object from .
 * @ param clazz the new instance type
 * @ param < T > generic type capture
 * @ return new object */
@ SuppressWarnings ( "unchecked" ) public static < T > T fromMap ( Map < String , Object > map , Class < T > clazz ) { } }

implementation: return mapper . fromMap ( map , clazz ) ;


signature:
public class MapObjectConversion { /** * fromMap converts a map into a java object .
 * @ param map map to create the object from .
 * @ param clazz the new instance type
 * @ param excludeProperties the properties to exclude
 * @ param < T > generic type capture
 * @ return the new object */
@ SuppressWarnings ( "unchecked" ) public static < T > T fromMap ( Map < String , Object > map , Class < T > clazz , String ... excludeProperties ) { } }

implementation: Set < String > ignoreProps = excludeProperties . length > 0 ? Sets . set ( excludeProperties ) : null ; return new MapperComplex ( FieldAccessMode . FIELD_THEN_PROPERTY . create ( false ) , ignoreProps , null , true ) . fromMap ( map , clazz ) ;


signature:
public class MapObjectConversion { /** * fromMap converts a map into a java object
 * @ param respectIgnore honor @ JsonIgnore , transients , etc . of the field
 * @ param view the view of the object which can ignore certain fields given certain views
 * @ param fieldsAccessor how we are going to access the fields ( by field , by property , combination )
 * @ param map map to create the object from .
 * @ param cls class type of new object
 * @ param ignoreSet a set of properties to ignore
 * @ param < T > map to create teh object from .
 * @ return new object of type cls < T > */
@ SuppressWarnings ( "unchecked" ) public static < T > T fromMap ( boolean respectIgnore , String view , FieldsAccessor fieldsAccessor , Map < String , Object > map , Class < T > cls , Set < String > ignoreSet ) { } }

implementation: Mapper mapper = new MapperComplex ( ignoreSet , view , respectIgnore ) ; return mapper . fromMap ( map , cls ) ;


signature:
public class MapObjectConversion { /** * Creates an object from a value map .
 * This does some special handling to take advantage of us using the value map so it avoids creating
 * a bunch of array objects and collections . Things you have to worry about when writing a
 * high - speed JSON serializer .
 * @ param respectIgnore honor @ JsonIgnore , transients , etc . of the field
 * @ param view the view of the object which can ignore certain fields given certain views
 * @ param fieldsAccessor how we are going to access the fields ( by field , by property , combination )
 * @ param cls the new type
 * @ param ignoreSet a set of properties to ignore
 * @ return new object from value map */
@ SuppressWarnings ( "unchecked" ) public static < T > T fromValueMap ( boolean respectIgnore , String view , final FieldsAccessor fieldsAccessor , final Map < String , Value > valueMap , final Class < T > cls , Set < String > ignoreSet ) { } }

implementation: Mapper mapper = new MapperComplex ( fieldsAccessor , ignoreSet , view , respectIgnore ) ; return mapper . fromValueMap ( valueMap , cls ) ;


signature:
public class MapObjectConversion { /** * Basic toMap to create an object into a map .
 * @ param object the object we want to convert to a list
 * @ param ignore do we honor ignore properties
 * @ return new map */
public static Map < String , Object > toMap ( final Object object , final String ... ignore ) { } }

implementation: return toMap ( object , Sets . set ( ignore ) ) ;


signature:
public class MapObjectConversion { /** * This could be refactored to use core . TypeType class and it would run faster .
 * Converts an object into a map
 * @ param object the object that we want to convert
 * @ param ignore the map
 * @ return map map representation of the object */
public static Map < String , Object > toMap ( final Object object , Set < String > ignore ) { } }

implementation: return new MapperComplex ( ignore ) . toMap ( object ) ;


signature:
public class MapObjectConversion { /** * This converts a list of maps to objects .
 * I always forget that this exists . I need to remember .
 * @ param respectIgnore honor @ JsonIgnore , transients , etc . of the field
 * @ param view the view of the object which can ignore certain fields given certain views
 * @ param fieldsAccessor how we are going to access the fields ( by field , by property , combination )
 * @ param componentType The component type of the created list
 * @ param list the input list
 * @ param ignoreProperties properties to ignore
 * @ param < T > generics
 * @ return a new list */
public static < T > List < T > convertListOfMapsToObjects ( boolean respectIgnore , String view , FieldsAccessor fieldsAccessor , Class < T > componentType , List < Map > list , Set < String > ignoreProperties ) { } }

implementation: return new MapperComplex ( fieldsAccessor , ignoreProperties , view , respectIgnore ) . convertListOfMapsToObjects ( list , componentType ) ;


signature:
public class MapObjectConversion { /** * Creates a list of maps from a list of class instances .
 * @ param collection the collection we are coercing into a field value
 * @ return the return value . */
public static List < Map < String , Object > > toListOfMaps ( Collection < ? > collection ) { } }

implementation: return mapper . toListOfMaps ( collection ) ;


signature:
public class AnnotationData { /** * Get the values from the annotation .
 * We use reflection to turn the annotation into a simple HashMap
 * of values .
 * @ return */
Map < String , Object > doGetValues ( Annotation annotation ) { } }

implementation:
/* Holds the value map . */
Map < String , Object > values = new HashMap < String , Object > ( ) ; /* Get the declared staticMethodMap from the actual annotation . */
Method [ ] methods = annotation . annotationType ( ) . getDeclaredMethods ( ) ; final Object [ ] noargs = ( Object [ ] ) null ; /* Iterate through declared staticMethodMap and extract values
 * by invoking decalared staticMethodMap if they are no arg staticMethodMap . */
for ( Method method : methods ) { /* If it is a no arg method assume it is an annoation value . */
if ( method . getParameterTypes ( ) . length == 0 ) { try { /* Get the value . */
Object value = method . invoke ( annotation , noargs ) ; if ( value instanceof Enum ) { Enum enumVal = ( Enum ) value ; value = enumVal . name ( ) ; } values . put ( method . getName ( ) , value ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } } } return values ;


signature:
public class RecursiveDescentPropertyValidator { /** * Create the validator by looking it up in the ObjectRegistry and then
 * populating it with values from the meta - data list .
 * @ param validationMetaDataList Holds metadataInformation about validation .
 * @ return composite validator with all of the validators for this property present . */
protected CompositeValidator createValidator ( List < ValidatorMetaData > validationMetaDataList ) { } }

implementation:
/* * A field ( property ) can be associated with many validators so we use a
 * CompositeValidator to hold all of the validators associated with this
 * validator . */
CompositeValidator compositeValidator = new CompositeValidator ( ) ; // hold
// all
// of
// the
// validators
// associated
// with
// the
// field .
/* * Lookup the list of validators for the current field and initialize
 * them with validation meta - data properties . */
List < FieldValidator > validatorsList = lookupTheListOfValidatorsAndInitializeThemWithMetaDataProperties ( validationMetaDataList ) ; compositeValidator . setValidatorList ( validatorsList ) ; return compositeValidator ;


signature:
public class RecursiveDescentPropertyValidator { /** * Lookup the list of validators for the current field and initialize them
 * with validation meta - data properties .
 * @ param validationMetaDataList list of validation meta - data
 * @ return list of field validators . */
private List < FieldValidator > lookupTheListOfValidatorsAndInitializeThemWithMetaDataProperties ( List < ValidatorMetaData > validationMetaDataList ) { } }

implementation:
List < FieldValidator > validatorsList = new ArrayList < > ( ) ; /* * Look up the crank validators and then apply the properties from the
 * validationMetaData to them . */
for ( ValidatorMetaData validationMetaData : validationMetaDataList ) { /* Look up the FieldValidator . */
FieldValidator validator = lookupValidatorInRegistry ( validationMetaData . getName ( ) ) ; /* * Apply the properties from the validationMetaData to the
 * validator . */
applyValidationMetaDataPropertiesToValidator ( validationMetaData , validator ) ; validatorsList . add ( validator ) ; } return validatorsList ;


signature:
public class RecursiveDescentPropertyValidator { /** * This method looks up the validator in the registry .
 * @ param validationMetaDataName The name of the validator that we are looking up .
 * @ return field validator */
private FieldValidator lookupValidatorInRegistry ( String validationMetaDataName ) { } }

implementation: Map < String , Object > applicationContext = ValidationContext . get ( ) . getObjectRegistry ( ) ; Exceptions . requireNonNull ( applicationContext ) ; return ( FieldValidator ) applicationContext . get ( "/org/boon/validator/" + validationMetaDataName ) ;


signature:
public class RecursiveDescentPropertyValidator { /** * This method applies the properties from the validationMetaData to the
 * validator uses Spring ' s BeanWrapperImpl .
 * @ param metaData validation meta data
 * @ param validator field validator */
private void applyValidationMetaDataPropertiesToValidator ( ValidatorMetaData metaData , FieldValidator validator ) { } }

implementation: Map < String , Object > properties = metaData . getProperties ( ) ; ifPropertyBlankRemove ( properties , "detailMessage" ) ; ifPropertyBlankRemove ( properties , "summaryMessage" ) ; BeanUtils . copyProperties ( validator , properties ) ;


signature:
public class RecursiveDescentPropertyValidator { /** * Removes a property if it is null or an empty string .
 * This allows the property to have a null or emtpy string in the
 * meta - data but we don ' t copy it to the validator if the property
 * is not set .
 * @ param properties properties
 * @ param property property */
private void ifPropertyBlankRemove ( Map < String , Object > properties , String property ) { } }

implementation: Object object = properties . get ( property ) ; if ( object == null ) { properties . remove ( property ) ; } else if ( object instanceof String ) { String string = ( String ) object ; if ( "" . equals ( string . trim ( ) ) ) { properties . remove ( property ) ; } }


signature:
public class Classpaths { /** * Load the listFromClassLoader
 * @ param loader
 * @ param resource
 * @ return */
public static List < String > listFromClassLoader ( ClassLoader loader , String resource ) { } }

implementation:
final List < URL > resourceURLs = Classpaths . classpathResources ( loader , resource ) ; final List < String > resourcePaths = Lists . list ( String . class ) ; final Map < URI , FileSystem > pathToZipFileSystems = new HashMap < > ( ) ; // So you don ' t have to keep loading the same jar / zip file .
for ( URL resourceURL : resourceURLs ) { if ( resourceURL . getProtocol ( ) . equals ( "jar" ) ) { resourcesFromJar ( resourcePaths , resourceURL , pathToZipFileSystems ) ; } else { resourcesFromFileSystem ( resourcePaths , resourceURL ) ; } } return resourcePaths ;


signature:
public class Classpaths { /** * Load the listFromClassLoader
 * @ param loader
 * @ param resource
 * @ return */
public static List < Path > pathsFromClassLoader ( ClassLoader loader , String resource ) { } }

implementation:
final List < URL > resourceURLs = Classpaths . classpathResources ( loader , resource ) ; final List < Path > resourcePaths = Lists . list ( Path . class ) ; final Map < URI , FileSystem > pathToZipFileSystems = new HashMap < > ( ) ; // So you don ' t have to keep loading the same jar / zip file .
for ( URL resourceURL : resourceURLs ) { if ( resourceURL . getProtocol ( ) . equals ( "jar" ) ) { pathsFromJar ( resourcePaths , resourceURL , pathToZipFileSystems ) ; } else { pathsFromFileSystem ( resourcePaths , resourceURL ) ; } } return resourcePaths ;


signature:
public class AsyncFileWriterDataStore { /** * Calculate utc time . This gets called every 20 mili - seconds or so . */
@ Override public void tick ( long time ) { } }

implementation:
this . time . set ( time ) ; /* Foreign thread every 20 or so mili - seconds so we don ' t spend too
 much time figuring out utc time . */
approxTime . set ( Dates . utcNow ( ) ) ;


signature:
public class SimpleConcurrentCache { /** * Get the size of the cache .
 * This is not 100 % accurate if cache is being concurrenly accessed . */
@ Override public int size ( ) { } }

implementation: int size = 0 ; for ( SimpleCache < K , V > cache : cacheRegions ) { size += cache . size ( ) ; } return size ;


signature:
public class SimpleConcurrentCache { /** * Calculate the hash .
 * @ param k key
 * @ return */
private final int hash ( Object k ) { } }


signature:
public class LevelDBKeyValueStore { /** * Configures default options .
 * @ return */
private Options defaultOptions ( ) { } }

implementation:
Options options = new Options ( ) ; options . createIfMissing ( true ) ; options . blockSize ( 32_768 ) ; // 32K
options . cacheSize ( 67_108_864 ) ; // 64MB
return options ;


signature:
public class LevelDBKeyValueStore { /** * Opens the database
 * @ param file filename to open
 * @ param options options
 * @ return */
private boolean openDB ( File file , Options options ) { } }

implementation: try { database = JniDBFactory . factory . open ( file , options ) ; logger . info ( "Using JNI Level DB" ) ; return true ; } catch ( IOException ex1 ) { try { database = Iq80DBFactory . factory . open ( file , options ) ; logger . info ( "Using Java Level DB" ) ; return false ; } catch ( IOException ex2 ) { return Exceptions . handle ( Boolean . class , ex2 ) ; } }


signature:
public class LevelDBKeyValueStore { /** * Puts values into the key value store in batch mode
 * @ param values values */
@ Override public void putAll ( Map < byte [ ] , byte [ ] > values ) { } }

implementation: WriteBatch batch = database . createWriteBatch ( ) ; try { for ( Map . Entry < byte [ ] , byte [ ] > entry : values . entrySet ( ) ) { batch . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } if ( putAllWriteCount . addAndGet ( values . size ( ) ) > 10_000 ) { putAllWriteCount . set ( 0 ) ; database . write ( batch , flush ) ; } else { database . write ( batch , writeOptions ) ; } } finally { closeBatch ( batch ) ; }


signature:
public class LevelDBKeyValueStore { /** * Remove all of the keys passed .
 * @ param keys keys */
@ Override public void removeAll ( Iterable < byte [ ] > keys ) { } }

implementation: WriteBatch batch = database . createWriteBatch ( ) ; try { for ( byte [ ] key : keys ) { batch . delete ( key ) ; } database . write ( batch ) ; } finally { closeBatch ( batch ) ; }


signature:
public class LevelDBKeyValueStore { /** * Search to a certain location .
 * @ param startKey startKey
 * @ return */
@ Override public KeyValueIterable < byte [ ] , byte [ ] > search ( byte [ ] startKey ) { } }

implementation: final DBIterator iterator = database . iterator ( ) ; iterator . seek ( startKey ) ; return new KeyValueIterable < byte [ ] , byte [ ] > ( ) { @ Override public void close ( ) { closeIterator ( iterator ) ; } @ Override public Iterator < Entry < byte [ ] , byte [ ] > > iterator ( ) { return new Iterator < Entry < byte [ ] , byte [ ] > > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Entry < byte [ ] , byte [ ] > next ( ) { Map . Entry < byte [ ] , byte [ ] > next = iterator . next ( ) ; return new Entry < > ( next . getKey ( ) , next . getValue ( ) ) ; } @ Override public void remove ( ) { iterator . remove ( ) ; } } ; } } ;


signature:
public class LevelDBKeyValueStore { /** * Load all of the key / values from the store .
 * @ return */
@ Override public KeyValueIterable < byte [ ] , byte [ ] > loadAll ( ) { } }

implementation: final DBIterator iterator = database . iterator ( ) ; iterator . seekToFirst ( ) ; return new KeyValueIterable < byte [ ] , byte [ ] > ( ) { @ Override public void close ( ) { closeIterator ( iterator ) ; } @ Override public Iterator < Entry < byte [ ] , byte [ ] > > iterator ( ) { return new Iterator < Entry < byte [ ] , byte [ ] > > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Entry < byte [ ] , byte [ ] > next ( ) { Map . Entry < byte [ ] , byte [ ] > next = iterator . next ( ) ; return new Entry < > ( next . getKey ( ) , next . getValue ( ) ) ; } @ Override public void remove ( ) { iterator . remove ( ) ; } } ; } } ;


signature:
public class LevelDBKeyValueStore { /** * Keys are expected to be sorted
 * @ param keys
 * @ return */
@ Override public Map < byte [ ] , byte [ ] > loadAllByKeys ( Collection < byte [ ] > keys ) { } }

implementation: if ( keys == null || keys . size ( ) == 0 ) { return Collections . EMPTY_MAP ; } Map < byte [ ] , byte [ ] > results = new LinkedHashMap < > ( keys . size ( ) ) ; DBIterator iterator = null ; try { iterator = database . iterator ( ) ; iterator . seek ( keys . iterator ( ) . next ( ) ) ; while ( iterator . hasNext ( ) ) { final Map . Entry < byte [ ] , byte [ ] > next = iterator . next ( ) ; results . put ( next . getKey ( ) , next . getValue ( ) ) ; } } finally { try { if ( iterator != null ) { iterator . close ( ) ; } } catch ( IOException e ) { Exceptions . handle ( e ) ; } } return results ;


signature:
public class LevelDBKeyValueStore { /** * Close the database connection . */
@ Override public void close ( ) { } }

implementation: try { flush ( ) ; database . close ( ) ; } catch ( Exception e ) { Exceptions . handle ( e ) ; }


signature:
public class Dbl { /** * / * End universal methods . */
private static int calculateEndIndex ( double [ ] array , int originalIndex ) { } }

implementation:
final int length = array . length ; Exceptions . requireNonNull ( array , "array cannot be null" ) ; int index = originalIndex ; /* Adjust for reading from the right as in
 -1 reads the 4th element if the length is 5 */
if ( index < 0 ) { index = length + index ; } /* Bounds check
 if it is still less than 0 , then they
 have an negative index that is greater than length */
/* Bounds check
 if it is still less than 0 , then they
 have an negative index that is greater than length */
if ( index < 0 ) { index = 0 ; } if ( index > length ) { index = length ; } return index ;


signature:
public class Dbl { /** * Reduce by functional support for int arrays .
 * @ param array array of items to reduce by
 * @ param object object that contains the reduce by function
 * @ param < T > the type of object
 * @ return the final reduction */
public static < T > double reduceBy ( final double [ ] array , T object ) { } }

implementation: if ( object . getClass ( ) . isAnonymousClass ( ) ) { return reduceByR ( array , object ) ; } try { ConstantCallSite callSite = Invoker . invokeReducerLongIntReturnLongMethodHandle ( object ) ; MethodHandle methodHandle = callSite . dynamicInvoker ( ) ; try { double sum = 0 ; for ( double v : array ) { sum = ( double ) methodHandle . invokeExact ( sum , v ) ; } return sum ; } catch ( Throwable throwable ) { return handle ( Long . class , throwable , "Unable to perform reduceBy" ) ; } } catch ( Exception ex ) { return reduceByR ( array , object ) ; }


signature:
public class Dbl { /** * Fallback to reflection if the call - site will not work or did not work
 * @ param array array of items to reduce by
 * @ param object function object
 * @ param < T > type of function object .
 * @ return */
private static < T > double reduceByR ( final double [ ] array , T object ) { } }

implementation: try { Method method = Invoker . invokeReducerLongIntReturnLongMethod ( object ) ; double sum = 0 ; for ( double v : array ) { sum = ( double ) method . invoke ( object , sum , v ) ; } return sum ; } catch ( Throwable throwable ) { return handle ( Long . class , throwable , "Unable to perform reduceBy" ) ; }


signature:
public class Dbl { /** * Min
 * @ param values values in int
 * @ return min */
public static double min ( double [ ] values , final int start , final int length ) { } }

implementation: double min = Float . MAX_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] < min ) min = values [ index ] ; } return min ;


signature:
public class Dbl { /** * Calculate Variance .
 * @ param values values
 * @ param start start
 * @ param length length
 * @ return variance */
public static double varianceDouble ( double [ ] values , final int start , final int length ) { } }

implementation: double mean = mean ( values , start , length ) ; double temp = 0 ; for ( int index = start ; index < length ; index ++ ) { double a = values [ index ] ; temp += ( mean - a ) * ( mean - a ) ; } return temp / length ;


signature:
public class Lng { /** * / * End universal methods . */
private static int calculateIndex ( long [ ] array , int originalIndex ) { } }

implementation:
final int length = array . length ; Exceptions . requireNonNull ( array , "array cannot be null" ) ; int index = originalIndex ; /* Adjust for reading from the right as in
 -1 reads the 4th element if the length is 5 */
if ( index < 0 ) { index = length + index ; } /* Bounds check
 if it is still less than 0 , then they
 have an negative index that is greater than length */
/* Bounds check
 if it is still less than 0 , then they
 have an negative index that is greater than length */
if ( index < 0 ) { index = 0 ; } if ( index >= length ) { index = length - 1 ; } return index ;


signature:
public class Lng { /** * Max
 * @ param values values in int
 * @ return max */
public static long max ( long [ ] values , final int start , final int length ) { } }

implementation: long max = Long . MIN_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] > max ) { max = values [ index ] ; } } return max ;


signature:
public class Lng { /** * Min
 * @ param values values in int
 * @ return min */
public static long min ( long [ ] values , final int start , final int length ) { } }

implementation: long min = Long . MAX_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] < min ) min = values [ index ] ; } return min ;


signature:
public class Lng { /** * Average
 * @ param values values in int
 * @ return average */
public static long mean ( long [ ] values , final int start , final int length ) { } }

implementation: return ( long ) Math . round ( meanDouble ( values , start , length ) ) ;


signature:
public class Lng { /** * Calculates variance
 * @ param values values
 * @ param start start
 * @ param length length
 * @ return variance */
public static long variance ( long [ ] values , final int start , final int length ) { } }

implementation: return ( long ) Math . round ( varianceDouble ( values , start , length ) ) ;


signature:
public class Lng { /** * Used internally to avoid loss and rounding errors a bit .
 * @ param values values
 * @ param start start
 * @ param length length
 * @ return meanDouble */
public static double meanDouble ( long [ ] values , final int start , final int length ) { } }

implementation: double mean = ( ( double ) sum ( values , start , length ) ) / ( ( double ) length ) ; return mean ;


signature:
public class Lng { /** * Calculate Median
 * @ param values values
 * @ param start start
 * @ param length length
 * @ return median */
public static long median ( long [ ] values , final int start , final int length ) { } }

implementation: long [ ] sorted = new long [ length ] ; System . arraycopy ( values , start , sorted , 0 , length ) ; Arrays . sort ( sorted ) ; if ( length % 2 == 0 ) { int middle = sorted . length / 2 ; double median = ( sorted [ middle - 1 ] + sorted [ middle ] ) / 2.0 ; return Math . round ( median ) ; } else { return sorted [ sorted . length / 2 ] ; }


signature:
public class RequestHandler { /** * Main entry into system .
 * If you are debugging something not coming into the system .
 * Start here ! */
@ ServiceMethod public void mainRequestHandler ( DataStoreRequest dataStoreRequest ) { } }

implementation: if ( verbose || debug ) { logger . info ( "RequestHandler::mainRequestHandler" , dataStoreRequest ) ; } switch ( dataStoreRequest . action ( ) ) { case GET : masterDataStore . get ( ( GetRequest ) dataStoreRequest ) ; break ; case GET_LOCAL_DB : handleGetLocalDbVerb ( dataStoreRequest ) ; break ; case GET_MEM : handleGetMemVerb ( dataStoreRequest ) ; break ; case SET : masterDataStore . set ( ( SetRequest ) dataStoreRequest ) ; break ; case SET_BROADCAST : handleSetAndBroadCastVerb ( dataStoreRequest ) ; break ; case SET_IF_NOT_EXIST : handleSetIfNotExistsVerb ( dataStoreRequest ) ; break ; case SET_BATCH : handleSetBatch ( dataStoreRequest ) ; break ; case SET_BATCH_IF_NOT_EXISTS : handleSetBatchIfNotExists ( dataStoreRequest ) ; break ; case SET_SOURCE : handleSetSource ( dataStoreRequest ) ; break ; case GET_SOURCE : handleGetSource ( dataStoreRequest ) ; break ; case BATCH_READ : handleBatchRead ( dataStoreRequest ) ; break ; case CLEAR_STATS : handleClearStats ( dataStoreRequest ) ; break ; case GET_STATS : handleGetStats ( dataStoreRequest ) ; break ; case REMOVE : handleRemove ( dataStoreRequest ) ; break ; case REMOVE_SOURCE : handleRemoveSource ( dataStoreRequest ) ; break ; case METHOD_CALL : handleMethodCall ( ( MethodCall ) dataStoreRequest ) ; break ; case SEARCH : handleSearchVerb ( dataStoreRequest ) ; break ; default : puts ( dataStoreRequest ) ; } trackCall ( dataStoreRequest . action ( ) ) ;


signature:
public class AbstractRangeValidator { /** * / * Allows this base class to be initialized by the subclasses . */
protected void init ( Comparable min , Comparable max ) { } }

implementation: this . realMin = min ; this . realMax = max ; assert min . compareTo ( max ) < 0 ; isInitialized = true ;


signature:
public class Invoker { /** * Invokes method from list or map depending on what the Object arg is .
 * @ param object
 * @ param method
 * @ param args
 * @ return */
public static Object invokeMethodFromObjectArg ( Object object , MethodAccess method , Object args ) { } }

implementation: return invokeMethodFromObjectArg ( false , null , null , object , method , args ) ;


signature:
public class Flt { /** * A very fast reduce by .
 * If performance is your thing , this seems to be as fast a plain for loop when benchmarking with JMH .
 * @ param array array of items to reduce by
 * @ param reduceBy reduceBy interface
 * @ return the final value */
public static double reduceBy ( final float [ ] array , ReduceBy reduceBy ) { } }

implementation: double sum = 0 ; for ( float v : array ) { sum = reduceBy . reduce ( sum , v ) ; } return sum ;


signature:
public class Flt { /** * Big Sum
 * @ param values values in int
 * @ return sum */
public static double bigSum ( float [ ] values , int start , int length ) { } }

implementation: double sum = 0 ; for ( int index = start ; index < length ; index ++ ) { sum += values [ index ] ; } return sum ;


signature:
public class Flt { /** * Max
 * @ param values values in int
 * @ return max */
public static float max ( float [ ] values , final int start , final int length ) { } }

implementation: float max = Float . MIN_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] > max ) { max = values [ index ] ; } } return max ;


signature:
public class Flt { /** * Calculate standard deviation .
 * @ param values values
 * @ param start start
 * @ param length length
 * @ return standard deviation */
public static float standardDeviation ( float [ ] values , final int start , final int length ) { } }

implementation: double variance = varianceDouble ( values , start , length ) ; return ( float ) Math . sqrt ( variance ) ;


signature:
public class Dates { /** * Useful for generated file names and generated work directories .
 * @ param timestamp the timestamp
 * @ return euro style format . */
public static String euroUTCSystemDateString ( long timestamp ) { } }

implementation: Calendar calendar = Calendar . getInstance ( ) ; calendar . setTimeInMillis ( timestamp ) ; calendar . setTimeZone ( UTC_TIME_ZONE ) ; int day = calendar . get ( Calendar . DAY_OF_MONTH ) ; int month = calendar . get ( Calendar . MONTH ) ; int year = calendar . get ( Calendar . YEAR ) ; int hour = calendar . get ( Calendar . HOUR_OF_DAY ) ; int minute = calendar . get ( Calendar . MINUTE ) ; int second = calendar . get ( Calendar . SECOND ) ; CharBuf buf = CharBuf . create ( 16 ) ; buf . add ( Str . zfill ( day , 2 ) ) . add ( '_' ) ; buf . add ( Str . zfill ( month , 2 ) ) . add ( '_' ) ; buf . add ( year ) . add ( '_' ) ; buf . add ( Str . zfill ( hour , 2 ) ) . add ( '_' ) ; buf . add ( Str . zfill ( minute , 2 ) ) . add ( '_' ) ; buf . add ( Str . zfill ( second , 2 ) ) . add ( "_utc_euro" ) ; return buf . toString ( ) ;


signature:
public class ObjectFilter { /** * Does the object match this expression .
 * An expression is a collection of criteria .
 * @ param obj object in question
 * @ param exp expression
 * @ return true or false */
public static boolean matches ( Object obj , Criteria ... exp ) { } }

implementation: return ObjectFilter . and ( exp ) . test ( obj ) ;


signature:
public class ObjectFilter { /** * This has to convert values to field type . */
public static Criterion notIn ( final Object name , final Object ... values ) { } }

implementation: return new Criterion < Object > ( name . toString ( ) , Operator . NOT_IN , values ) { @ Override public boolean resolve ( Object owner ) { Object fieldValue = fieldValue ( ) ; if ( value == null ) { return false ; } return ! valueSet ( ) . contains ( fieldValue ) ; } } ;


signature: public class ObjectFilter { public static Criterion ltLong ( final Object name , final long compareValue ) { } }

implementation: return new Criterion ( name . toString ( ) , Operator . LESS_THAN , compareValue ) { @ Override public boolean resolve ( final Object owner ) { long value = fieldLong ( ) ; return value < compareValue ; } } ;


signature:
public class ObjectFilter { /** * Make criteria configurable
 * @ param operator
 * @ param type
 * @ param values
 * @ return */
public static Criteria createCriteria ( String name , Operator operator , TypeType type , Class < Object > classType , List < ? > values ) { } }

implementation: okOrDie ( "Values must be passed" , values ) ; Object value = values . get ( 0 ) ; switch ( operator ) { case EQUAL : switch ( type ) { case CHAR : return eqChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return eqByte ( name , Conversions . toByte ( value ) ) ; case BOOLEAN : return eqBoolean ( name , Conversions . toBoolean ( value ) ) ; case INT : return eqInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return eqFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return eqShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return eqDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return eqLong ( name , Conversions . toLong ( value ) ) ; default : return eq ( name , Conversions . coerce ( classType , value ) ) ; } case NOT_EQUAL : switch ( type ) { case CHAR : return notEqChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return notEqByte ( name , Conversions . toByte ( value ) ) ; case BOOLEAN : return notEqBoolean ( name , Conversions . toBoolean ( value ) ) ; case INT : return notEqInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return notEqFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return notEqShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return notEqDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return notEqLong ( name , Conversions . toLong ( value ) ) ; default : return notEq ( name , Conversions . coerce ( classType , value ) ) ; } case GREATER_THAN : switch ( type ) { case CHAR : return gtChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return gtByte ( name , Conversions . toByte ( value ) ) ; case INT : return gtInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return gtFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return gtShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return gtDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return gtLong ( name , Conversions . toLong ( value ) ) ; default : return gt ( name , Conversions . coerce ( classType , value ) ) ; } case LESS_THAN : switch ( type ) { case CHAR : return ltChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return ltByte ( name , Conversions . toByte ( value ) ) ; case INT : return ltInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return ltFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return ltShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return ltDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return ltLong ( name , Conversions . toLong ( value ) ) ; default : return lt ( name , Conversions . coerce ( classType , value ) ) ; } case GREATER_THAN_EQUAL : switch ( type ) { case CHAR : return gteChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return gteByte ( name , Conversions . toByte ( value ) ) ; case INT : return gteInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return gteFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return gteShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return gteDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return gteLong ( name , Conversions . toLong ( value ) ) ; default : return gte ( name , Conversions . coerce ( classType , value ) ) ; } case LESS_THAN_EQUAL : switch ( type ) { case CHAR : return lteChar ( name , Conversions . toChar ( value ) ) ; case BYTE : return lteByte ( name , Conversions . toByte ( value ) ) ; case INT : return lteInt ( name , Conversions . toInt ( value ) ) ; case FLOAT : return lteFloat ( name , Conversions . toFloat ( value ) ) ; case SHORT : return lteShort ( name , Conversions . toShort ( value ) ) ; case DOUBLE : return lteDouble ( name , Conversions . toDouble ( value ) ) ; case LONG : return lteLong ( name , Conversions . toLong ( value ) ) ; default : return lte ( name , Conversions . coerce ( classType , value ) ) ; } case BETWEEN : okOrDie ( "Values must be at least 2 in size" , values . size ( ) > 1 ) ; Object value2 = values . get ( 1 ) ; switch ( type ) { case CHAR : return betweenChar ( name , Conversions . toChar ( value ) , Conversions . toChar ( value2 ) ) ; case BYTE : return betweenByte ( name , Conversions . toByte ( value ) , Conversions . toByte ( value2 ) ) ; case INT : return betweenInt ( name , Conversions . toInt ( value ) , Conversions . toInt ( value2 ) ) ; case FLOAT : return betweenFloat ( name , Conversions . toFloat ( value ) , Conversions . toFloat ( value2 ) ) ; case SHORT : return betweenShort ( name , Conversions . toShort ( value ) , Conversions . toShort ( value2 ) ) ; case DOUBLE : return betweenDouble ( name , Conversions . toDouble ( value ) , Conversions . toDouble ( value2 ) ) ; case LONG : return betweenLong ( name , Conversions . toLong ( value ) , Conversions . toLong ( value2 ) ) ; default : return between ( name , Conversions . coerce ( classType , value ) , Conversions . coerce ( classType , value2 ) ) ; } case IN : switch ( type ) { case CHAR : return inChars ( name , Conversions . carray ( values ) ) ; case BYTE : return inBytes ( name , Conversions . barray ( values ) ) ; case INT : return inInts ( name , Conversions . iarray ( values ) ) ; case FLOAT : return inFloats ( name , Conversions . farray ( values ) ) ; case SHORT : return inShorts ( name , Conversions . sarray ( values ) ) ; case DOUBLE : return inDoubles ( name , Conversions . darray ( values ) ) ; case LONG : return inLongs ( name , Conversions . larray ( values ) ) ; default : return in ( name , Conversions . toArray ( classType , ( List < Object > ) values ) ) ; } case NOT_IN : switch ( type ) { case CHAR : return notInChars ( name , Conversions . carray ( values ) ) ; case BYTE : return notInBytes ( name , Conversions . barray ( values ) ) ; case INT : return notInInts ( name , Conversions . iarray ( values ) ) ; case FLOAT : return notInFloats ( name , Conversions . farray ( values ) ) ; case SHORT : return notInShorts ( name , Conversions . sarray ( values ) ) ; case DOUBLE : return notInDoubles ( name , Conversions . darray ( values ) ) ; case LONG : return notInLongs ( name , Conversions . larray ( values ) ) ; default : return notIn ( name , Conversions . toArray ( classType , ( List < Object > ) values ) ) ; } case CONTAINS : return contains ( name , Conversions . coerce ( classType , value ) ) ; case NOT_CONTAINS : return notContains ( name , Conversions . coerce ( classType , value ) ) ; case STARTS_WITH : return startsWith ( name , value ) ; case ENDS_WITH : return endsWith ( name , value ) ; case NOT_EMPTY : return notEmpty ( name ) ; case IS_EMPTY : return empty ( name ) ; } return die ( Criteria . class , "Not Found" , name , operator , type , values ) ;


signature:
public class ObjectFilter { /** * Make criteria configurable
 * @ param operator
 * @ param values
 * @ return */
public static Criteria createCriteriaFromClass ( String name , Class < ? > cls , Operator operator , List < ? > values ) { } }

implementation: if ( operator == Operator . AND ) { return new Group . And ( cls , values ) ; } else if ( operator == Operator . OR ) { return new Group . Or ( cls , values ) ; } else { FieldAccess fieldAccess = BeanUtils . idxField ( cls , name ) ; return createCriteria ( name , operator , fieldAccess . typeEnum ( ) , ( Class < Object > ) fieldAccess . type ( ) , values ) ; }


signature:
public class ObjectFilter { /** * Creates criteria from a list . This is used to configure Criteria in JSON .
 * @ param list list to configure a single criteria
 * @ return criteria */
public static Criteria criteriaFromList ( List < ? > list ) { } }

implementation: List < Object > args = new ArrayList ( list ) ; Object o = atIndex ( args , - 1 ) ; if ( ! ( o instanceof List ) ) { atIndex ( args , - 1 , Collections . singletonList ( o ) ) ; } return ( Criteria ) Invoker . invokeFromList ( ObjectFilter . class , "createCriteriaFromClass" , args ) ;


signature:
public class ObjectFilter { /** * Converts a JSON string into a Criteria .
 * @ param json
 * @ return */
public static Criteria criteriaFromJson ( String json ) { } }

implementation: return ( Criteria ) Invoker . invokeFromObject ( ObjectFilter . class , "createCriteriaFromClass" , fromJson ( json ) ) ;


signature:
public class DoubleList { /** * Creates a primitive list based on an input list and a property path
 * @ param inputList input list
 * @ param propertyPath property path
 * @ return primitive list */
public static DoubleList toDoubleList ( Collection < ? > inputList , String propertyPath ) { } }

implementation: if ( inputList . size ( ) == 0 ) { return new DoubleList ( 0 ) ; } DoubleList outputList = new DoubleList ( inputList . size ( ) ) ; if ( propertyPath . contains ( "." ) || propertyPath . contains ( "[" ) ) { String [ ] properties = StringScanner . splitByDelimiters ( propertyPath , ".[]" ) ; for ( Object o : inputList ) { outputList . add ( BeanUtils . getPropertyDouble ( o , properties ) ) ; } } else { Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( inputList . iterator ( ) . next ( ) ) ; FieldAccess fieldAccess = fields . get ( propertyPath ) ; for ( Object o : inputList ) { outputList . add ( fieldAccess . getDouble ( o ) ) ; } } return outputList ;


signature:
public class DoubleList { /** * Add a new value to the list but don ' t employ a wrapper .
 * @ param value new value
 * @ return was able to add . */
public boolean addFloat ( double value ) { } }

implementation: if ( end + 1 >= values . length ) { values = grow ( values ) ; } values [ end ] = value ; end ++ ; return true ;


signature:
public class DoubleList { /** * Add a new value to the list but don ' t employ a wrapper .
 * @ param integer new value
 * @ return was able to add . */
public DoubleList add ( double integer ) { } }

implementation: if ( end + 1 >= values . length ) { values = grow ( values ) ; } values [ end ] = integer ; end ++ ; return this ;


signature:
public class DoubleList { /** * Add a new array to the list .
 * @ return was able to add . */
public boolean addArray ( double ... integers ) { } }

implementation: if ( end + integers . length >= values . length ) { values = grow ( values , ( values . length + integers . length ) * 2 ) ; } System . arraycopy ( integers , 0 , values , end , integers . length ) ; end += integers . length ; return true ;


signature:
public class DoubleList { /** * Set a value in the list .
 * @ param index index
 * @ param element new value
 * @ return old value at this index */
@ Override public Double set ( int index , Double element ) { } }

implementation: double oldValue = values [ index ] ; values [ index ] = element ; return oldValue ;


signature:
public class DoubleList { /** * This would be a good opportunity to reintroduce dynamic invoke
 * @ param function function
 * @ return */
public double reduceBy ( Object function , String name ) { } }

implementation: return Dbl . reduceBy ( values , end , function , name ) ;


signature:
public class Ordering { /** * Does a binary search
 * NOTE THIS WILL NOT SORT THE LIST ASCENDING .
 * @ param list items you want to search .
 * @ param item the item you are searching for .
 * @ param < T > type of item
 * @ return item found or null */
public static < T > T search ( List < T > list , T item ) { } }

implementation: if ( list . size ( ) > 1 ) { Object o = list ; int index = Collections . binarySearch ( ( List < ? extends Comparable < ? super T > > ) o , item ) ; return list . get ( index ) ; } else { return null ; }


signature:
public class Ordering { /** * Does a binary search
 * NOTE THIS WILL NOT SORT THE LIST ASCENDING .
 * @ param list list you are searching
 * @ param item the item you are searching for
 * @ return the index of the item */
public static int searchForIndex ( List < ? > list , Object item ) { } }

implementation: if ( list . size ( ) > 1 ) { Object o = list ; return Collections . binarySearch ( ( List < ? extends Comparable < ? super Object > > ) o , item ) ; } else { return - 1 ; }


signature:
public class Ordering { /** * Gets the max item from the array .
 * Sorts the list descending first .
 * @ param array the list
 * @ param < T > type of items
 * @ return the max item */
public static < T > T max ( T [ ] array ) { } }

implementation: if ( array . length > 1 ) { Sorting . sortDesc ( array ) ; return array [ 0 ] ; } else { return null ; }


signature:
public class Ordering { /** * From the sorts , this is the first few items .
 * @ param list
 * @ param count
 * @ param sorts
 * @ param < T >
 * @ return */
public static < T > List < T > firstOf ( List < T > list , int count , Sort ... sorts ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sort ( list , sorts ) ; return Lists . sliceOf ( list , 0 , count ) ; } else { return null ; }


signature:
public class Ordering { /** * Grabs the last items after the sort .
 * @ param list
 * @ param sorts
 * @ param < T >
 * @ return */
public static < T > T lastOf ( List < T > list , Sort ... sorts ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sort ( list , sorts ) ; return list . get ( list . size ( ) - 1 ) ; } else { return null ; }


signature:
public class Ordering { /** * Grabs the last few items from the list .
 * @ param list
 * @ param count
 * @ param sorts
 * @ param < T >
 * @ return */
public static < T > List < T > lastOf ( List < T > list , int count , Sort ... sorts ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sort ( list , sorts ) ; return Lists . endSliceOf ( list , count * - 1 ) ; } else { return null ; }


signature:
public class Ordering { /** * Returns the max value of the object with the property given .
 * @ param list
 * @ param sortBy
 * @ param < T >
 * @ return */
public static < T > T max ( List < T > list , String sortBy ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sortDesc ( list , sortBy ) ; return list . get ( 0 ) ; } else { return null ; }


signature:
public class Ordering { /** * Returns the max value of the object with the property given .
 * @ param array
 * @ param sortBy
 * @ param < T >
 * @ return */
public static < T > T max ( T [ ] array , String sortBy ) { } }

implementation: if ( array . length > 1 ) { Sorting . sortDesc ( array , sortBy ) ; return array [ 0 ] ; } else { return null ; }


signature:
public class Ordering { /** * Returns the least few .
 * @ param list
 * @ param count
 * @ param < T >
 * @ return */
public static < T > List < T > least ( List < T > list , int count ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sort ( list ) ; return Lists . sliceOf ( list , 0 , count ) ; } else { return null ; }


signature:
public class Ordering { /** * Returns the min value using a natural sort .
 * @ param list
 * @ param < T >
 * @ return */
public static < T > T min ( List < T > list ) { } }

implementation: if ( list . size ( ) > 1 ) { Sorting . sort ( list ) ; return list . get ( 0 ) ; } else { return null ; }


signature:
public class Ordering { /** * Returns the max value of the object with the property given .
 * @ param array
 * @ param < T >
 * @ return */
public static < T > T min ( T [ ] array ) { } }

implementation: if ( array . length > 1 ) { Sorting . sort ( array ) ; return array [ 0 ] ; } else { return null ; }


signature:
public class Ordering { /** * Returns the min value of the object with the property given .
 * @ param array
 * @ param sortBy
 * @ param < T >
 * @ return */
public static < T > T min ( T [ ] array , String sortBy ) { } }

implementation: if ( array . length > 1 ) { Sorting . sort ( array , sortBy ) ; return array [ 0 ] ; } else { return null ; }


signature:
public class MapperSimple { /** * This converts a list of maps to objects .
 * I always forget that this exists . I need to remember .
 * @ param list the input list
 * @ param < T > generics
 * @ return a new list */
@ Override public < T > List < T > convertListOfMapsToObjects ( List < Map > list , Class < T > componentType ) { } }

implementation: List < Object > newList = new ArrayList < > ( list . size ( ) ) ; for ( Object obj : list ) { if ( obj instanceof Value ) { obj = ( ( Value ) obj ) . toValue ( ) ; } if ( obj instanceof Map ) { Map map = ( Map ) obj ; if ( map instanceof ValueMapImpl ) { newList . add ( fromValueMap ( ( Map < String , Value > ) map , componentType ) ) ; } else { newList . add ( fromMap ( map , componentType ) ) ; } } else { newList . add ( Conversions . coerce ( componentType , obj ) ) ; } } return ( List < T > ) newList ;


signature:
public class MapperSimple { /** * Processes an array of maps .
 * @ param newInstance new instance we are injecting field into
 * @ param field field we are injecting a value into */
private void processArrayOfMaps ( Object newInstance , FieldAccess field , Map < String , Object > [ ] maps ) { } }

implementation: List < Map < String , Object > > list = Lists . list ( maps ) ; handleCollectionOfMaps ( newInstance , field , list ) ;


signature:
public class MapperSimple { /** * Processes an collection of maps .
 * @ param newInstance new instance we are injecting field into
 * @ param field field we are injecting a value into */
@ SuppressWarnings ( "unchecked" ) private void handleCollectionOfMaps ( Object newInstance , FieldAccess field , Collection < Map < String , Object > > collectionOfMaps ) { } }

implementation: Collection < Object > newCollection = Conversions . createCollection ( field . type ( ) , collectionOfMaps . size ( ) ) ; Class < ? > componentClass = field . getComponentClass ( ) ; if ( componentClass != null ) { for ( Map < String , Object > mapComponent : collectionOfMaps ) { newCollection . add ( fromMap ( mapComponent , componentClass ) ) ; } field . setObject ( newInstance , newCollection ) ; }


signature:
public class MapperSimple { /** * fromMap converts a map into a Java object .
 * This version will see if there is a class parameter in the map , and dies if there is not .
 * @ param map map to create the object from .
 * @ return new object */
@ Override public Object fromMap ( Map < String , Object > map ) { } }

implementation: String clazz = ( String ) map . get ( "class" ) ; Class cls = Reflection . loadClass ( clazz ) ; return fromMap ( map , cls ) ;


signature:
public class MapperSimple { /** * Creates a list of maps from a list of class instances .
 * @ param collection the collection we are coercing into a field value
 * @ return the return value . */
@ Override public List < Map < String , Object > > toListOfMaps ( Collection < ? > collection ) { } }

implementation: List < Map < String , Object > > list = new ArrayList < > ( ) ; for ( Object o : collection ) { list . add ( toMap ( o ) ) ; } return list ;


signature:
public class ConcurrentLruCache { /** * Key
 * @ param key the key
 * @ param value the value */
@ Override public void put ( KEY key , VALUE value ) { } }

implementation: VALUE oldValue = map . put ( key , value ) ; if ( oldValue != null ) { removeThenAddKey ( key ) ; } else { addKey ( key ) ; } if ( map . size ( ) > limit ) { map . remove ( removeLast ( ) ) ; }


signature:
public class ConcurrentLruCache { /** * Get the value at key
 * @ param key the key
 * @ return value */
@ Override public VALUE get ( KEY key ) { } }

implementation: removeThenAddKey ( key ) ; return map . get ( key ) ;


signature:
public class MessageUtils { /** * Generate the field . Transforms firstName into First Name . This allows
 * reasonable defaults for labels .
 * @ param fieldName fieldName
 * @ return generated label name . */
public static String generateLabelValue ( final String fieldName ) { } }

implementation:
final StringBuilder buffer = new StringBuilder ( fieldName . length ( ) * 2 ) ; class GenerationCommand { boolean capNextChar = false ; boolean lastCharWasUpperCase = false ; boolean lastCharWasNumber = false ; boolean lastCharWasSpecial = false ; boolean shouldContinue = true ; char [ ] chars = fieldName . toCharArray ( ) ; void processFieldName ( ) { for ( int index = 0 ; index < chars . length ; index ++ ) { char cchar = chars [ index ] ; shouldContinue = true ; processCharWasNumber ( buffer , index , cchar ) ; if ( ! shouldContinue ) { continue ; } processCharWasUpperCase ( buffer , index , cchar ) ; if ( ! shouldContinue ) { continue ; } processSpecialChars ( buffer , cchar ) ; if ( ! shouldContinue ) { continue ; } cchar = processCapitalizeCommand ( cchar ) ; cchar = processFirstCharacterCheck ( buffer , index , cchar ) ; if ( ! shouldContinue ) { continue ; } buffer . append ( cchar ) ; } } private void processCharWasNumber ( StringBuilder buffer , int index , char cchar ) { if ( lastCharWasSpecial ) { return ; } if ( Character . isDigit ( cchar ) ) { if ( index != 0 && ! lastCharWasNumber ) { buffer . append ( ' ' ) ; } lastCharWasNumber = true ; buffer . append ( cchar ) ; this . shouldContinue = false ; } else { lastCharWasNumber = false ; } } private char processFirstCharacterCheck ( final StringBuilder buffer , int index , char cchar ) { /* Always capitalize the first character . */
if ( index == 0 ) { cchar = Character . toUpperCase ( cchar ) ; buffer . append ( cchar ) ; this . shouldContinue = false ; } return cchar ; } private char processCapitalizeCommand ( char cchar ) { /* Capitalize the character . */
if ( capNextChar ) { capNextChar = false ; cchar = Character . toUpperCase ( cchar ) ; } return cchar ; } private void processSpecialChars ( final StringBuilder buffer , char cchar ) { lastCharWasSpecial = false ; /* If the character is ' . ' or ' _ ' then append a space and mark
 * the next iteration to capitalize . */
if ( cchar == '.' || cchar == '_' ) { buffer . append ( ' ' ) ; capNextChar = true ; lastCharWasSpecial = false ; this . shouldContinue = false ; } } private void processCharWasUpperCase ( final StringBuilder buffer , int index , char cchar ) { /* If the character is uppercase , append a space and keep track
 * that the last character was uppercase for the next iteration . */
if ( Character . isUpperCase ( cchar ) ) { if ( index != 0 && ! lastCharWasUpperCase ) { buffer . append ( ' ' ) ; } lastCharWasUpperCase = true ; buffer . append ( cchar ) ; this . shouldContinue = false ; } else { lastCharWasUpperCase = false ; } } } GenerationCommand gc = new GenerationCommand ( ) ; gc . processFieldName ( ) ; /* This is a hack to get address . line _ 1 to work . */
return buffer . toString ( ) . replace ( "  " , " " ) ;


signature:
public class CharBuf { /** * Turn a single bytes into two hex character representation .
 * @ param decoded the byte to serializeObject . */
public CharSequence addHex ( final int decoded ) { } }

implementation: int _location = location ; char [ ] _buffer = buffer ; int _capacity = capacity ; if ( 2 + _location > _capacity ) { _buffer = Chr . grow ( _buffer ) ; _capacity = _buffer . length ; } _buffer [ _location ] = ( char ) encodeNibbleToHexAsciiCharByte ( ( decoded >> 4 ) & 0x0F ) ; _location ++ ; _buffer [ _location ] = ( char ) encodeNibbleToHexAsciiCharByte ( decoded & 0x0F ) ; ; _location ++ ; location = _location ; buffer = _buffer ; capacity = _capacity ; return this ;


signature:
public class DataStoreSimpleHttpClient { /** * RESPONSES FROM SERVER .
 * @ param textResponse */
private void handleMessageFromServer ( String textResponse ) { } }

implementation: if ( verbose ) { puts ( "RESPONSE" , url , ProtocolConstants . prettyPrintMessage ( textResponse ) ) ; puts ( "RESPONSE" , url ) ; puts ( ProtocolConstants . prettyPrintMessageWithLinesTabs ( textResponse ) ) ; } if ( textResponse . startsWith ( Action . GET . response ( ) . startsWith ( ) ) || textResponse . startsWith ( Action . SET_BROADCAST . response ( ) . startsWith ( ) ) ) { queue . put ( SingleResult . fromTextMessage ( textResponse ) ) ; } else if ( textResponse . startsWith ( Action . BATCH_READ . response ( ) . startsWith ( ) ) ) { queue . put ( BatchResult . fromTextMessage ( textResponse ) ) ; } else if ( textResponse . startsWith ( Action . GET_STATS . response ( ) . startsWith ( ) ) ) { queue . put ( StatsResults . fromTextMessage ( textResponse ) ) ; } else { if ( verbose ) { puts ( textResponse ) ; } }


signature:
public class DataStoreSimpleHttpClient { /** * public SetRequest ( DataStoreSource source , Action action ,
 * long id , String clientId , long version ,
 * long createTimeStamp , long updateTimeStamp ,
 * String key , String payload ) {
 * @ param source
 * @ param key
 * @ param value */
@ Override public void set ( DataStoreSource source , String key , Object value ) { } }

implementation: SetRequest request = new SetRequest ( source , Action . SET_SOURCE , messageId , clientId , 0 , 0 , 0 , key , serializer . serialize ( value ) . toString ( ) ) ; send ( request ) ;


signature:
public class BaseStringBinaryKeyValueStore { /** * Search for a key in the key / value store .
 * @ param startKey
 * @ return */
public KeyValueIterable < K , V > search ( K startKey ) { } }

implementation: final KeyValueIterable < String , byte [ ] > search = store . search ( toKeyString ( startKey ) ) ; final Iterator < Entry < String , byte [ ] > > iterator = search . iterator ( ) ; return new KeyValueIterable < K , V > ( ) { @ Override public void close ( ) { search . close ( ) ; } @ Override public Iterator < Entry < K , V > > iterator ( ) { return new Iterator < Entry < K , V > > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Entry < K , V > next ( ) { final Entry < String , byte [ ] > next = iterator . next ( ) ; return new Entry < > ( toKeyObject ( next . key ( ) ) , toValueObject ( next . value ( ) ) ) ; } @ Override public void remove ( ) { iterator . remove ( ) ; } } ; } } ;


signature:
public class BaseStringBinaryKeyValueStore { /** * Put a value in the key / value store .
 * @ param key key
 * @ param value value */
public void put ( K key , V value ) { } }

implementation: store . put ( toKeyString ( key ) , toValueBytes ( value ) ) ;


signature:
public class BaseStringBinaryKeyValueStore { /** * Remove all of these values from the key value store .
 * @ param keys */
public void removeAll ( Iterable < K > keys ) { } }

implementation: List < String > list = new ArrayList < > ( ) ; for ( K key : keys ) { list . add ( toKeyString ( key ) ) ; } store . removeAll ( list ) ;


signature:
public class BaseDataStore { /** * Called from worker thread .
 * @ throws InterruptedException */
private void processReadQueue ( ) throws InterruptedException { } }

implementation: ReadStatus readStatus = new ReadStatus ( ) ; while ( true ) { DataStoreRequest request = readOperationsQueue . poll ( dataStoreConfig . pollTimeoutMS ( ) , TimeUnit . MILLISECONDS ) ; while ( request != null ) { readStatus . tracker . addCall ( request , outputDataQueue ) ; readOperationsBatch . add ( request ) ; if ( readOperationsBatch . size ( ) > dataStoreConfig . processQueueMaxBatchSize ( ) ) { break ; } request = readOperationsQueue . poll ( ) ; } if ( readOperationsBatch . size ( ) > 0 ) { try { recievedReadBatch ( new ArrayList < > ( readOperationsBatch ) ) ; } finally { readOperationsBatch . clear ( ) ; } } else { flushReadsIfNeeded ( ) ; } if ( readStatus . readBatchSize . size ( ) > 1_000 ) { StatCount count ; final long now = Timer . timer ( ) . time ( ) ; count = new StatCount ( now , DataStoreSource . SERVER , Action . GET_STATS , "Thread TIME USER  BaseDataStore " + Thread . currentThread ( ) . getName ( ) , Sys . threadUserTime ( ) ) ; this . outputDataQueue . put ( count ) ; count = new StatCount ( now , DataStoreSource . SERVER , Action . GET_STATS , "Thread TIME CPU  BaseDataStore " + Thread . currentThread ( ) . getName ( ) , Sys . threadCPUTime ( ) ) ; this . outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.max" , readStatus . readBatchSize . max ( ) ) ; outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.min" , readStatus . readBatchSize . min ( ) ) ; outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.median" , readStatus . readBatchSize . median ( ) ) ; outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.mean" , readStatus . readBatchSize . mean ( ) ) ; outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.standardDeviation" , readStatus . readBatchSize . standardDeviation ( ) ) ; outputDataQueue . put ( count ) ; count = new StatCount ( now , source , Action . GET , "BaseDataStore readStatus.readBatchSize.variance" , readStatus . readBatchSize . variance ( ) ) ; outputDataQueue . put ( count ) ; readStatus . readBatchSize . clear ( ) ; } }


signature:
public class BaseDataStore { /** * Called from worker thread .
 * Processes the incoming queue for read and writes . */
private void processWriteQueue ( ) throws InterruptedException { } }

implementation: WriteStatus status = new WriteStatus ( ) ; while ( true ) { DataStoreRequest operation = writeOperationsQueue . poll ( dataStoreConfig . pollTimeoutMS ( ) , TimeUnit . MILLISECONDS ) ; while ( operation != null ) { status . tracker . addCall ( operation , outputDataQueue ) ; writeOperationsBatch . add ( operation ) ; if ( writeOperationsBatch . size ( ) > dataStoreConfig . processQueueMaxBatchSize ( ) ) { break ; } operation = writeOperationsQueue . poll ( ) ; } if ( writeOperationsBatch . size ( ) > 0 ) { try { status . writeBatchSize . add ( writeOperationsBatch . size ( ) ) ; recievedWriteBatch ( new ArrayList < > ( writeOperationsBatch ) ) ; } finally { writeOperationsBatch . clear ( ) ; } } else { flushWritesIfNeeded ( ) ; } if ( status . writeBatchSize . size ( ) > 1000 ) { status . sendBatchSize ( source , outputDataQueue ) ; } }


signature:
public class BaseDataStore { /** * Start up the queue handlers . */
public void start ( ) { } }

implementation:
scheduledExecutorService = Executors . newScheduledThreadPool ( 2 , new ThreadFactory ( ) { @ Override public Thread newThread ( Runnable runnable ) { Thread thread = new Thread ( runnable ) ; thread . setName ( " DataQueue Process " + source ) ; return thread ; } } ) ; future = scheduledExecutorService . scheduleAtFixedRate ( new Runnable ( ) { @ Override public void run ( ) { if ( stop . get ( ) ) { return ; } try { processWriteQueue ( ) ; } catch ( InterruptedException ex ) { // let it restart or stop
} catch ( Exception ex ) { logger . fatal ( ex ) ; } } } , 0 , dataStoreConfig . threadErrorResumeTimeMS ( ) , TimeUnit . MILLISECONDS ) ; future = scheduledExecutorService . scheduleAtFixedRate ( new Runnable ( ) { @ Override public void run ( ) { if ( stop . get ( ) ) { return ; } try { processReadQueue ( ) ; } catch ( InterruptedException ex ) { // let it restart or stop
} catch ( Exception ex ) { logger . fatal ( ex , "Problem with base data store running scheduled job" ) ; } } } , 0 , dataStoreConfig . threadErrorResumeTimeMS ( ) , TimeUnit . MILLISECONDS ) ;


signature:
public class Str { /** * Puts character at index
 * @ param str string
 * @ param index index
 * @ param c char to put in
 * @ return new string */
@ Universal public static String atIndex ( String str , int index , char c ) { } }

implementation: return idx ( str , index , c ) ;


signature:
public class Str { /** * Gets slice of a string .
 * @ param str string
 * @ param start start index of slice
 * @ return new string */
@ Universal public static String slc ( String str , int start ) { } }

implementation: return FastStringUtils . noCopyStringFromChars ( Chr . slc ( FastStringUtils . toCharArray ( str ) , start ) ) ;


signature:
public class Str { /** * See if chars is in another string
 * @ param chars chars
 * @ param str string
 * @ return true or false */
@ Universal public static boolean in ( char [ ] chars , String str ) { } }

implementation: return Chr . in ( chars , FastStringUtils . toCharArray ( str ) ) ;


signature:
public class Str { /** * Add a char to a string
 * @ param str string
 * @ param c char
 * @ return new string */
@ Universal public static String add ( String str , char c ) { } }

implementation: return FastStringUtils . noCopyStringFromChars ( Chr . add ( FastStringUtils . toCharArray ( str ) , c ) ) ;


signature:
public class Str { /** * Add many objects converted to strings together .
 * Null are ignored so be careful .
 * @ param objects objects to convert to strings
 * @ return new string */
public static String addObjects ( Object ... objects ) { } }

implementation: int length = 0 ; for ( Object obj : objects ) { if ( obj == null ) { continue ; } length += obj . toString ( ) . length ( ) ; } CharBuf builder = CharBuf . createExact ( length ) ; for ( Object str : objects ) { if ( str == null ) { continue ; } builder . add ( str . toString ( ) ) ; } return builder . toString ( ) ;


signature:
public class Str { /** * Gets rid of null characters lurking in the string
 * @ param str string
 * @ return new string */
public static String compact ( String str ) { } }

implementation: return FastStringUtils . noCopyStringFromChars ( Chr . compact ( FastStringUtils . toCharArray ( str ) ) ) ;


signature:
public class Str { /** * Split a string
 * @ param str string to split
 * @ return string array */
public static String [ ] split ( String str ) { } }

implementation: char [ ] [ ] split = Chr . split ( FastStringUtils . toCharArray ( str ) ) ; return fromCharArrayOfArrayToStringArray ( split ) ;


signature:
public class Str { /** * Split a string by space
 * @ param str string to split
 * @ return string array */
public static String [ ] splitBySpace ( String str ) { } }

implementation: char [ ] [ ] split = CharScanner . splitBySpace ( FastStringUtils . toCharArray ( str ) ) ; return fromCharArrayOfArrayToStringArray ( split ) ;


signature:
public class Str { /** * Split a string by pipe
 * @ param str string to split
 * @ return string array */
public static String [ ] splitByPipe ( String str ) { } }

implementation: char [ ] [ ] split = CharScanner . splitByPipe ( FastStringUtils . toCharArray ( str ) ) ; return fromCharArrayOfArrayToStringArray ( split ) ;


signature:
public class Str { /** * Convert arrays of chars to arrays of strings
 * @ param split array of chars
 * @ return string array */
public static String [ ] fromCharArrayOfArrayToStringArray ( char [ ] [ ] split ) { } }

implementation: String [ ] results = new String [ split . length ] ; char [ ] array ; for ( int index = 0 ; index < split . length ; index ++ ) { array = split [ index ] ; results [ index ] = array . length == 0 ? EMPTY_STRING : FastStringUtils . noCopyStringFromChars ( array ) ; } return results ;


signature:
public class Str { /** * Convert to camel case and pass upper or lower
 * @ param inStr string to convert
 * @ param upper upper flag
 * @ return new string */
public static String camelCase ( String inStr , boolean upper ) { } }

implementation: char [ ] in = FastStringUtils . toCharArray ( inStr ) ; char [ ] out = Chr . camelCase ( in , upper ) ; return FastStringUtils . noCopyStringFromChars ( out ) ;


signature:
public class Str { /** * Checks to see if a string is inside of another
 * @ param start start
 * @ param inStr input string
 * @ param end index at end
 * @ return */
public static boolean insideOf ( String start , String inStr , String end ) { } }

implementation: return Chr . insideOf ( FastStringUtils . toCharArray ( start ) , FastStringUtils . toCharArray ( inStr ) , FastStringUtils . toCharArray ( end ) ) ;


signature:
public class Str { /** * Convert to under bar case
 * @ param inStr input string
 * @ return new string */
public static String underBarCase ( String inStr ) { } }

implementation: char [ ] in = FastStringUtils . toCharArray ( inStr ) ; char [ ] out = Chr . underBarCase ( in ) ; return FastStringUtils . noCopyStringFromChars ( out ) ;


signature:
public class Str { /** * See if they are equal or die
 * @ param a a
 * @ param b b */
public static void equalsOrDie ( CharSequence a , CharSequence b ) { } }

implementation: char [ ] ac = FastStringUtils . toCharArray ( a ) ; char [ ] bc = FastStringUtils . toCharArray ( b ) ; Chr . equalsOrDie ( ac , bc ) ;


signature:
public class Str { /** * See if they are equal or die
 * @ param a a
 * @ param b b */
public static void equalsOrDie ( String a , String b ) { } }

implementation: if ( a == null && b == null ) { return ; } if ( a == null || b == null ) { die ( "Values not equal value a=" , a , "value b=" , b ) ; } char [ ] ac = FastStringUtils . toCharArray ( a ) ; char [ ] bc = FastStringUtils . toCharArray ( b ) ; Chr . equalsOrDie ( ac , bc ) ;


signature:
public class Str { /** * Do a nice pretty print of a number .
 * Add commas and such .
 * @ param count number
 * @ return string format of number */
public static String num ( Number count ) { } }

implementation: if ( count == null ) { return "" ; } if ( count instanceof Double || count instanceof BigDecimal ) { String s = count . toString ( ) ; if ( idx ( s , 1 ) == '.' && s . length ( ) > 7 ) { s = slc ( s , 0 , 5 ) ; return s ; } else { return s ; } } else if ( count instanceof Integer || count instanceof Long || count instanceof Short || count instanceof BigInteger ) { String s = count . toString ( ) ; s = new StringBuilder ( s ) . reverse ( ) . toString ( ) ; CharBuf buf = CharBuf . create ( s . length ( ) ) ; int index = 0 ; for ( char c : s . toCharArray ( ) ) { index ++ ; buf . add ( c ) ; if ( index % 3 == 0 ) { buf . add ( ',' ) ; } } if ( buf . lastChar ( ) == ',' ) { buf . removeLastChar ( ) ; } s = buf . toString ( ) ; s = new StringBuilder ( s ) . reverse ( ) . toString ( ) ; return s ; } return count . toString ( ) ;


signature:
public class Sort { /** * Helper method to create a Sort that is a composite of other sorts .
 * @ param sorts list of child sorts
 * @ return */
public static Sort sorts ( Sort ... sorts ) { } }

implementation: if ( sorts == null || sorts . length == 0 ) { return null ; } Sort main = sorts [ 0 ] ; for ( int index = 1 ; index < sorts . length ; index ++ ) { main . then ( sorts [ index ] ) ; } return main ;


signature:
public class Sort { /** * Sort if you already know the reflection fields .
 * @ param list sort from list
 * @ param fields sort from fields . */
public void sort ( List list , Map < String , FieldAccess > fields ) { } }

implementation: Collections . sort ( list , this . comparator ( fields ) ) ;


signature:
public class Sort { /** * Sort and you look up the reflection fields .
 * @ param list */
public void sort ( List list ) { } }

implementation: if ( list == null || list . size ( ) == 0 ) { return ; } Object item = list . iterator ( ) . next ( ) ; Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( item ) ; Collections . sort ( list , this . comparator ( fields ) ) ;


signature:
public class Sort { /** * Sort and you look up the reflection fields .
 * @ param collection the collection to sort */
public < T > Collection < T > sort ( Class < T > componentClass , Collection < T > collection ) { } }

implementation: if ( collection instanceof List ) { sort ( ( List ) collection ) ; return collection ; } if ( collection == null || collection . size ( ) == 0 ) { return Collections . EMPTY_LIST ; } Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( componentClass ) ; T [ ] array = toArray ( componentClass , collection ) ; Arrays . sort ( array , this . comparator ( fields ) ) ; if ( collection instanceof Set ) { return new LinkedHashSet < > ( Lists . list ( array ) ) ; } else { return Lists . list ( array ) ; }


signature:
public class Sort { /** * Sort and you look up the reflection fields .
 * @ param iterable the collection to sort */
public < T > Iterable < T > sort ( Class < T > componentClass , Iterable < T > iterable ) { } }

implementation: if ( iterable instanceof List ) { sort ( ( List ) iterable ) ; return iterable ; } if ( iterable instanceof Collection ) { return sort ( componentClass , ( Collection ) iterable ) ; } if ( iterable == null ) { return Collections . EMPTY_LIST ; } List < T > list = Lists . list ( iterable ) ; sort ( list ) ; return list ;


signature:
public class Sort { /** * Sort and you look up the reflection fields .
 * @ param array */
public < T > void sort ( T [ ] array ) { } }

implementation: if ( array == null || array . length == 0 ) { return ; } Object item = array [ 0 ] ; Map < String , FieldAccess > fields = BeanUtils . getFieldsFromObject ( item ) ; Arrays . sort ( array , this . comparator ( fields ) ) ;


signature:
public class Sort { /** * This is what really does the magic . This is the comparator creator . */
public Comparator comparator ( Map < String , FieldAccess > fields ) { } }

implementation: if ( comparator == null ) { comparator = universalComparator ( this . getName ( ) , fields , this . getType ( ) , this . childComparators ( fields ) ) ; } return comparator ;


signature:
public class Sort { /** * This creates a list of children comparators based on the child list .
 * @ param fields
 * @ return */
private List < Comparator > childComparators ( Map < String , FieldAccess > fields ) { } }

implementation: if ( this . comparators == null ) { this . comparators = new ArrayList < > ( this . sorts . size ( ) + 1 ) ; for ( Sort sort : sorts ) { Comparator comparator = universalComparator ( sort . getName ( ) , fields , sort . getType ( ) , sort . childComparators ( fields ) ) ; this . comparators . add ( comparator ) ; } } return this . comparators ;


signature:
public class Maps { /** * Grabs the last value from a tree map ( Navigable map ) . */
@ Universal public static < K , V > V last ( NavigableMap < K , V > map ) { } }

implementation: return map . lastEntry ( ) . getValue ( ) ;


signature:
public class Maps { /** * Grabs the value after this key from a tree map ( Navigable map ) . */
@ Universal public static < K , V > V after ( NavigableMap < K , V > map , final K index ) { } }

implementation: return map . get ( map . higherKey ( index ) ) ;


signature:
public class Maps { /** * Grabs the value before this key from a tree map ( Navigable map ) . */
@ Universal public static < K , V > V before ( NavigableMap < K , V > map , final K index ) { } }

implementation: return map . get ( map . lowerKey ( index ) ) ;


signature:
public class Maps { /** * End universal methods . */
public static < K , V > boolean valueIn ( V value , Map < K , V > map ) { } }

implementation: return map . containsValue ( value ) ;


signature:
public class Int { /** * Checks to see if two values are the same
 * @ param expected expected value
 * @ param got got value
 * @ return true if equal throws exception if not equal */
public static boolean equalsOrDie ( int expected , int got ) { } }

implementation: if ( expected != got ) { return die ( Boolean . class , "Expected was" , expected , "but we got " , got ) ; } return true ;


signature:
public class Int { /** * Checks to see if two arrays are equals
 * @ param expected expected array
 * @ param got got array
 * @ return true if equal or throws exception if not . */
public static boolean equalsOrDie ( int [ ] expected , int [ ] got ) { } }

implementation: if ( expected . length != got . length ) { die ( "Lengths did not match, expected length" , expected . length , "but got" , got . length ) ; } for ( int index = 0 ; index < expected . length ; index ++ ) { if ( expected [ index ] != got [ index ] ) { die ( "value at index did not match index" , index , "expected value" , expected [ index ] , "but got" , got [ index ] ) ; } } return true ;


signature:
public class Int { /** * Sum
 * Provides overflow protection .
 * @ param values values in int
 * @ return sum */
public static int sum ( int [ ] values , int start , int length ) { } }

implementation: long sum = 0 ; for ( int index = start ; index < length ; index ++ ) { sum += values [ index ] ; } if ( sum < Integer . MIN_VALUE ) { die ( "overflow the sum is too small" , sum ) ; } if ( sum > Integer . MAX_VALUE ) { die ( "overflow the sum is too big" , sum ) ; } return ( int ) sum ;


signature:
public class Int { /** * Max
 * @ param values values in int
 * @ return max */
public static int max ( int [ ] values , final int start , final int length ) { } }

implementation: int max = Integer . MIN_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] > max ) { max = values [ index ] ; } } return max ;


signature:
public class Int { /** * Min
 * @ param values values in int
 * @ return min */
public static int min ( int [ ] values , final int start , final int length ) { } }

implementation: int min = Integer . MAX_VALUE ; for ( int index = start ; index < length ; index ++ ) { if ( values [ index ] < min ) min = values [ index ] ; } return min ;


signature:
public class Int { /** * Calculate standard deviation .
 * @ return standard deviation */
public static double standardDeviation ( Collection < ? > inputList , String propertyPath ) { } }

implementation: double variance = variance ( inputList , propertyPath ) ; return Math . round ( Math . sqrt ( variance ) ) ;


signature:
public class Int { /** * Calculate standard deviation .
 * @ return standard deviation */
public static int median ( Collection < ? > inputList , String propertyPath ) { } }

implementation: return IntList . toIntList ( inputList , propertyPath ) . median ( ) ;


signature:
public class Int { /** * Round up to the nearest power of 2
 * @ param number number you want to round up to .
 * @ return rounded up to the power of 2. */
public static int roundUpToPowerOf2 ( int number ) { } }

implementation: int rounded = number >= 1_000 ? 1_000 : ( rounded = Integer . highestOneBit ( number ) ) != 0 ? ( Integer . bitCount ( number ) > 1 ) ? rounded << 1 : rounded : 1 ; return rounded ;