signature:
public class RateCalculator { /** * Performs a calculation with the given minimal interval . See
 * { @ link RateCalculator } for details .
 * @ param rateBytesPerSecond
 * The rate in bytes per second to target
 * @ param minInterval
 * The minimal interval in nanoseconds .
 * @ return the calculation result */
public static Result calculate ( float rateBytesPerSecond , int minInterval ) { } }

implementation:
BigDecimal B_MIN = BigDecimal . ONE ; BigDecimal B_MAX = BigDecimal . valueOf ( MAX_BYTES_PER_TICK ) ; BigDecimal I_MIN = BigDecimal . valueOf ( minInterval ) ; BigDecimal I_MAX = BigDecimal . valueOf ( MAX_INTERVAL_NS ) ; BigDecimal Id_MAX = BigDecimal . valueOf ( Integer . MAX_VALUE ) ; BigDecimal ONEG = BigDecimal . valueOf ( NS_PER_S ) ; BigDecimal TWO = BigDecimal . valueOf ( 2 ) ; BigDecimal E = BigDecimal . valueOf ( Math . E ) ; BigDecimal R = BigDecimal . valueOf ( rateBytesPerSecond ) . divide ( ONEG , SCALE , ROUND ) ; BigDecimal I = I_MAX ; BigDecimal B = R . multiply ( I ) ; BigDecimal ERROR ; BigDecimal ERROR_MAX = BigDecimal . valueOf ( MAX_ERROR ) ; BigDecimal R_set = BigDecimal . valueOf ( rateBytesPerSecond ) . divide ( ONEG , SCALE , ROUND ) ; BigDecimal R_eff ; // bytes per I _ MAX < = 1
if ( B . compareTo ( B_MIN ) <= 0 ) { B = BigDecimal . ONE ; I = B . divide ( R , SCALE , ROUND ) ; BigDecimal Id = BigDecimal . ONE ; while ( true ) { while ( I . compareTo ( I_MAX ) > 0 ) { I = I . divide ( E , SCALE , ROUND ) ; Id = Id . multiply ( E ) ; } if ( Id . compareTo ( Id_MAX ) > 0 ) throw new IllegalArgumentException ( "rate too low (" + rateBytesPerSecond + "): prescaler too high" ) ; BigDecimal B_int = BigDecimal . valueOf ( B . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; BigDecimal I_int = BigDecimal . valueOf ( I . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; BigDecimal Id_int = BigDecimal . valueOf ( Id . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; R_eff = B_int . divide ( I_int , SCALE , ROUND ) . divide ( Id_int , SCALE , ROUND ) ; ERROR = R_eff . divide ( R_set , SCALE , ROUND ) . subtract ( BigDecimal . ONE ) . abs ( ) ; if ( ERROR . compareTo ( ERROR_MAX ) < 0 ) break ; I = I . multiply ( E ) ; B = B . multiply ( E ) ; } return new Result ( B . setScale ( 0 , ROUND ) . intValueExact ( ) , Id . setScale ( 0 , ROUND ) . intValueExact ( ) , I . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; } else { BigDecimal Id = BigDecimal . ONE ; while ( true ) { while ( I . compareTo ( I_MAX ) > 0 ) { I = I . divide ( E , SCALE , ROUND ) ; Id = Id . multiply ( E ) ; } while ( B . compareTo ( B_MAX ) > 0 ) { B = B . divide ( TWO , SCALE , ROUND ) ; I = I . divide ( TWO , SCALE , ROUND ) ; } if ( I . compareTo ( BigDecimal . ONE ) < 0 ) throw new IllegalArgumentException ( "rate too high (" + rateBytesPerSecond + "): interval too low" ) ; BigDecimal B_int = BigDecimal . valueOf ( B . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; BigDecimal I_int = BigDecimal . valueOf ( I . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; BigDecimal Id_int = BigDecimal . valueOf ( Id . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; R_eff = B_int . divide ( I_int , SCALE , ROUND ) . divide ( Id_int , SCALE , ROUND ) ; ERROR = R_eff . divide ( R_set , SCALE , ROUND ) . subtract ( BigDecimal . ONE ) . abs ( ) ; if ( ERROR . compareTo ( ERROR_MAX ) < 0 ) break ; I = I . multiply ( E ) ; B = B . multiply ( E ) ; } if ( I . compareTo ( I_MIN ) < 0 ) throw new IllegalArgumentException ( "rate too high (" + rateBytesPerSecond + "): interval too low" ) ; return new Result ( B . setScale ( 0 , ROUND ) . intValueExact ( ) , Id . setScale ( 0 , ROUND ) . intValueExact ( ) , I . setScale ( 0 , ROUND ) . intValueExact ( ) ) ; }


signature:
public class Streams { /** * Creates a byte - rate - limited { @ link InputStream } . See
 * { @ link RateLimitInputStream # RateLimitInputStream ( InputStream , TickSource , int , int ) }
 * for detailed information .
 * @ param base
 * The raw ( underlying ) { @ link InputStream }
 * @ param tickSource
 * The source of ticks
 * @ param bytesPerTick
 * ( see
 * { @ link RateLimitInputStream # RateLimitInputStream ( InputStream , TickSource , int , int ) }
 * @ param prescale
 * ( see
 * { @ link RateLimitInputStream # RateLimitInputStream ( InputStream , TickSource , int , int ) }
 * @ return the resulting input stream */
public static RateLimitInputStream limitRate ( InputStream base , TickSource tickSource , int bytesPerTick , int prescale ) { } }

implementation: return new RateLimitInputStream ( base , tickSource , bytesPerTick , prescale ) ;


signature:
public class Streams { /** * Creates a byte - rate - limited { @ link OutputStream } . See
 * { @ link RateLimitOutputStream # RateLimitOutputStream ( OutputStream , TickSource , int , int ) }
 * for detailed information .
 * @ param base
 * The raw ( underlying ) { @ link OutputStream }
 * @ param tickSource
 * The source of ticks
 * @ param bytesPerTick
 * ( see
 * { @ link RateLimitOutputStream # RateLimitOutputStream ( OutputStream , TickSource , int , int ) }
 * @ param prescaler
 * ( see
 * { @ link RateLimitOutputStream # RateLimitOutputStream ( OutputStream , TickSource , int , int ) }
 * @ return the resulting output stream */
public static RateLimitOutputStream limitRate ( OutputStream base , TickSource tickSource , int bytesPerTick , int prescaler ) { } }

implementation: return new RateLimitOutputStream ( base , tickSource , bytesPerTick , prescaler ) ;


signature:
public class Streams { /** * Creates a delayed { @ link InputStream } . See
 * { @ link DelayedInputStream # DelayedInputStream ( TickSource , InputStream , long , int ) }
 * for detailed information .
 * @ param base
 * The raw ( underlying ) { @ link InputStream } .
 * @ param tickSource
 * The source of ticks
 * @ param delay
 * The delay in ticks to add to the stream
 * @ param bufferSize
 * The buffer size to use ( see
 * { @ link DelayedInputStream # DelayedInputStream ( TickSource , InputStream , long , int ) }
 * @ return the resulting input stream */
public static DelayedInputStream addDelay ( InputStream base , TickSource tickSource , long delay , int bufferSize ) { } }

implementation: return new DelayedInputStream ( tickSource , base , delay , bufferSize ) ;


signature:
public class StreamGobbler { /** * Waits until the gobbler finished . If the gobbler encountered any
 * exception , it is thrown from this method .
 * @ throws Throwable
 * if the gobbler has thrown an exception */
public void waitFor ( ) throws Throwable { } }

implementation: while ( ! finished ) { try { synchronized ( this ) { this . wait ( 100 ) ; } } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } } if ( t != null ) throw t ;


signature:
public class StreamGobbler { /** * Interrupts the gobbler and closes its streams . */
public void close ( ) { } }

implementation: cancel = true ; try { thread . interrupt ( ) ; waitFor ( ) ; } catch ( Throwable ignore ) { } try { is . close ( ) ; } catch ( Exception ignore ) { } try { os . close ( ) ; } catch ( Exception ignore ) { }


signature:
public class RateLimitOutputStream { /** * len < = num */
private int realWrite ( byte [ ] b , int off , int len ) throws IOException { } }

implementation: int lenToWrite = rateHelper . take ( len ) ; real . write ( b , off , lenToWrite ) ; return lenToWrite ;


signature:
public class MapUtils { /** * Merging single level aggregation maps
 * @ param stream source to merge
 * @ param mergeFunction operation
 * @ param mapSupplier new map supplier
 * @ param < K > type of key
 * @ param < V > type of value
 * @ param < M > type of map supplier
 * @ return new merged map */
public static < K , V , M extends Map < K , V > > M merge ( Stream < ? extends Map < K , V > > stream , BinaryOperator < V > mergeFunction , Supplier < M > mapSupplier ) { } }

implementation: Assert . notNull ( stream , "Missing map merge function!" ) ; Assert . notNull ( mergeFunction , "Missing map merge function!" ) ; Assert . notNull ( mapSupplier , "Missing map supplier!" ) ; return stream . collect ( mapSupplier , ( a , b ) -> b . forEach ( ( k , v ) -> a . merge ( k , v , mergeFunction ) ) , Map :: putAll ) ;


signature:
public class MapUtils { /** * Splits map to list of maps
 * @ param map to be split
 * @ param limit max number of items in splitted map
 * @ param < K > key type
 * @ param < V > value type
 * @ return list of maps */
public static < K , V > List < Map < K , V > > split ( Map < K , V > map , int limit ) { } }

implementation:
Assert . notNull ( map , "Missing map!" ) ; Assert . isTrue ( limit > 0 , "Map limit must be > 0!" ) ; if ( map . size ( ) <= limit ) { return Collections . singletonList ( map ) ; // nothing to do
} return map . entrySet ( ) . parallelStream ( ) . collect ( mapSizer ( limit ) ) ;


signature:
public class MapUtils { /** * Collector splitting map into seperate maps
 * @ param limit max number of items in slitted map
 * @ param < K > key type
 * @ param < V > value type
 * @ return collected map with size less or equal to limit */
private static < K , V > Collector < Map . Entry < K , V > , ? , List < Map < K , V > > > mapSizer ( int limit ) { } }

implementation: return Collector . of ( ArrayList :: new , ( l , e ) -> { if ( l . isEmpty ( ) || l . get ( l . size ( ) - 1 ) . size ( ) == limit ) { l . add ( new HashMap < > ( ) ) ; } l . get ( l . size ( ) - 1 ) . put ( e . getKey ( ) , e . getValue ( ) ) ; } , ( l1 , l2 ) -> { if ( l1 . isEmpty ( ) ) { return l2 ; } if ( l2 . isEmpty ( ) ) { return l1 ; } if ( l1 . get ( l1 . size ( ) - 1 ) . size ( ) < limit ) { Map < K , V > map = l1 . get ( l1 . size ( ) - 1 ) ; ListIterator < Map < K , V > > mapsIte = l2 . listIterator ( l2 . size ( ) ) ; while ( mapsIte . hasPrevious ( ) && map . size ( ) < limit ) { Iterator < Map . Entry < K , V > > ite = mapsIte . previous ( ) . entrySet ( ) . iterator ( ) ; while ( ite . hasNext ( ) && map . size ( ) < limit ) { Map . Entry < K , V > entry = ite . next ( ) ; map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; ite . remove ( ) ; } if ( ! ite . hasNext ( ) ) { mapsIte . remove ( ) ; } } } l1 . addAll ( l2 ) ; return l1 ; } ) ;


signature:
public class MapUtils { /** * Sorts map with comparator
 * @ param map to be sorted
 * @ param comparator to apply
 * @ param < K > type of key
 * @ param < V > type of value
 * @ return sorted map ( LinkedHashMap ) */
public static < K , V > Map < K , V > sort ( Map < K , V > map , Comparator < Map . Entry < K , V > > comparator ) { } }

implementation: Assert . notNull ( map , "Missing map!" ) ; Assert . notNull ( comparator , "Missing comparator!" ) ; List < Map . Entry < K , V > > list = new LinkedList < > ( map . entrySet ( ) ) ; Collections . sort ( list , comparator ) ; Map < K , V > result = new LinkedHashMap < > ( ) ; for ( Map . Entry < K , V > entry : list ) { result . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } return result ;


signature:
public class MapUtils { /** * Returns first value in map as given by the iterator or null if empty
 * @ param map to get first value out
 * @ param < T > object type of result
 * @ return first value in map or null if null or empty */
public static < T > T firstValue ( Map < String , T > map ) { } }

implementation: if ( map == null || map . size ( ) == 0 ) { return null ; } String firstKey = map . keySet ( ) . iterator ( ) . next ( ) ; return map . get ( firstKey ) ;


signature:
public class Assert { /** * Tests if object is null
 * @ param test must be null
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if object ! = null */
public static < T > void isNull ( T test , String message ) { } }

implementation: isTrue ( test == null , message ) ;


signature:
public class Assert { /** * Tests if object is ! = null
 * @ param test must not be null
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if object = = null */
public static < T > void notNull ( T test , String message ) { } }

implementation: isFalse ( test == null , message ) ;


signature:
public class Assert { /** * Tests if String is null or empty when trimmed
 * @ param value must be non empty string
 * @ param message to return in exception
 * @ throws IllegalArgumentException if value = = null , value = = " " or value . trim ( ) = = " " */
public static void notNullOrEmptyTrimmed ( String value , String message ) { } }

implementation: isFalse ( StringUtils . isNullOrEmptyTrimmed ( value ) , message ) ;


signature:
public class Assert { /** * Tests if list is null or empty
 * @ param list must be have at least one element
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list = = null or list . size ( ) = = 0 */
public static < T > void notNullOrEmpty ( Collection < T > list , String message ) { } }

implementation: isFalse ( list == null || list . size ( ) == 0 , message ) ;


signature:
public class Assert { /** * Tests if list is null or empty
 * @ param set must be have at least one element
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list = = null or list . size ( ) = = 0 */
public static < T > void notNullOrEmpty ( Set < T > set , String message ) { } }

implementation: isFalse ( set == null || set . size ( ) == 0 , message ) ;


signature:
public class Assert { /** * Tests if list is null or empty
 * @ param array must be have at least one element
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list = = null or list . size ( ) = = 0 */
public static < T > void notNullOrEmpty ( T [ ] array , String message ) { } }

implementation: isFalse ( array == null || array . length == 0 , message ) ;


signature:
public class Assert { /** * Tests if map is null or empty
 * @ param map must be have at least one element
 * @ param message to return in exception
 * @ param < T > object type
 * @ param < K > value type
 * @ throws IllegalArgumentException if list = = null or list . size ( ) = = 0 */
public static < T , K > void notNullOrEmpty ( Map < T , K > map , String message ) { } }

implementation: isFalse ( map == null || map . size ( ) == 0 , message ) ;


signature:
public class Assert { /** * Tests if list is null or empty
 * @ param list must be null or empty
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list ! = null or list . size ( ) greater than 0 */
public static < T > void isNullOrEmpty ( List < T > list , String message ) { } }

implementation: isTrue ( list == null || list . size ( ) == 0 , message ) ;


signature:
public class Assert { /** * Tests if set is null or empty
 * @ param set must be null or empty
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list ! = null or list . size ( ) greater than 0 */
public static < T > void isNullOrEmpty ( Set < T > set , String message ) { } }

implementation: isTrue ( set == null || set . size ( ) == 0 , message ) ;


signature:
public class Assert { /** * Tests if array is null or empty
 * @ param array must be null or empty
 * @ param message to return in exception
 * @ param < T > object type
 * @ throws IllegalArgumentException if list ! = null or list . size ( ) greater than 0 */
public static < T > void isNullOrEmpty ( T [ ] array , String message ) { } }

implementation: isTrue ( array == null || array . length == 0 , message ) ;


signature:
public class Assert { /** * Tests if map is null or empty
 * @ param map must be null or empty
 * @ param message to return in exception
 * @ param < T > object type
 * @ param < K > value type
 * @ throws IllegalArgumentException if list ! = null or list . size ( ) greater than 0 */
public static < T , K > void isNullOrEmpty ( Map < T , K > map , String message ) { } }

implementation: isTrue ( map == null || map . size ( ) == 0 , message ) ;


signature:
public class ResourceUtils { /** * Loads class resource to String
 * @ param resourceFile to read
 * @ param clazz to use for resource access
 * @ return String representing the resource or null if resource could not be read */
@ Deprecated public static String getResourceAsString ( String resourceFile , Class clazz ) { } }

implementation: Assert . notNullOrEmptyTrimmed ( resourceFile , "Missing resource file!" ) ; Scanner scanner = null ; try { InputStream resource = clazz . getResourceAsStream ( resourceFile ) ; scanner = new Scanner ( resource , UTF_8 ) ; return scanner . useDelimiter ( "\\A" ) . next ( ) ; } catch ( Exception e ) { return null ; } finally { if ( scanner != null ) { scanner . close ( ) ; } }


signature:
public class ResourceUtils { /** * Loads resource as a set of Strings , where each word is added to the set
 * @ param resourceFile to read
 * @ param clazz to use for resource access
 * @ return set of strings ( lines ) or null if resource could not be read */
public static Set < String > getResourceWords ( String resourceFile , Class clazz ) { } }

implementation: Assert . notNullOrEmptyTrimmed ( resourceFile , "Missing resource file!" ) ; Scanner scanner = null ; try { InputStream resource = clazz . getResourceAsStream ( resourceFile ) ; scanner = new Scanner ( resource , UTF_8 ) ; Set < String > list = new LinkedHashSet < > ( ) ; while ( scanner . hasNext ( ) ) { String next = scanner . next ( ) ; if ( next != null && next . trim ( ) . length ( ) > 0 ) { list . add ( next ) ; } } return list ; } catch ( Exception e ) { return null ; } finally { if ( scanner != null ) { scanner . close ( ) ; } }


signature:
public class ResourceUtils { /** * Get resource last modified date
 * @ param resourceFile to read
 * @ param clazz to use for resource access
 * @ return last modified date or null if resource could not be read */
@ Deprecated public static Long getLastModifiedTime ( String resourceFile , Class clazz ) { } }

implementation:
Assert . notNullOrEmptyTrimmed ( resourceFile , "Missing resource file!" ) ; try { URL url = clazz . getResource ( resourceFile ) ; return url . openConnection ( ) . getLastModified ( ) ; // get last modified date of resource
} catch ( IOException e ) { return null ; }


signature:
public class ResourceUtils { /** * Load input stream into string
 * @ param is stream
 * @ param encoding to use when reading input stream
 * @ return String representation of given input */
public static String getString ( final InputStream is , String encoding ) { } }

implementation: if ( is == null ) { return null ; } if ( StringUtils . isNullOrEmptyTrimmed ( encoding ) ) { encoding = UTF_8 ; } final char [ ] buffer = new char [ BUFFER_SIZE ] ; final StringBuilder out = new StringBuilder ( ) ; try { try ( Reader in = new InputStreamReader ( is , encoding ) ) { for ( ; ; ) { int rsz = in . read ( buffer , 0 , buffer . length ) ; if ( rsz < 0 ) { break ; } out . append ( buffer , 0 , rsz ) ; } } } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; } return out . toString ( ) ;


signature:
public class ResourceUtils { /** * Load input stream into byte array
 * @ param is stream
 * @ return byte representation of given input */
public static byte [ ] getBytes ( InputStream is ) { } }

implementation: if ( is == null ) { return null ; } ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; int nRead ; byte [ ] data = new byte [ BUFFER_SIZE ] ; try { while ( ( nRead = is . read ( data , 0 , data . length ) ) != - 1 ) { buffer . write ( data , 0 , nRead ) ; } buffer . flush ( ) ; } catch ( IOException ignored ) { } return buffer . toByteArray ( ) ;


signature:
public class ResourceUtils { /** * Reads file into String
 * @ param file to be read
 * @ return file content
 * @ throws IOException in case file does ' t exist or is not a file */
public static String readFileToString ( File file ) throws IOException { } }

implementation: Assert . isTrue ( file . exists ( ) , "File '" + file + "' does not exist" ) ; Assert . isFalse ( file . isDirectory ( ) , "File '" + file + "' is a directory" ) ; Assert . isTrue ( file . canRead ( ) , "File '" + file + "' cannot be read" ) ; FileInputStream stream = new FileInputStream ( file ) ; return getString ( stream ) ;


signature:
public class ResourceUtils { /** * Gets absolute file path of resource
 * @ param resource to get absolute file path for
 * @ param clazz namespace holding resource
 * @ return file path if found
 * @ throws IllegalArgumentException if resource can not be found */
@ Deprecated public static String getResourceAbsolutePath ( String resource , Class clazz ) { } }

implementation: Assert . notNullOrEmptyTrimmed ( resource , "Missing resource name!" ) ; URL file = clazz . getResource ( resource ) ; Assert . notNull ( file , "Resource: '" + resource + "', not found!" ) ; return file . getFile ( ) ;


signature:
public class KeyGenerator { /** * Generates random string from ELEMENTS set of chars and numbers
 * @ param length desired length of key greater than 0
 * @ return random string of desired length ( min 1 , max 100 characters long ) */
public static String generateString ( int length ) { } }

implementation: if ( length <= 0 || length > 100 ) { throw new IllegalArgumentException ( "Can't generate random id with length: " + length ) ; } SecureRandom random = new SecureRandom ( ) ; StringBuilder sb = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i ++ ) { sb . append ( ELEMENTS . charAt ( random . nextInt ( ELEMENTS . length ( ) ) ) ) ; } return sb . toString ( ) ;


signature:
public class KeyGenerator { /** * Generates non negative long key of maximum length 18
 * @ param length desired length of key grater than 0 ( must consider max possible length of a long value )
 * @ return long key ( min 1 , max 19 digits long ) */
public static long generateLong ( int length ) { } }

implementation:
if ( length <= 0 || length > 19 ) { throw new IllegalArgumentException ( "Can't generate random id with length: " + length ) ; } SecureRandom random = new SecureRandom ( ) ; StringBuilder sb = new StringBuilder ( length ) ; // 1st digit should not be a 0 or 9 if desired length is 19 ( as max long is : 9223372036854775807)
if ( length == 19 ) { sb . append ( NUMBERS_NO_NINE_AND_ZERO . charAt ( random . nextInt ( NUMBERS_NO_NINE_AND_ZERO . length ( ) ) ) ) ; } else { sb . append ( NUMBERS_NO_ZERO . charAt ( random . nextInt ( NUMBERS_NO_ZERO . length ( ) ) ) ) ; } // all other digits can contain a 0
for ( int i = 1 ; i < length ; i ++ ) { sb . append ( NUMBERS . charAt ( random . nextInt ( NUMBERS . length ( ) ) ) ) ; } return Long . parseLong ( sb . toString ( ) ) ;


signature:
public class ArrayUtils { /** * joins two arrays and preserves array order
 * array1 items are followed by array2 items as given
 * @ param array1 first array
 * @ param array2 second array
 * @ param < T > class type of object in arrays
 * @ return joined array holding both arrays in same order as given */
@ SafeVarargs public static < T > T [ ] join ( final T [ ] array1 , final T ... array2 ) { } }

implementation:
if ( isEmpty ( array1 ) && isEmpty ( array2 ) ) { return null ; } if ( isEmpty ( array1 ) ) { return array2 ; } if ( isEmpty ( array2 ) ) { return array1 ; } final Class < ? > type1 = array1 . getClass ( ) . getComponentType ( ) ; @ SuppressWarnings ( "unchecked" ) // OK , because array is of type T
final T [ ] joinedArray = ( T [ ] ) Array . newInstance ( type1 , array1 . length + array2 . length ) ; int index = 0 ; for ( T item : array1 ) { joinedArray [ index ++ ] = item ; } for ( T item : array2 ) { joinedArray [ index ++ ] = item ; } return joinedArray ;


signature:
public class SetUtils { /** * Splits set in 1 . . N chunks of maxSize or less
 * @ param set to be spitted
 * @ param maxSize of a given chunk
 * @ param < T > type of class in set
 * @ return list of sets containing all elements of original set without duplicates */
public static < T > List < Set < T > > split ( Set < T > set , int maxSize ) { } }

implementation: Assert . notNull ( set , "Missing set to be split!" ) ; Assert . isTrue ( maxSize > 0 , "Max size must be > 0!" ) ; if ( set . size ( ) < maxSize ) { return Collections . singletonList ( set ) ; } List < Set < T > > list = new ArrayList < > ( ) ; Iterator < T > iterator = set . iterator ( ) ; while ( iterator . hasNext ( ) ) { Set < T > newSet = new HashSet < > ( ) ; for ( int j = 0 ; j < maxSize && iterator . hasNext ( ) ; j ++ ) { T item = iterator . next ( ) ; newSet . add ( item ) ; } list . add ( newSet ) ; } return list ;


signature:
public class InstantTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date time formatted to yyyy - MM - dd HH : mm : ss Z */
public static String formatDateTime ( long time ) { } }

implementation: Instant instant = Instant . ofEpochMilli ( time ) ; return formatDateTime ( instant ) ;


signature:
public class InstantTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date time formatted to yyyy - MM - dd HH : mm : ss Z */
public static String formatDateTime ( Instant time ) { } }

implementation: Assert . notNull ( time , "Missing time!" ) ; return DATE_TIME_FORMAT . format ( time ) ;


signature:
public class InstantTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date time formatted to yyyy - MM - dd HH : mm */
public static String formatDateTimeShort ( long time ) { } }

implementation: Instant instant = Instant . ofEpochMilli ( time ) ; return formatDateTimeShort ( instant ) ;


signature:
public class InstantTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date time formatted to yyyy - MM - dd HH : mm */
public static String formatDateTimeShort ( Instant time ) { } }

implementation: Assert . notNull ( time , "Missing time!" ) ; return SHORT_TIME_FORMAT . format ( time ) ;


signature:
public class InstantTimeUtils { /** * Formats time to date only
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date formatted yyyy - MM - dd */
public static String formatDate ( long time ) { } }

implementation: Instant instant = Instant . ofEpochMilli ( time ) ; return DATE_FORMAT . format ( instant ) ;


signature:
public class InstantTimeUtils { /** * Formats time to date only
 * @ param time to be formatted ( UTC ) in milliseconds
 * @ return date formatted yyyy - MM - dd */
public static String formatDate ( Instant time ) { } }

implementation: Assert . notNull ( time , "Missing time!" ) ; return DATE_FORMAT . format ( time ) ;


signature:
public class InstantTimeUtils { /** * Custom date time format
 * @ param time to be formatted
 * @ param format simple date time format , or null for default yyyy - MM - dd HH : mm : ss Z format
 * @ return formated date time */
public static String format ( long time , DateTimeFormatter format ) { } }

implementation: return format ( Instant . ofEpochMilli ( time ) , format ) ;


signature:
public class InstantTimeUtils { /** * Custom date time format
 * @ param time to be formatted
 * @ param format simple date time format , or null for default yyyy - MM - dd HH : mm : ss Z format
 * @ return formated date time */
public static String format ( Instant time , DateTimeFormatter format ) { } }

implementation: if ( format == null ) { return formatDateTime ( time ) ; } Assert . notNull ( time , "Missing time!" ) ; return format . format ( time ) ;


signature:
public class InstantTimeUtils { /** * Convert any given timestamp string to long
 * Note that in case conversion fails to produce a result a 0 timestamp is returned !
 * @ param value to be converted
 * @ param formats list of formats to try out
 * @ return time stamp or 0 if conversion failed */
public static Instant getTimestamp ( String value , DateTimeFormatter ... formats ) { } }

implementation:
Assert . notNull ( formats , "Missing date time formats" ) ; Assert . isTrue ( formats . length > 0 , "Missing date time formats" ) ; if ( StringUtils . isNullOrEmptyTrimmed ( value ) ) { return null ; } // OK check if we have 6 digit milliseconds . . . if so truncate
if ( value . matches ( ".*\\.\\d{6}.*" ) ) { // remove 3 milliseconds places
int index = value . indexOf ( "." ) ; value = value . substring ( 0 , index + 4 ) + value . substring ( index + 7 ) ; } // Go over all formats . . . and if success return value
for ( DateTimeFormatter format : formats ) { try { TemporalAccessor date = format . parse ( value ) ; return Instant . from ( date ) ; } catch ( DateTimeParseException e ) { // try next one . . .
} } return null ;


signature:
public class InstantTimeUtils { /** * Converts timestamp into OffsetDatetime
 * @ param timestamp to be converted
 * @ param zoneId desired zone or null to take instant zone id
 * @ return OffsetDatetime representation of timestamp */
public static OffsetDateTime toOffsetDateTime ( long timestamp , ZoneId zoneId ) { } }

implementation: Instant time = Instant . ofEpochMilli ( timestamp ) ; return toOffsetDateTime ( time , zoneId ) ;


signature:
public class InstantTimeUtils { /** * Converts timestamp into OffsetDatetime
 * @ param time to be converted
 * @ param zoneId desired zone or null to take instant zone id
 * @ return OffsetDatetime representation of timestamp */
public static OffsetDateTime toOffsetDateTime ( Instant time , ZoneId zoneId ) { } }

implementation: Assert . notNull ( time , "Missing time!" ) ; if ( zoneId == null ) { zoneId = ZoneId . from ( time ) ; } return OffsetDateTime . ofInstant ( time , zoneId ) ;


signature:
public class InstantTimeUtils { /** * Gets first millisecond of first day in month
 * @ param time to get first millisecond
 * @ return first millisecond of month for given time */
public static Instant getMonthStart ( Instant time ) { } }

implementation: Assert . notNull ( time , "Missing date time" ) ; LocalDateTime dateTime = LocalDateTime . ofInstant ( time , ZoneOffset . UTC ) ; dateTime = dateTime . withDayOfMonth ( 1 ) . withHour ( 0 ) . withMinute ( 0 ) . withSecond ( 0 ) . with ( ChronoField . MILLI_OF_SECOND , 0 ) ; return dateTime . toInstant ( ZoneOffset . UTC ) ;


signature:
public class InstantTimeUtils { /** * Returns last millisecond of last day in month . . . + 1 = next first day in month
 * @ param time to get last second in month
 * @ return last millisecond of month for given time */
public static Instant getMonthEnd ( Instant time ) { } }

implementation: Assert . notNull ( time , "Missing date time" ) ; LocalDateTime dateTime = LocalDateTime . ofInstant ( time , ZoneOffset . UTC ) ; dateTime = dateTime . withDayOfMonth ( 1 ) . withHour ( 23 ) . withMinute ( 59 ) . withSecond ( 59 ) . with ( ChronoField . MILLI_OF_SECOND , 999 ) ; dateTime = dateTime . plus ( 1 , ChronoUnit . MONTHS ) . minus ( 1 , ChronoUnit . DAYS ) ; return dateTime . toInstant ( ZoneOffset . UTC ) ;


signature:
public class InstantTimeUtils { /** * Check is time periods overlap
 * @ param startOne start time of first period / null for full
 * @ param endOne end tme of first period / null for full
 * @ param startTwo start time of second period / null for full
 * @ param endTwo end time of second period / null for full
 * @ return true if periods overlap , false if they don ' t
 * @ throws IllegalArgumentException in case start time is after end time of first / second period */
public static boolean overlaps ( Instant startOne , Instant endOne , Instant startTwo , Instant endTwo ) { } }

implementation:
// ( StartDate1 < = EndDate2 ) and ( StartDate2 < = EndDate1)
Instant startDate1 = startOne == null ? Instant . MIN : startOne ; Instant endDate1 = endOne == null ? Instant . MAX : endOne ; Assert . isTrue ( startDate1 . isBefore ( endDate1 ) , "Start date one can't be after end date one!" ) ; Instant startDate2 = startTwo == null ? Instant . MIN : startTwo ; Instant endDate2 = endTwo == null ? Instant . MAX : endTwo ; Assert . isTrue ( startDate2 . isBefore ( endDate2 ) , "Start date two can't be after end date two!" ) ; return startDate1 . compareTo ( endDate2 ) <= 0 && startDate2 . compareTo ( endDate1 ) <= 0 ;


signature:
public class StringUtils { /** * Compares two strings with < code > String . compare ( ) < / code > . Method allows
 * < code > null < / code > values .
 * @ param one to compare
 * @ param two to compare
 * @ return < b > 0 < / b > if both < code > null < / code > , < b > - 1 < / b > if < code > one < / code > is < code > null < / code > , < b > 1 < / b > if < code > two < / code > is < code > null < / code > , otherwise < code > String . compare ( ) < / code > is
 * called */
public static int compare ( String one , String two ) { } }

implementation: if ( one == null && two == null ) { return 0 ; } if ( one == null ) { return - 1 ; } if ( two == null ) { return 1 ; } return one . compareTo ( two ) ;


signature:
public class StringUtils { /** * Additionally to outer < code > trim ( ) < / code > double spaces are removed .
 * @ param value to remove double spaces from
 * @ return value with single spaces if any */
public static String trimDoubleSpaces ( String value ) { } }

implementation: if ( isNullOrEmpty ( value ) ) { return value ; } value = value . trim ( ) ; return value . replaceAll ( "\\s+" , " " ) ;


signature:
public class StringUtils { /** * Additionally to outer < code > trim ( ) < / code > all inner spaces are removed .
 * @ param value to remove inner spaces from
 * @ return value with single spaces if any */
public static String trimInner ( String value ) { } }

implementation: if ( isNullOrEmpty ( value ) ) { return value ; } value = value . trim ( ) ; return value . replaceAll ( "\\s+" , "" ) ;


signature:
public class StringUtils { /** * Trims down text to null if empty
 * @ param text to be trimmed
 * @ return text or null if empty */
public static String trimToNull ( String text ) { } }

implementation: text = trim ( text ) ; if ( text == null || text . isEmpty ( ) ) { return null ; } return text ;


signature:
public class StringUtils { /** * Capitalizes first character in given string
 * @ param input to capitalize first character
 * @ return capitalized string or null if null */
public static String capitalize ( String input ) { } }

implementation: if ( input == null ) { return null ; } if ( input . length ( ) > 1 ) { for ( int i = 0 ; i < input . length ( ) ; i ++ ) { if ( Character . isAlphabetic ( input . charAt ( i ) ) ) { return input . substring ( 0 , i ) + Character . toString ( input . charAt ( i ) ) . toUpperCase ( ) + input . substring ( i + 1 ) ; } } } return input . toUpperCase ( ) ;


signature:
public class StringUtils { /** * Joins list of string items to a single string , where items are separated
 * with a defined separator .
 * @ param list to join into string
 * @ param separator to be used between elements
 * @ return items joined into a single string */
public static String join ( List < ? > list , String separator ) { } }

implementation: return join ( list , separator , null ) ;


signature:
public class StringUtils { /** * Joins list of string items to a single string , where items are separated
 * with a defined separator .
 * @ param list to join into string
 * @ param separator to be used between elements
 * @ param limit max items to consider when joining , null or 0 to join all
 * @ return items joined into a single string */
public static String join ( List < ? > list , String separator , Integer limit ) { } }

implementation:
if ( separator == null || separator . equalsIgnoreCase ( "" ) ) { throw new IllegalArgumentException ( "Missing separator!" ) ; } StringBuilder output = new StringBuilder ( ) ; if ( limit == null || limit <= 0 ) { limit = list . size ( ) ; } if ( list != null && limit > 0 ) { for ( int i = 1 ; i <= limit ; i ++ ) { if ( i > list . size ( ) ) { break ; } if ( i <= limit ) { output . append ( list . get ( i - 1 ) ) ; if ( i == limit && list . size ( ) > limit ) { // ok list is larger than limit . . and we hit the limit
output . append ( separator ) . append ( "... [" ) . append ( limit ) . append ( "/" ) . append ( list . size ( ) ) . append ( "]" ) ; } if ( i < limit ) { output . append ( separator ) ; } } } } return output . toString ( ) ;


signature:
public class StringUtils { /** * Joins list of string items to a single string , where items are separated
 * with a defined separator .
 * @ param args to join into string
 * @ param separator to be used between elements
 * @ param limit max items to consider when joining , null or 0 to join all
 * @ return items joined into a single string */
public static String join ( Object [ ] args , String separator , Integer limit ) { } }

implementation: if ( separator == null || separator . equalsIgnoreCase ( "" ) ) { throw new IllegalArgumentException ( "Missing separator!" ) ; } if ( args != null && args . length > 0 ) { List < Object > array = Arrays . asList ( args ) ; return join ( array , separator , limit ) ; } return "" ;


signature:
public class StringUtils { /** * Joins array of objects into string , where items are separated
 * with a defined separator .
 * @ param args array of Object
 * @ param separator to be used between elements
 * @ return items joined into a single string */
public static String join ( Object [ ] args , String separator ) { } }

implementation: return join ( args , separator , null ) ;


signature:
public class StringUtils { /** * Joins list of string items to a single string , where items are separated
 * with a defined separator .
 * @ param items to join into string
 * @ param separator to be used between elements
 * @ param limit max items to consider when joining , null or 0 to join all
 * @ return items joined into a single string */
public static String join ( Set < ? > items , String separator , Integer limit ) { } }

implementation: if ( separator == null || separator . equalsIgnoreCase ( "" ) ) { throw new IllegalArgumentException ( "Missing separator!" ) ; } if ( items != null && items . size ( ) > 0 ) { Object [ ] array = items . toArray ( ) ; return join ( array , separator , limit ) ; } return "" ;


signature:
public class StringUtils { /** * Joins set of items to a single string , where items are separated
 * with a defined separator .
 * @ param items to join into string
 * @ param separator to be used between elements
 * @ return items joined into a single string */
public static String join ( Set < ? > items , String separator ) { } }

implementation: return join ( items , separator , null ) ;


signature:
public class StringUtils { /** * Joins list of string items to a single string , where items are separated
 * with a defined separator .
 * @ param map to join into key = value list
 * @ param separator to be used between elements
 * @ param < T > key class type
 * @ param < V > value class type
 * @ return map key values joined into a single string */
public static < T , V > String join ( Map < T , V > map , String separator ) { } }

implementation: if ( separator == null || separator . equalsIgnoreCase ( "" ) ) { throw new IllegalArgumentException ( "Missing separator!" ) ; } StringBuilder output = new StringBuilder ( ) ; if ( map != null ) { for ( Object key : map . keySet ( ) ) { if ( output . length ( ) > 0 ) { output . append ( separator ) ; } output . append ( key ) . append ( "=" ) . append ( map . get ( key ) ) ; } } return output . toString ( ) ;


signature:
public class StringUtils { /** * Extracts words from text removing non alpha characters
 * @ param text to extract words from
 * @ return list of found words or empty list if none found */
public static List < String > getWords ( String text ) { } }

implementation: List < String > output = new ArrayList < > ( ) ; if ( isNullOrEmptyTrimmed ( text ) ) { return output ; } Pattern p = Pattern . compile ( "\\b\\p{L}+\\b" ) ; Matcher m = p . matcher ( text ) ; while ( m . find ( ) ) { output . add ( m . group ( ) ) ; } return output ;


signature:
public class StringUtils { /** * Wrapper around String . split ( regEx ) method
 * @ param text to split
 * @ param regEx regular expression to use for splitting
 * @ return list of strings or empty list if could not split */
public static List < String > split ( String text , String regEx ) { } }

implementation: if ( isNullOrEmptyTrimmed ( text ) ) { return Collections . emptyList ( ) ; } String [ ] items = text . trim ( ) . split ( regEx ) ; return Arrays . asList ( items ) ;


signature:
public class StringUtils { /** * Reduces text to max given size preserving words
 * @ param text to trim down
 * @ param size max desired size
 * @ return trimmed down text with " . . . " or original text if fitting size */
public static String trimTextDown ( String text , int size ) { } }

implementation: if ( text == null || text . length ( ) <= size ) { return text ; } int pos = text . lastIndexOf ( " " , size ) ; if ( pos < 0 ) { return text . substring ( 0 , size ) ; } return text . substring ( 0 , pos ) ;


signature:
public class StringUtils { /** * Reduces text size to a given size
 * @ param text to reduce
 * @ param sizeMinusAppend size final string should be max long
 * @ param append string to append at the end to indicate trimming
 * @ return trimmed text with appended text of given max size , or original text if shorter than desired */
public static String trimTextDown ( String text , int sizeMinusAppend , String append ) { } }

implementation: Assert . notNull ( append , "Missing append!" ) ; if ( text == null || text . length ( ) <= sizeMinusAppend ) { return text ; } sizeMinusAppend = sizeMinusAppend - append . length ( ) ; int pos = text . lastIndexOf ( " " , sizeMinusAppend ) ; if ( pos < 0 ) { return text . substring ( 0 , sizeMinusAppend ) + append ; } return text . substring ( 0 , pos ) + append ;


signature:
public class StringUtils { /** * Converts text to list of characters
 * @ param text to be converted
 * @ return list of characters */
public static List < String > asListOfChars ( String text ) { } }

implementation: List < String > list = new ArrayList < > ( ) ; if ( StringUtils . isNullOrEmptyTrimmed ( text ) ) { return list ; } for ( int i = 0 ; i < text . length ( ) ; i ++ ) { list . add ( Character . toString ( text . charAt ( i ) ) ) ; } return list ;


signature:
public class StringUtils { /** * Checks if given string is a single word ( doesn ' t accepts words with " - " as a single word ! )
 * @ param word to test
 * @ return true if word , false otherwise */
public static boolean isWord ( String word ) { } }

implementation: if ( isNullOrEmptyTrimmed ( word ) ) { return false ; } List < String > list = getWords ( word ) ; return list . size ( ) == 1 ;


signature:
public class StringUtils { /** * Calculates matching relevance between given string and search expression
 * @ param value to search in
 * @ param search to search for
 * @ return - 1 not relevant , 0 . . N - where lower values represents more relevant results */
public static int relevance ( String value , String search ) { } }

implementation:
if ( StringUtils . isNullOrEmptyTrimmed ( value ) || StringUtils . isNullOrEmptyTrimmed ( search ) ) { return - 1 ; } if ( search . length ( ) > value . length ( ) ) { return - 1 ; } int relevance = - 1 ; // start at - 1 . . . so - 1 is returned for no result
int delta = 1 ; // first delta at 1 . . . producing a sum of 0 when first letter is found
int len = value . length ( ) ; int searchLen = search . length ( ) ; int letterIndex = 0 ; for ( int searchIndex = 0 ; searchIndex < searchLen ; searchIndex ++ ) { char match = search . charAt ( searchIndex ) ; while ( letterIndex < len ) { char letter = value . charAt ( letterIndex ) ; letterIndex ++ ; if ( match == letter ) { relevance = relevance + delta ; // reverse to get higher value for better match
delta = 0 ; break ; } else { delta ++ ; } } // we matched all characters . . . and found the last one . . .
if ( delta == 0 && searchIndex == searchLen - 1 ) { return relevance ; } if ( letterIndex == len ) { break ; } } return - 1 ;


signature:
public class StringUtils { /** * Removes all multiple - consecutive whitespace characters ( space , tab , newline ) and replaces them with single space .
 * Also removes leading and trailing spaces .
 * @ param input to be sanitized
 * @ return sanitized output
 * @ throws IllegalArgumentException in case input is null or empty */
public static String sanitizeWhitespace ( String input ) { } }

implementation: Assert . notNull ( input , "Missing input!" ) ; input = input . replaceAll ( "\\s+" , " " ) ; return input . trim ( ) ;


signature:
public class StringUtils { /** * Removes all multiple - consecutive whitespace characters ( space , tab , newline ) and replaces them with single space .
 * Also removes leading and trailing spaces .
 * @ param input text to be sanitized as byte array
 * @ return sanitized byte array */
public static byte [ ] sanitizeWhitespace ( byte [ ] input ) { } }

implementation: Assert . isFalse ( input == null || input . length == 0 , "Missing input!" ) ; try { String stringFileData = new String ( input , "utf-8" ) ; return sanitizeWhitespace ( stringFileData ) . getBytes ( "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; }


signature:
public class StringUtils { /** * Simple enumeration : first , second , third . . . 5th , 6th . . etc for given number
 * @ param number to be enumerated ( must be grated than 0)
 * @ return enumeration or null if not applicable */
public static String enumerate ( Integer number ) { } }

implementation:
if ( number == null || number <= 0 ) { return null ; } int lastDigit = number % 10 ; switch ( number ) { // special case for first five
case 1 : return "first" ; case 2 : return "second" ; case 3 : return "third" ; case 4 : return "fourth" ; case 5 : return "fifth" ; default : switch ( lastDigit ) { case 1 : return number + "st" ; case 2 : return number + "nd" ; case 3 : return number + "rd" ; default : return number + "th" ; } }


signature:
public class StringUtils { /** * Removes double or single quotes if any are present
 * @ param text to remove double quotes from
 * @ return un quoted string */
public static String unQuote ( String text ) { } }

implementation: if ( isNullOrEmptyTrimmed ( text ) ) { return text ; } if ( ( text . startsWith ( "\"" ) && text . endsWith ( "\"" ) ) || ( text . startsWith ( "'" ) && text . endsWith ( "'" ) ) ) { return text . substring ( 1 , text . length ( ) - 1 ) ; } return text ;


signature:
public class DateTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC )
 * @ return date time formatted to yyyy - MM - dd HH : mm : ss Z */
public static String formatDateTime ( long time ) { } }

implementation: SimpleDateFormat format = getTimeFormat ( ) ; Calendar calendar = getCalendar ( time ) ; return format . format ( calendar . getTime ( ) ) ;


signature:
public class DateTimeUtils { /** * Formats time to String
 * @ param time to be formatted ( UTC )
 * @ return date time formatted to yyyy - MM - dd HH : mm */
public static String formatDateTimeShort ( long time ) { } }

implementation: SimpleDateFormat format = getDateTimeFormat ( ) ; Calendar calendar = getCalendar ( time ) ; return format . format ( calendar . getTime ( ) ) ;


signature:
public class DateTimeUtils { /** * Formats time to date only
 * @ param time to be formatted ( UTC )
 * @ return date formatted yyyy - MM - dd */
public static String formatDate ( long time ) { } }

implementation: SimpleDateFormat format = getDateFormat ( ) ; Calendar calendar = getCalendar ( time ) ; return format . format ( calendar . getTime ( ) ) ;


signature:
public class DateTimeUtils { /** * Returns time for given time zone
 * @ param time current time
 * @ param timezone time zone ( - 12 / + 12)
 * @ return time in other time zone */
public static long getTimezoneTime ( long time , int timezone ) { } }

implementation: Calendar calendar = getCalendar ( time ) ; int hour = calendar . get ( Calendar . HOUR_OF_DAY ) ; hour = ( hour + timezone ) % 24 ; if ( hour < 0 ) { hour = 24 + hour ; calendar . add ( Calendar . DAY_OF_MONTH , - 1 ) ; } calendar . set ( Calendar . HOUR_OF_DAY , hour ) ; return calendar . getTimeInMillis ( ) ;


signature:
public class DateTimeUtils { /** * Converts timestamp into OffsetDatetime
 * @ param timestamp to be converted
 * @ return OffsetDatetime representation of timestamp */
public static OffsetDateTime toOffsetDateTime ( long timestamp ) { } }

implementation: Calendar calendar = DateTimeUtils . getCalendar ( timestamp ) ; return OffsetDateTime . ofInstant ( calendar . toInstant ( ) , calendar . getTimeZone ( ) . toZoneId ( ) ) ;


signature:
public class DateTimeUtils { /** * Returns number of day in week , where monday is the first day of the week ( 1)
 * @ param time to check day in week
 * @ return 1 - monday , 2 - tuesday . . . 7 - saturday */
public static int getDayInWeek ( long time ) { } }

implementation:
int dayInWeek = getCalendar ( time ) . get ( Calendar . DAY_OF_WEEK ) - 1 ; // SUNDAY = = 1 - 1 = = 0
if ( dayInWeek == 0 ) { dayInWeek = 7 ; // make sunday the last day of the week
} return dayInWeek ;


signature:
public class DateTimeUtils { /** * Convert any given timestamp string to long
 * Note that in case conversion fails to produce a result a 0 timestamp is returned !
 * @ param value to be converted
 * @ param formats list of formats to try out
 * @ return time stamp or 0 if conversion failed */
public static long getTimestamp ( String value , SimpleDateFormat [ ] formats ) { } }

implementation:
Assert . notNull ( formats , "Missing date time formats" ) ; Assert . isTrue ( formats . length > 0 , "Missing date time formats" ) ; if ( StringUtils . isNullOrEmptyTrimmed ( value ) ) { return 0 ; } // OK check if we have 6 digit milliseconds . . . if so truncate
if ( value . matches ( ".*\\.\\d{6}.*" ) ) { // remove 3 milliseconds places
int index = value . indexOf ( "." ) ; value = value . substring ( 0 , index + 4 ) + value . substring ( index + 7 ) ; } // Go over all formats . . . and if success return value
for ( SimpleDateFormat format : formats ) { TimeZone oldDefaultTimeZone = TimeZone . getDefault ( ) ; try { // make sure we are in the correct time zone while doing this
TimeZone . setDefault ( TimeZone . getTimeZone ( "UTC" ) ) ; Date date = format . parse ( value ) ; return date . getTime ( ) ; } catch ( ParseException e ) { // try next one . . .
} finally { TimeZone . setDefault ( oldDefaultTimeZone ) ; } } return 0 ;


signature:
public class DateTimeUtils { /** * Check is time periods overlap
 * @ param startOne start time of first period / null for full
 * @ param endOne end tme of first period / null for full
 * @ param startTwo start time of second period / null for full
 * @ param endTwo end time of second period / null for full
 * @ return true if periods overlap , false if they don ' t
 * @ throws IllegalArgumentException in case start time is after end time of first / second period */
public static boolean overlaps ( Instant startOne , Instant endOne , Instant startTwo , Instant endTwo ) { } }

implementation: return InstantTimeUtils . overlaps ( startOne , endOne , startTwo , endTwo ) ;


signature:
public class Filter { /** * Loops through the FilterTags held by this Filter , and returns the state of the tag if it exists , and - 1 if it does not .
 * @ param tagID The id of the tag to get the state of
 * @ return - 1 if the tag was not found , otherwise the state of the tag */
public List < Integer > hasTag ( final Integer tagID ) { } }

implementation: final List < Integer > retValue = new ArrayList < Integer > ( ) ; for ( final FilterTag tag : getFilterTags ( ) ) { if ( tag . getTag ( ) . getTagId ( ) . equals ( tagID ) ) retValue . add ( tag . getTagState ( ) ) ; } return retValue ;


signature:
public class Filter { /** * Not all FilterTags assigned to a filter have an associated FilterCategory . If a FilterTags belongs to a category that
 * does not have an associated FilterCategory , the default boolean logic is used .
 * This function returns all the categories that the tags in this filter belong to . These are then matched to any associated
 * FilterCategories to find out how the tags are matched ( i . e . are we matching all the tags ( " And " logic ) , or one or more of
 * the tags matches ( " Or " logic ) ) , using the default logic ( " Or " ) if no associated FilterCategory exists .
 * @ return An ArrayList containing the Category IDs that the tags in this filter belong to */
@ Transient public ArrayList < Category > getFilterTagCategories ( ) { } }

implementation: final ArrayList < Category > categories = new ArrayList < Category > ( ) ; for ( final FilterTag filterTag : filterTags ) { final int filterTagState = filterTag . getTagState ( ) ; if ( filterTagState == CommonFilterConstants . MATCH_TAG_STATE || filterTagState == CommonFilterConstants . NOT_MATCH_TAG_STATE ) { final Tag tag = filterTag . getTag ( ) ; final Set < TagToCategory > tagToCategories = tag . getTagToCategories ( ) ; if ( tagToCategories . size ( ) != 0 ) { for ( final TagToCategory category : tagToCategories ) { if ( ! categories . contains ( category . getCategory ( ) ) ) { categories . add ( category . getCategory ( ) ) ; } } } else { if ( ! categories . contains ( null ) ) categories . add ( null ) ; } } } return categories ;


signature:
public class Statements { /** * Adds one or more { @ link Statement } objects to this { @ link Statements } holder .
 * @ param toAdd One or more { @ link Statement } instances . */
@ SuppressWarnings ( "PMD" ) public void add ( final Statement ... toAdd ) { } }

implementation:
if ( toAdd != null ) { Arrays . stream ( toAdd ) . filter ( Objects :: nonNull ) . forEach ( c -> { // Resolve the type of the current Statement , and assign it to
// the appropriate internal state .
if ( c instanceof CommonEdgeAttributes ) { this . commonEdgeAttributes = ( CommonEdgeAttributes ) c ; } else if ( c instanceof CommonGraphAttributes ) { this . commonGraphAttributes = ( CommonGraphAttributes ) c ; } else if ( c instanceof CommonNodeAttributes ) { this . commonNodeAttributes = ( CommonNodeAttributes ) c ; } else if ( c instanceof Node ) { this . nodes . add ( ( Node ) c ) ; } else if ( c instanceof Identifier ) { this . identifiers . add ( ( Identifier ) c ) ; } else if ( c instanceof Edge ) { this . edges . add ( ( Edge ) c ) ; } else if ( c instanceof Subgraph ) { this . subgraphs . add ( ( Subgraph ) c ) ; } } ) ; }


signature:
public class Statements { /** * Finds the Node with the supplied identifier within this Statements ( and within any contained Subgraphs , if the
 * { @ code recursive } flag is true ) .
 * @ param identifier The identifier to match against the { @ link Node # getId ( ) } of a matching Node .
 * @ param recursive If { @ code true } , the search should recurse into the Statements of Subgraphs .
 * @ return The Node with the supplied identifier - or null if none was found . */
public Node findNode ( final String identifier , final boolean recursive ) { } }

implementation:
Optional < Node > toReturn = getNodes ( ) . stream ( ) . filter ( c -> c . getId ( ) . equals ( identifier ) ) . findFirst ( ) ; if ( ! toReturn . isPresent ( ) && recursive && getSubgraphs ( ) != null && ! getSubgraphs ( ) . isEmpty ( ) ) { // Does the Node with the given identifier exist in any Subgraph ?
toReturn = getSubgraphs ( ) . stream ( ) . map ( c -> c . getStatements ( ) . findNode ( identifier , true ) ) . filter ( c -> c != null ) . findFirst ( ) ; } // All Done .
return toReturn . orElse ( null ) ;


signature:
public class Statements { /** * Finds the Edge with the supplied identifier within this Statements ( and within any contained Subgraphs , if the
 * { @ code recursive } flag is true ) .
 * @ param fromId The Node or Subgraph identifier of the starting point of the Edge to find .
 * @ param toId The Node or Subgraph identifier of the finishing point of the Edge to find .
 * @ param recursive If { @ code true } , the search should recurse into the Statements of Subgraphs .
 * @ return The Edge with the supplied identifier - or null if none was found . */
public Edge findEdge ( final String fromId , final String toId , final boolean recursive ) { } }

implementation:
Optional < Edge > toReturn = getEdges ( ) . stream ( ) . filter ( c -> c . getId ( ) . equals ( fromId ) && c . getRightSideEdge ( ) . getId ( ) . equals ( toId ) ) . findFirst ( ) ; if ( ! toReturn . isPresent ( ) && recursive ) { // Does the Node with the given identifier exist in any Subgraph ?
toReturn = subgraphs . stream ( ) . map ( c -> c . getStatements ( ) . findEdge ( fromId , toId , true ) ) . findFirst ( ) ; } // All Done .
return toReturn . orElse ( null ) ;


signature:
public class Statements { /** * Finds the Subgraph with the supplied identifier within this Statements ( and within any contained Subgraphs , if
 * the { @ code recursive } flag is true ) .
 * @ param identifier The identifier to match against the { @ link Subgraph # getId ( ) } of a matching Node .
 * @ param recursive If { @ code true } , the search should recurse into the Statements of Subgraphs .
 * @ return The Subgraph with the supplied identifier - or null if none was found . */
public Subgraph findSubgraph ( final String identifier , final boolean recursive ) { } }

implementation:
Optional < Subgraph > toReturn = getSubgraphs ( ) . stream ( ) . filter ( c -> c . getId ( ) . equals ( identifier ) ) . findFirst ( ) ; if ( ! toReturn . isPresent ( ) && recursive && getSubgraphs ( ) != null && ! getSubgraphs ( ) . isEmpty ( ) ) { // Does the Node with the given identifier exist in any Subgraph ?
toReturn = getSubgraphs ( ) . stream ( ) . map ( c -> c . getStatements ( ) . findSubgraph ( identifier , true ) ) . filter ( c -> c != null ) . findFirst ( ) ; } // All Done .
return toReturn . orElse ( null ) ;


signature:
public class Statements { /** * Convenience method to add and return an Edge between a Node / Subgraph and another Node / Subgraph .
 * @ param fromId The non - empty ID of the Node / Subgraph from which the Edge should originate .
 * @ param toId The non - empty ID of the Node / Subgraph to which the Edge should be directed .
 * @ param parentGraph The non - null parent { @ link Graph } where the Edge is about to be created .
 * @ return The newly created Edge - or { @ code null } if the Edge could not be created . */
public Edge addEdge ( final String fromId , final String toId , final Graph parentGraph ) { } }

implementation:
// Check sanity
if ( fromId == null || fromId . isEmpty ( ) ) { throw new IllegalArgumentException ( "Cannot handle null or empty 'fromId' argument." ) ; } if ( toId == null || toId . isEmpty ( ) ) { throw new IllegalArgumentException ( "Cannot handle null or empty 'toId' argument." ) ; } if ( parentGraph == null ) { throw new IllegalArgumentException ( "Cannot handle null 'parentGraph' argument." ) ; } Edge toReturn = null ; // Find the nodes between which the Edge should be created .
final Node fromNode = findNode ( fromId , true ) ; final Subgraph fromSubgraph = findSubgraph ( fromId , true ) ; if ( fromNode != null || fromSubgraph != null ) { // Find the RHS edge data .
final Node toNode = findNode ( toId , true ) ; final Subgraph toSubgraph = findSubgraph ( toId , true ) ; final NodeID toNodeId = toNode == null ? null : toNode . getNodeID ( ) ; // Can we actually create an Edge ?
if ( toNodeId != null || toSubgraph != null ) { // Start by creating the RightSideEdge .
final RightSideEdge rightSideEdge = toNodeId == null ? new RightSideEdge ( toSubgraph ) : new RightSideEdge ( toNodeId ) ; // Finally , create the Edge to return .
toReturn = fromNode == null ? new Edge ( fromSubgraph , rightSideEdge ) : new Edge ( fromNode . getNodeID ( ) , rightSideEdge ) ; } } // Add the newly created Edge , if applicable .
if ( toReturn != null ) { add ( toReturn ) ; } // All Done .
return toReturn ;


signature:
public class CheckstyleViolationCheckMojo { /** * { @ inheritDoc } */
public void execute ( ) throws MojoExecutionException , MojoFailureException { } }

implementation:
if ( skip ) { return ; } if ( ! skipExec ) { if ( checkstyleRules != null ) { if ( ! "sun_checks.xml" . equals ( configLocation ) ) { throw new MojoExecutionException ( "If you use inline configuration for rules, don't specify " + "a configLocation" ) ; } if ( checkstyleRules . getChildCount ( ) > 1 ) { throw new MojoExecutionException ( "Currently only one root module is supported" ) ; } PlexusConfiguration checkerModule = checkstyleRules . getChild ( 0 ) ; try { FileUtils . forceMkdir ( rulesFiles . getParentFile ( ) ) ; FileUtils . fileWrite ( rulesFiles , CHECKSTYLE_FILE_HEADER + checkerModule . toString ( ) ) ; } catch ( final IOException e ) { throw new MojoExecutionException ( e . getMessage ( ) , e ) ; } configLocation = rulesFiles . getAbsolutePath ( ) ; } ClassLoader currentClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { CheckstyleExecutorRequest request = new CheckstyleExecutorRequest ( ) ; request . setConsoleListener ( getConsoleListener ( ) ) . setConsoleOutput ( consoleOutput ) . setExcludes ( excludes ) . setFailsOnError ( failsOnError ) . setIncludes ( includes ) . setResourceIncludes ( resourceIncludes ) . setResourceExcludes ( resourceExcludes ) . setIncludeResources ( includeResources ) . setIncludeTestResources ( includeTestResources ) . setIncludeTestSourceDirectory ( includeTestSourceDirectory ) . setListener ( getListener ( ) ) . setProject ( project ) . setSourceDirectories ( getSourceDirectories ( ) ) . setResources ( resources ) . setTestResources ( testResources ) . setStringOutputStream ( stringOutputStream ) . setSuppressionsLocation ( suppressionsLocation ) . setTestSourceDirectories ( getTestSourceDirectories ( ) ) . setConfigLocation ( configLocation ) . setConfigurationArtifacts ( collectArtifacts ( "config" ) ) . setPropertyExpansion ( propertyExpansion ) . setHeaderLocation ( headerLocation ) . setLicenseArtifacts ( collectArtifacts ( "license" ) ) . setCacheFile ( cacheFile ) . setSuppressionsFileExpression ( suppressionsFileExpression ) . setEncoding ( encoding ) . setPropertiesLocation ( propertiesLocation ) ; checkstyleExecutor . executeCheckstyle ( request ) ; } catch ( CheckstyleException e ) { throw new MojoExecutionException ( "Failed during checkstyle configuration" , e ) ; } catch ( CheckstyleExecutorException e ) { throw new MojoExecutionException ( "Failed during checkstyle execution" , e ) ; } finally { // be sure to restore original context classloader
Thread . currentThread ( ) . setContextClassLoader ( currentClassLoader ) ; } } if ( ! "xml" . equals ( outputFileFormat ) ) { throw new MojoExecutionException ( "Output format is '" + outputFileFormat + "', checkstyle:check requires format to be 'xml'." ) ; } if ( ! outputFile . exists ( ) ) { getLog ( ) . info ( "Unable to perform checkstyle:check, unable to find checkstyle:checkstyle outputFile." ) ; return ; } Reader reader = null ; try { reader = new BufferedReader ( ReaderFactory . newXmlReader ( outputFile ) ) ; XmlPullParser xpp = new MXParser ( ) ; xpp . setInput ( reader ) ; int violations = countViolations ( xpp ) ; if ( violations > maxAllowedViolations ) { if ( failOnViolation ) { String msg = "You have " + violations + " Checkstyle violation" + ( ( violations > 1 ) ? "s" : "" ) + "." ; if ( maxAllowedViolations > 0 ) { msg += " The maximum number of allowed violations is " + maxAllowedViolations + "." ; } throw new MojoFailureException ( msg ) ; } getLog ( ) . warn ( "checkstyle:check violations detected but failOnViolation set to false" ) ; } reader . close ( ) ; reader = null ; } catch ( IOException | XmlPullParserException e ) { throw new MojoExecutionException ( "Unable to read Checkstyle results xml: " + outputFile . getAbsolutePath ( ) , e ) ; } finally { IOUtil . close ( reader ) ; }


signature:
public class CheckstyleViolationCheckMojo { /** * Checks if the given severity is considered a violation .
 * @ param severity The severity to check
 * @ return < code > true < / code > if the given severity is a violation , otherwise < code > false < / code > */
private boolean isViolation ( String severity ) { } }

implementation: if ( "error" . equals ( severity ) ) { return "error" . equals ( violationSeverity ) || "warning" . equals ( violationSeverity ) || "info" . equals ( violationSeverity ) ; } else if ( "warning" . equals ( severity ) ) { return "warning" . equals ( violationSeverity ) || "info" . equals ( violationSeverity ) ; } else if ( "info" . equals ( severity ) ) { return "info" . equals ( violationSeverity ) ; } else { return false ; }


signature:
public class CompareTool { /** * compare two snapshots from source and target maps
 * format : key : absentKeys or map */
private static Map < String , Set > compareAndAggregate ( Map sourceMap , Map targetMap ) { } }

implementation:
// keys witch values are different
System . out . println ( "compare maps" ) ; System . out . println ( "source: " + sourceMap ) ; System . out . println ( "target: " + targetMap ) ; Map < String , Set > aggregationInfo = new HashMap < String , Set > ( ) ; Set < Object > keysForDiffValues = new HashSet < Object > ( ) ; for ( Object regionKey : targetMap . keySet ( ) ) { if ( ! targetMap . get ( regionKey ) . equals ( sourceMap . get ( regionKey ) ) ) // we compare not original values , but it ' s hash code
keysForDiffValues . add ( regionKey ) ; } aggregationInfo . put ( "diffValues" , keysForDiffValues ) ; return aggregationInfo ;


signature:
public class Topic { /** * This function will take the XML in the topicXML String and use it to generate a text only view .
 * The text extraction uses Jericho - http : / / jericho . htmlparser . net / */
@ Transient public String getTopicSearchText ( ) { } }

implementation: if ( topicXML == null ) return "" ; final Source source = new Source ( topicXML ) ; source . fullSequentialParse ( ) ; return source . getTextExtractor ( ) . toString ( ) ;


signature:
public class IconTool { /** * Render a simple icon of given level .
 * @ param level one of < code > INFO < / code > , < code > WARNING < / code > or < code > ERROR < / code > constants */
public void iconSeverity ( String level ) { } }

implementation: sink . figure ( ) ; sink . figureGraphics ( "images/icon_" + level + "_sml.gif" ) ; sink . figure_ ( ) ;


signature:
public class IconTool { /** * Render an icon of given level with associated text .
 * @ param level one of < code > INFO < / code > , < code > WARNING < / code > or < code > ERROR < / code > constants
 * @ param textType one of < code > NO _ TEXT < / code > , < code > TEXT _ SIMPLE < / code > , < code > TEXT _ TITLE < / code > or
 * < code > TEXT _ ABBREV < / code > constants */
public void iconSeverity ( String level , int textType ) { } }

implementation: sink . figure ( ) ; sink . figureGraphics ( "images/icon_" + level + "_sml.gif" ) ; sink . figure_ ( ) ; if ( textType > 0 ) { sink . nonBreakingSpace ( ) ; sink . text ( bundle . getString ( "report.checkstyle." + level + suffix ( textType ) ) ) ; }


signature:
public class Project { /** * Generates a HTML formatted and categorized list of the tags that are associated with this topic
 * @ return A HTML String to display in a table */
@ Transient public String getTagsList ( final boolean brLineBreak ) { } }

implementation:
// define the line breaks for html and for tooltips
final String lineBreak = brLineBreak ? "
" : "\n" ; final String boldStart = brLineBreak ? "" : "" ; final String boldEnd = brLineBreak ? "" : "" ; final TreeMap < NameIDSortMap , ArrayList < String > > tags = new TreeMap < NameIDSortMap , ArrayList < String > > ( ) ; for ( final TagToProject tagToProject : tagToProjects ) { final Tag tag = tagToProject . getTag ( ) ; final Set < TagToCategory > tagToCategories = tag . getTagToCategories ( ) ; if ( tagToCategories . size ( ) == 0 ) { NameIDSortMap categoryDetails = new NameIDSortMap ( "Uncategorised" , - 1 , 0 ) ; if ( ! tags . containsKey ( categoryDetails ) ) tags . put ( categoryDetails , new ArrayList < String > ( ) ) ; tags . get ( categoryDetails ) . add ( tag . getTagName ( ) ) ; } else { for ( final TagToCategory category : tagToCategories ) { NameIDSortMap categoryDetails = new NameIDSortMap ( category . getCategory ( ) . getCategoryName ( ) , category . getCategory ( ) . getCategoryId ( ) , category . getCategory ( ) . getCategorySort ( ) == null ? 0 : category . getCategory ( ) . getCategorySort ( ) ) ; if ( ! tags . containsKey ( categoryDetails ) ) tags . put ( categoryDetails , new ArrayList < String > ( ) ) ; tags . get ( categoryDetails ) . add ( tag . getTagName ( ) ) ; } } } String tagsList = "" ; for ( final NameIDSortMap key : tags . keySet ( ) ) { // sort alphabetically
Collections . sort ( tags . get ( key ) ) ; if ( tagsList . length ( ) != 0 ) tagsList += lineBreak ; tagsList += boldStart + key . getName ( ) + boldEnd + ": " ; String thisTagList = "" ; for ( final String tag : tags . get ( key ) ) { if ( thisTagList . length ( ) != 0 ) thisTagList += ", " ; thisTagList += tag ; } tagsList += thisTagList + " " ; } return tagsList ;


signature:
public class AbstractCheckstyleReport { /** * { @ inheritDoc } */
public void executeReport ( final Locale locale ) throws MavenReportException { } }

implementation:
locator . addSearchPath ( FileResourceLoader . ID , project . getFile ( ) . getParentFile ( ) . getAbsolutePath ( ) ) ; locator . addSearchPath ( "url" , "" ) ; locator . setOutputDirectory ( new File ( project . getBuild ( ) . getDirectory ( ) ) ) ; // for when we start using maven - shared - io and maven - shared - monitor . . .
// locator = new Locator ( new MojoLogMonitorAdaptor ( getLog ( ) ) ) ;
// locator = new Locator ( getLog ( ) , new File ( project . getBuild ( ) . getDirectory ( ) ) ) ;
ClassLoader currentClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { CheckstyleExecutorRequest request = createRequest ( ) . setLicenseArtifacts ( collectArtifacts ( "license" ) ) . setConfigurationArtifacts ( collectArtifacts ( "configuration" ) ) ; CheckstyleResults results = checkstyleExecutor . executeCheckstyle ( request ) ; ResourceBundle bundle = getBundle ( locale ) ; generateReportStatics ( ) ; generateMainReport ( results , bundle ) ; if ( enableRSS ) { CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest = new CheckstyleRssGeneratorRequest ( this . project , this . getCopyright ( ) , outputDirectory , getLog ( ) ) ; checkstyleRssGenerator . generateRSS ( results , checkstyleRssGeneratorRequest ) ; } } catch ( CheckstyleException e ) { throw new MavenReportException ( "Failed during checkstyle configuration" , e ) ; } catch ( CheckstyleExecutorException e ) { throw new MavenReportException ( "Failed during checkstyle execution" , e ) ; } finally { // be sure to restore original context classloader
Thread . currentThread ( ) . setContextClassLoader ( currentClassLoader ) ; }


signature:
public class CSNode { /** * Sets the Next Node and cleans up any old references .
 * @ param next The next node . */
@ Transient public void setNextAndClean ( CSNode next ) { } }

implementation: setNextInternal ( next ) ; if ( next != null ) { next . setPreviousInternal ( this ) ; }


signature:
public class CSNode { /** * Sets the Previous Node and cleans up any old references .
 * @ param previous The previous node . */
@ Transient public void setPreviousAndClean ( CSNode previous ) { } }

implementation: setPreviousInternal ( previous ) ; if ( previous != null ) { previous . setNextInternal ( this ) ; }


signature:
public class EnversUtilities { /** * When returning a collection of entity revisions , the lastModified property is set automatically ( in the getRevision
 * method ) . For entities returned from a database query , the last modified date needs to be found manually .
 * @ return either the date saved in the lastModified property , or the latest revision date if lastModified is null */
public static < T extends AuditedEntity > Date getFixedLastModifiedDate ( final EntityManager entityManager , final T entity ) { } }

implementation: return entity . getLastModifiedDate ( ) != null ? entity . getLastModifiedDate ( ) : getLatestRevisionDate ( entityManager , entity ) ;


signature:
public class NodesContainer { /** * Finds the node by host and port .
 * @ param host
 * - the host .
 * @ param port
 * - the port .
 * @ return - the found node , or null otherwise . */
public Node find ( String host , int port ) { } }

implementation: return socketToNodeMap . get ( Utils . toKey ( host , port ) ) ;


signature:
public class NodesContainer { /** * Finds the set of nodes by host .
 * @ param host
 * - the host .
 * @ return - the found nodes . */
public Set < Node > find ( String host ) { } }

implementation: Set < Node > resultSet = new HashSet < Node > ( ) ; if ( host != null ) { for ( Node node : socketToNodeMap . values ( ) ) { if ( host . equals ( node . getHost ( ) ) ) { resultSet . add ( node ) ; } } } return resultSet ;


signature:
public class NodesContainer { /** * Gets all the nodes not in status DEAD .
 * @ return - all the nodes not in status DEAD . */
public Set < Node > getAllNotDead ( ) { } }

implementation: Set < Node > allNotDeadNodesSet = new HashSet < Node > ( ) ; for ( Node node : socketToNodeMap . values ( ) ) { if ( ! NodeStatus . DEAD . equals ( node . getStatus ( ) ) ) { allNotDeadNodesSet . add ( node ) ; } } return allNotDeadNodesSet ;


signature:
public class NodesContainer { /** * Adds one more node to the container .
 * @ param node
 * - the node . */
public void add ( Node node ) { } }

implementation: socketToNodeMap . put ( Utils . toKey ( node ) , node ) ; sendEvent ( node , NodeEventType . ADDED ) ;


signature:
public class NodesContainer { /** * Removes the specified node .
 * @ param node
 * - the node . */
public void remove ( Node node ) { } }

implementation: socketToNodeMap . remove ( Utils . toKey ( node ) ) ; sendEvent ( node , NodeEventType . REMOVED ) ;


signature:
public class NodesContainer { /** * Marks the node as ALIVE in case of its status is not ALIVE .
 * @ param node
 * - the node . */
public void markAsAlive ( Node node ) { } }

implementation: if ( ! NodeStatus . ALIVE . equals ( node . getStatus ( ) ) ) { socketToNodeMap . get ( Utils . toKey ( node ) ) . markAsAlive ( ) ; sendEvent ( node , NodeEventType . MARKED_AS_ALIVE ) ; }


signature:
public class NodesContainer { /** * Marks the node as DEAD in case of its status is not DEAD .
 * @ param node
 * - the node . */
public void markAsDead ( Node node ) { } }

implementation: if ( ! NodeStatus . DEAD . equals ( node . getStatus ( ) ) ) { socketToNodeMap . get ( Utils . toKey ( node ) ) . markAsDead ( ) ; sendEvent ( node , NodeEventType . MARKED_AS_DEAD ) ; }


signature:
public class NodesContainer { /** * Sends the event to all the handlers .
 * @ param node
 * - the event node .
 * @ param type
 * - the event type . */
private void sendEvent ( Node node , NodeEventType type ) { } }

implementation: NodeEvent event = new NodeEvent ( node , type ) ; for ( NodeEventHandler handler : handlers ) { handler . handle ( event ) ; }


signature:
public class AbstractGraphConverter { /** * Retrieves an { @ link AbstractStatementConverter } subclass which can convert the given Concept
 * class into a { @ link Statement } . Null arguments are not permitted .
 * @ param conceptClass The class to convert into a Statement .
 * @ param < Concept > The type to convert .
 * @ param < S > The Statement subclass .
 * @ return The { @ link AbstractStatementConverter } subclass which manages the conversion - or null should none exist . */
public < Concept , S extends Statement > AbstractStatementConverter < Concept , S > get ( final Class < Concept > conceptClass ) { } }

implementation:
// Check sanity
if ( conceptClass == null ) { throw new NullPointerException ( "Cannot handle null 'conceptClass' argument." ) ; } // Fetch stashed converters
final AbstractStatementConverter < Concept , S > toReturn = statementConverters . get ( conceptClass ) ; if ( toReturn == null && log . isDebugEnabled ( ) ) { log . debug ( "No AbstractStatementConverter to convert [" + conceptClass . getName ( ) + "] into a Statement subtype was registered." ) ; } // All Done .
return toReturn ;


signature:
public class AbstractGraphConverter { /** * Adds the supplied { @ link AbstractStatementConverter } for the given Concept class .
 * Null arguments are not permitted .
 * @ param converter The Converter to add .
 * @ param conceptClass The class to convert into a Statement .
 * @ param < Concept > The type to convert .
 * @ param < S > The Statement subclass . */
public < Concept , S extends Statement > void put ( final Class < Concept > conceptClass , final AbstractStatementConverter < Concept , S > converter ) { } }

implementation:
// Check sanity
if ( conceptClass == null ) { throw new NullPointerException ( "Cannot handle null 'conceptClass' argument." ) ; } if ( converter == null ) { throw new NullPointerException ( "Cannot handle null 'converter' argument." ) ; }


signature:
public class AbstractGraphConverter { /** * { @ inheritDoc } */
@ Override public final Graph convert ( final From toConvert ) { } }

implementation:
// Handle nulls
if ( toConvert == null && ! acceptsNullValues ( ) ) { throw new IllegalArgumentException ( "Converter [" + getClass ( ) . getName ( ) + "] cannot accept null 'toConvert' arguments." ) ; } // All Done
return doConvert ( toConvert ) ;


signature:
public class DefaultCheckstyleExecutor { /** * Get the effective Checkstyle version at runtime .
 * @ return the MANIFEST implementation version of Checkstyle API package ( can be < code > null < / code > )
 * @ todo Copied from CheckstyleReportGenerator - move to a utility class */
private String getCheckstyleVersion ( ) { } }

implementation: Package checkstyleApiPackage = Configuration . class . getPackage ( ) ; return ( checkstyleApiPackage == null ) ? null : checkstyleApiPackage . getImplementationVersion ( ) ;


signature:
public class DefaultCheckstyleExecutor { /** * Configures search paths in the resource locator .
 * This method should only be called once per execution .
 * @ param request executor request data . */
private void configureResourceLocator ( final ResourceManager resourceManager , final CheckstyleExecutorRequest request , final List < Artifact > additionalArtifacts ) { } }

implementation:
final MavenProject project = request . getProject ( ) ; resourceManager . setOutputDirectory ( new File ( project . getBuild ( ) . getDirectory ( ) ) ) ; // Recurse up the parent hierarchy and add project directories to the search roots
MavenProject parent = project ; while ( parent != null && parent . getFile ( ) != null ) { // MCHECKSTYLE - 131 ( olamy ) I don ' t like this hack .
// ( dkulp ) Me either . It really pollutes the location stuff
// by allowing searches of stuff outside the current module .
File dir = parent . getFile ( ) . getParentFile ( ) ; resourceManager . addSearchPath ( FileResourceLoader . ID , dir . getAbsolutePath ( ) ) ; parent = parent . getParent ( ) ; } resourceManager . addSearchPath ( "url" , "" ) ; // MCHECKSTYLE - 225 : load licenses from additional artifacts , not from classpath
if ( additionalArtifacts != null ) { for ( Artifact licenseArtifact : additionalArtifacts ) { try { // MCHECKSTYLE - 287 , MCHECKSTYLE - 294 : Ignore null licenseArtifacts . . .
if ( licenseArtifact != null ) { if ( getLogger ( ) . isDebugEnabled ( ) ) { getLogger ( ) . debug ( "Adding licenceArtifact [" + licenseArtifact . getGroupId ( ) + ":" + licenseArtifact . getArtifactId ( ) + ":" + licenseArtifact . getVersion ( ) + "] to resourceManager." ) ; } resourceManager . addSearchPath ( "jar" , "jar:" + licenseArtifact . getFile ( ) . toURI ( ) . toURL ( ) ) ; } } catch ( MalformedURLException e ) { // noop
} } }


signature:
public class VisualizationDoclet { /** * { @ inheritDoc } */
@ Override public boolean start ( final RootDoc root ) { } }

implementation:
// Check sanity
if ( this . dotFacade == null ) { throw new IllegalStateException ( "The DotFacade cannot be null." ) ; } // Wrap the received RootDoc instance .
final VisualizationWrappedRootDoc rootDoc = new VisualizationWrappedRootDoc ( root ) ; htmlDoclet . configuration . root = root ; try { htmlDoclet . configuration . setOptions ( ) ; } catch ( Configuration . Fault fault ) { fault . printStackTrace ( ) ; } for ( ClassDoc cDoc : rootDoc . classes ( ) ) { // Log somewhat
if ( log . isDebugEnabled ( ) ) { log . debug ( getJavaDocAndTagsLog ( cDoc ) ) ; } } for ( PackageDoc pDoc : rootDoc . specifiedPackages ( ) ) { // Log somewhat
if ( log . isDebugEnabled ( ) ) { log . debug ( getJavaDocAndTagsLog ( pDoc ) ) ; } } // Convert the DOT - generated Map and write the image .
// dotFacade . writePngImageAndImageMap ( rootDoc , theDotDiagram , outputDirectory , fileName ) ;
// Delegate further execution to the standard Doclet .
return HtmlDoclet . start ( root ) ;


signature:
public class VisualizationDoclet { /** * { @ inheritDoc } */
@ Override public boolean validateJavaDocOptions ( final String [ ] [ ] options , final DocErrorReporter errorReporter ) { } }

implementation:
// This Visualization Doclet recognizes no special options .
// Simply delegate to the standard doclet .
try { htmlDoclet . sharedInstanceForOptions . setOptions ( options ) ; } catch ( Configuration . Fault fault ) { fault . printStackTrace ( ) ; } // All done ?
return HtmlDoclet . validOptions ( options , errorReporter ) ;


signature:
public class VisualizationDoclet { /** * { @ inheritDoc } */
@ Override public int optionLength ( final String option ) { } }

implementation:
// #1 ) Handle the - help option .
if ( JavaDocOption . HELP . getOption ( ) . equals ( option ) ) { // First , provide the help text from the Standard Doclet .
final int toReturn = HtmlDoclet . optionLength ( option ) ; // Print the options provided by VisualizationDoclet .
System . out . println ( ) ; System . out . println ( "Provided by " + VisualizationDoclet . class . getName ( ) + ":" ) ; for ( JavaDocOption current : JavaDocOption . values ( ) ) { if ( current != JavaDocOption . HELP ) { System . out . println ( current . getOption ( ) + " " + current . getHelpText ( ) ) ; } } // Delegate to the standard Doclet implementation .
return toReturn ; } // #2 ) Handle all JavaDoc options known to this Doclet
for ( JavaDocOption current : JavaDocOption . values ( ) ) { if ( current . getOption ( ) . equals ( option ) ) { return current . getOptionLength ( ) ; } } // #3 ) Delegate to the standard Doclet .
return HtmlDoclet . optionLength ( option ) ;


signature:
public class ObjectFactory { /** * Build object .
 * @ return */
public T build ( Object ... attributes ) { } }

implementation:
List < Object > attributeList = new ArrayList < Object > ( Arrays . asList ( attributes ) ) ; // kinda wacky but Arrays . asList returns a unmodifiable list
String [ ] traitNames = getTraitNames ( attributeList ) ; applyTraits ( traitNames ) ; T object = ReflectionUtils . createObject ( factoryClass , constructorArgs ) ; // merge default properties with supplied attributes
Map < String , Object > propertyValues = createObjectPropertyValues ( this . propertyValues , attributeList ) ; // now set properties and fields to the created object
setProperties ( object , propertyValues ) ; setFields ( object , fieldValues ) ; executeCallbacks ( AfterFactoryBuild . class , object ) ; return object ;


signature:
public class ObjectFactory { /** * Private methods * */
private void setProperty ( Object target , String name , Object value ) { } }

implementation:
if ( ! ReflectionUtils . setProperty ( target , name , getValue ( value ) ) ) { // no property was found , try to set the field directly
setField ( target , name , value ) ; }


signature:
public class ObjectFactory { /** * Merge passed attributes with the supplied property values .
 * @ param defaultPropertyValues
 * @ param attributes
 * @ return */
private Map < String , Object > createObjectPropertyValues ( Map < String , Object > defaultPropertyValues , List < Object > attributes ) { } }

implementation:
Map < String , Object > propertyValues = new HashMap < String , Object > ( defaultPropertyValues ) ; if ( attributes != null ) { Iterator < Object > iterator = attributes . iterator ( ) ; Map < String , Object > propertyOverrideMap = new HashMap < String , Object > ( ) ; while ( iterator . hasNext ( ) ) { String name = ( String ) iterator . next ( ) ; // we can only create a map entry if we have both a key and value , so make sure there ' s a value left
if ( iterator . hasNext ( ) ) { Object object = iterator . next ( ) ; propertyOverrideMap . put ( name , object ) ; } } propertyValues . putAll ( propertyOverrideMap ) ; } return propertyValues ;


signature:
public class ObjectFactory { /** * Retrieve the current sequence value for the given property .
 * @ param name name of the property that should be assigned the sequence value .
 * @ return The current value of the referenced sequence . */
private int currentSequence ( String name ) { } }

implementation: Map < String , Integer > sequencesForClass = sequences . get ( getClass ( ) ) ; if ( sequencesForClass == null ) { sequencesForClass = new HashMap < String , Integer > ( ) ; sequences . put ( getClass ( ) , sequencesForClass ) ; } Integer seq = sequencesForClass . get ( name ) ; seq = seq == null ? 1 : seq + 1 ; sequencesForClass . put ( name , seq ) ; return seq ;


signature:
public class SubgraphRenderer { /** * { @ inheritDoc } */
@ Override protected String doRender ( final RenderConfiguration config , final Subgraph subgraph ) { } }

implementation:
final String prologue = config . getIndent ( ) + "subgraph " + quote ( subgraph . getId ( ) ) + " { " + config . getNewline ( ) ; // Render the statements within this subgraph .
final Statements statements = subgraph . getStatements ( ) ; final StatementsRenderer statementsRenderer = new StatementsRenderer ( ) ; final String renderedStatements = statementsRenderer . render ( config . cloneAndChangeIndentation ( 1 ) , statements ) ; // All Done .
return prologue + renderedStatements + config . getNewline ( ) + config . getIndent ( ) + "}" ;


signature:
public class CommonNodeAttributesRenderer { /** * { @ inheritDoc } */
@ Override protected String doRender ( final RenderConfiguration config , final CommonNodeAttributes entity ) { } }

implementation: return config . getIndent ( ) + entity . getId ( ) + " " + attributeRenderer . render ( config , entity . getAttributes ( ) ) ;


signature:
public class PackageDocConverter { /** * { @ inheritDoc } */
@ Override protected Graph doConvert ( final Set < ClassDoc > toConvert ) { } }

implementation:
final ClassDoc [ ] clDocs = toConvert . toArray ( new ClassDoc [ toConvert . size ( ) ] ) ; final SortedMap < PackageDoc , SortedSet < ClassDoc > > clPerPackage = Comparators . sortClassesPerPackage ( clDocs ) ; final Map . Entry < PackageDoc , SortedSet < ClassDoc > > packageAndClasses = clPerPackage . entrySet ( ) . stream ( ) . filter ( e -> relevantPackage . getName ( ) . equalsIgnoreCase ( e . getKey ( ) . name ( ) ) ) . findFirst ( ) . orElseThrow ( ( ) -> new IllegalStateException ( "No retrieved classes in expected package [" + relevantPackage . getName ( ) + "]. Found: " + clPerPackage . keySet ( ) . stream ( ) . map ( Doc :: name ) . reduce ( ( l , r ) -> l + ", r" ) . orElse ( "<none>" ) ) ) ; final PackageDoc packageDoc = packageAndClasses . getKey ( ) ; final SortedSet < ClassDoc > classDocs = packageAndClasses . getValue ( ) ; // Create the Graph .
final Graph toReturn = new Graph ( "Graph_" + packageDoc . name ( ) , true , true ) ; final Subgraph packageSubgraph = new Subgraph ( packageDoc . name ( ) ) ; final CommonGraphAttributes subgraphAttrs = new CommonGraphAttributes ( ) ; packageSubgraph . add ( subgraphAttrs ) ; final GraphAttributes subAttrs = subgraphAttrs . getAttributes ( ) ; subAttrs . label = "Package: " + packageDoc . name ( ) ; // Add a Subgraph for the package
toReturn . add ( renderPackageSubGraph ( classDocs ) ) ; // All Done .
return toReturn ;


signature:
public class NodeID { /** * Compares the supplied NodeID to this one .
 * @ param that A NodeID to compare to this one .
 * @ return THe difference in */
@ Override public int compareTo ( final NodeID that ) { } }

implementation:
// Fail fast
if ( that == this ) { return 0 ; } else if ( null == that ) { return - 1 ; } // Delegate to internal state
return this . getId ( ) . compareTo ( that . getId ( ) ) ;


signature:
public class BufferedNodeEventHandler { /** * Gets the copy of the buffer and clears the buffer .
 * @ return - the copy of events since the last call of this method . */
public List < NodeEvent > getAndClearEventslist ( ) { } }

implementation: ArrayList < NodeEvent > result = new ArrayList < NodeEvent > ( eventslist ) ; eventslist . clear ( ) ; return result ;


signature:
public class VisualizationWrappedRootDoc { /** * Checks if ths supplied message contains an { @ link VisualizationDocletTag } reference , on the form
 * { @ code ' @ nazgul _ vis . xxxx ' } .
 * @ param message The message to check .
 * @ return { @ code true } if the supplied message contains a { @ link VisualizationDocletTag } reference . */
public static boolean containsVisualizationDocletTag ( final String message ) { } }

implementation:
if ( message != null ) { for ( VisualizationDocletTag current : VisualizationDocletTag . values ( ) ) { if ( message . contains ( current . toString ( ) + " " ) ) { // The message contains an entry on the form ' @ nazgul _ vis . xxxx '
// which implies that it has to do with a VisualizationDoclet javadoc Tag .
return true ; } } } // Nopes .
return false ;


signature:
public class VisualizationWrappedRootDoc { /** * Finds all PackageDoc objects from the classes in this JavaDoc execution .
 * @ return a non - null ( but possibly empty ) SortedSet containing all { @ link PackageDoc } s from the current execution . */
public SortedSet < PackageDoc > findPackagesFromClassesInJavaDocRun ( ) { } }

implementation:
final SortedSet < PackageDoc > toReturn = new TreeSet < > ( Comparators . PACKAGE_NAME_COMPARATOR ) ; final ClassDoc [ ] currentExecutionClasses = classes ( ) ; if ( currentExecutionClasses != null ) { Arrays . stream ( currentExecutionClasses ) . map ( ProgramElementDoc :: containingPackage ) . forEach ( toReturn :: add ) ; } // All Done .
return toReturn ;


signature:
public class Introspector { /** * - - - - - PUBLIC */
public static void checkClassIsSerialized ( final Class < ? > clazz ) throws InvalidClassException { } }

implementation:
// class
checkClassIsAnnotationMarked ( clazz ) ; checkClassIsPublic ( clazz ) ; checkClassIsNotNested ( clazz ) ; // constructor
Constructor < ? > constructor = checkConstructorNoArg ( clazz ) ; checkConstructorPublic ( constructor ) ; checkConstructorWithoutExceptions ( constructor ) ; checkParentConstructor ( clazz ) ; // getters
Map < String , Method > gettersMap = getPropertyGetters ( clazz ) ; for ( Map . Entry < String , Method > getterEntry : gettersMap . entrySet ( ) ) { Method getter = getterEntry . getValue ( ) ; checkGetterPublic ( getter ) ; checkGetterNoArg ( getter ) ; checkGetterWithoutExceptions ( getter ) ; Method setter = getSetterForGetter ( clazz , getter ) ; checkSetterPublic ( setter ) ; checkSetterOneArg ( setter ) ; checkSetterReturnVoid ( setter ) ; checkSetterWithoutExceptions ( setter ) ; checkGetterSetterTheSameType ( getter , setter ) ; }


signature:
public class Introspector { /** * Checks if parent class ( if exists ) is annotated as AutoSerializable , or have parameterless public constructor .
 * @ param clazz
 * @ throws java . io . InvalidClassException */
protected static void checkParentConstructor ( Class < ? > clazz ) throws InvalidClassException { } }

implementation: if ( clazz != Object . class ) { Class < ? > parentClazz = clazz . getSuperclass ( ) ; try { checkConstructorNoArg ( parentClazz ) ; } catch ( InvalidClassException e ) { checkClassIsAnnotationMarked ( parentClazz ) ; } }


signature:
public class Introspector { /** * 1 ) move hierarchy up
 * 2 ) look for method with name
 * 3 ) check @ TransientGetter
 * @ param clazz
 * @ return */
protected static Map < String , Method > getPropertyGetters ( Class < ? > clazz ) { } }

implementation:
// todo : clazz . getDeclaredMethods ( ) + hierarchy up OR clazz . getMethods ( ) ?
Map < String , Method > result = new HashMap < String , Method > ( ) ; if ( clazz != Object . class ) { Method [ ] methodArr = clazz . getMethods ( ) ; for ( Method method : methodArr ) { if ( isNameSuitableForGetter ( method ) ) { if ( method . getDeclaringClass ( ) != Object . class && ! method . isBridge ( ) ) { // remove Object . getClass ( )
final Annotation [ ] annArr = method . getDeclaredAnnotations ( ) ; boolean find = false ; for ( Annotation ann : annArr ) { if ( ann . annotationType ( ) == Transient . class ) { find = true ; break ; } } if ( ! find ) { String fieldName ; if ( method . getReturnType ( ) == Boolean . TYPE && method . getName ( ) . startsWith ( "is" ) ) fieldName = method . getName ( ) . substring ( 2 , 3 ) . toLowerCase ( ) + method . getName ( ) . substring ( 3 ) ; else fieldName = method . getName ( ) . substring ( 3 , 4 ) . toLowerCase ( ) + method . getName ( ) . substring ( 4 ) ; result . put ( fieldName , method ) ; } } } } clazz = clazz . getSuperclass ( ) ; } return result ;


signature:
public class DataSerializerGenerator { /** * 2 - stage compilation scheme of group of classes : < p > hack from
 * http : / / www . csg . is . titech . ac . jp / ~ chiba / javassist / tutorial / tutorial2 . html # add < p > order of return of
 * serializer - classes in response corresponds to order of arg - classes */
public static synchronized List < Class < ? > > generateDataSerializerClasses ( ClassLoader classLoader , List < Class < ? > > classList , String outputDir ) throws CannotCompileException , InvalidClassException { } }

implementation:
checkClassesValid ( classList ) ; List < CtClass > dataSerializerClassList = new ArrayList < CtClass > ( ) ; // create new ClassPool for every method call
// 1 ) low memory consumption - any caches with internal data structures of created classes
// 2 ) any collision between methods called serially - all crated classes are forgotten
// 3 ) any references on created classes from this lib
ClassPool classPool = newClassPool ( classLoader ) ; // #1 : create dataSerializers with stubs toData / fromData
for ( Class < ? > clazz : classList ) { String serializerClsName = createDataSerializerClassNameForClass ( clazz ) ; if ( existsClass ( serializerClsName , classLoader ) ) { logger . debug ( "Serializer for class {} exists. Skipping generation" , clazz . getName ( ) ) ; break ; } // create class
CtClass cc = createClass ( classPool , clazz , serializerClsName ) ; dataSerializerClassList . add ( cc ) ; // add static Register
addStaticConstruct ( clazz , cc , serializerClsName ) ; // add methods
addMethodGetId ( clazz , cc ) ; addMethodGetSupportedClasses ( clazz , cc ) ; // add stub - methods toData / fromData
addMethodToDataStub ( clazz , cc ) ; addMethodFromDataStub ( clazz , cc ) ; // we need this for Javassist do some magic with CtClass
try { cc . toBytecode ( ) ; } catch ( IOException e ) { throw new CannotCompileException ( "Error during end of compilation phase #1 (call CtClass.toBytecode() for some Javassist-magic with CtClass) for " + cc . getName ( ) , e ) ; } catch ( CannotCompileException e ) { throw new CannotCompileException ( "Error during end of compilation phase #1 (call CtClass.toBytecode() for some Javassist-magic with CtClass) for " + cc . getName ( ) , e ) ; } } List < Class < ? > > result = new ArrayList < Class < ? > > ( ) ; // #2 : change stubs toData / fromData in dataSerializers - > real methods
for ( int k = 0 ; k < classList . size ( ) ; k ++ ) { Class < ? > clazz = classList . get ( k ) ; CtClass cc = dataSerializerClassList . get ( k ) ; // make changing methods real : defrost CtClass
cc . defrost ( ) ; // change stub toData / fromData - > real methods
addMethodToData ( clazz , cc ) ; addMethodFromData ( clazz , cc ) ; // generate result
final Class < ? > resultClass ; try { resultClass = cc . toClass ( classLoader , null ) ; // ProtectionDomain = = null
logger . info ( "compiled data serializer for class: {}; id: {}; version: {}" , new Object [ ] { clazz , clazz . getAnnotation ( AutoSerializable . class ) . dataSerializerID ( ) , clazz . getAnnotation ( BeanVersion . class ) . value ( ) } ) ; if ( ( outputDir != null ) && ( outputDir . length ( ) > 0 ) ) { try { cc . writeFile ( outputDir ) ; } catch ( IOException e ) { throw new RuntimeException ( "couldn't save DataSerializer for class " + clazz . getName ( ) , e ) ; } } } catch ( CannotCompileException e ) { throw new CannotCompileException ( "Error during end of compilation phase #2 (call CtClass.toClass()) for " + cc . getName ( ) + ". Probably you second time try generate and load DataSerializer class " + cc . getName ( ) + " for class " + clazz . getName ( ) , e ) ; } // dump code to listener
if ( listener != null ) { listener . generated ( clazz . getName ( ) , cc . getName ( ) , new ClassProcessor ( ) . process ( new XClass ( clazz ) , cc . getName ( ) ) ) ; } result . add ( resultClass ) ; } return result ;


signature:
public class DataSerializerGenerator { /** * TODO .
 * @ param clsName
 * @ param clsLoader
 * @ return */
private static boolean existsClass ( String clsName , ClassLoader clsLoader ) { } }

implementation: String resource = clsName . replace ( '.' , '/' ) ; return clsLoader . getResource ( resource ) != null ;


signature:
public class DataSerializerGenerator { /** * - - - - - PRIVATE */
private static void checkClassesValid ( List < Class < ? > > classList ) throws InvalidClassException { } }

implementation:
// check classes is valid for generating DataSerializer , if not - throw NotSerializableException with detailed
// reason
for ( Class < ? > clazz : classList ) { Introspector . checkClassIsSerialized ( clazz ) ; } // check classes do not contain duplicated @ AutoSerializable . dataSerializerID
checkDataSerializerIDIsUnique ( classList ) ;


signature:
public class ValidateProjectType { /** * Delegate method , implemented by concrete subclasses .
 * @ param project The active MavenProject .
 * @ param helper The EnforcerRuleHelper instance , from which the MavenProject has been retrieved .
 * @ throws se . jguru . nazgul . tools . codestyle . enforcer . rules . RuleFailureException If the enforcer rule
 * was not satisfied . */
@ Override @ SuppressWarnings ( "PMD.PreserveStackTrace" ) protected void performValidation ( final MavenProject project , final EnforcerRuleHelper helper ) throws RuleFailureException { } }

implementation: try { ProjectType . getProjectType ( project ) ; } catch ( IllegalArgumentException e ) { throw new RuleFailureException ( e . getMessage ( ) ) ; }