signature:
public class Numbers { /** * Returns the maximum of the given values .
 * @ param values a non - empty array of { @ code long } values .
 * @ return the maximum of the given values .
 * @ throws NullPointerException if { @ code values } is { @ code null } .
 * @ throws IllegalArgumentException if { @ code values } is empty . */
public static long max ( long ... values ) { } }

implementation: Parameters . checkCondition ( values . length > 0 ) ; long max = values [ 0 ] ; for ( int i = 1 ; i < values . length ; i ++ ) { max = Math . max ( max , values [ i ] ) ; } return max ;


signature:
public class Numbers { /** * Returns the minimum of the given values .
 * @ param values a non - empty array of { @ code long } values .
 * @ return the minimum of the given values .
 * @ throws NullPointerException if { @ code values } is { @ code null } .
 * @ throws IllegalArgumentException if { @ code values } is empty . */
public static long min ( long ... values ) { } }

implementation: Parameters . checkCondition ( values . length > 0 ) ; long min = values [ 0 ] ; for ( int i = 1 ; i < values . length ; i ++ ) { min = Math . min ( min , values [ i ] ) ; } return min ;


signature:
public class Numbers { /** * Returns the arithmetic mean of the given values . This method is not
 * subject to overflow .
 * @ param values the values .
 * @ return the arithmetic mean of the given values .
 * @ throws NullPointerException if { @ code values } is { @ code null } .
 * @ throws IllegalArgumentException if { @ code values } is empty . */
public static double mean ( int ... values ) { } }

implementation: Parameters . checkCondition ( values . length > 0 ) ; long sum = 0L ; for ( int value : values ) { sum += value ; } return ( double ) sum / values . length ;


signature:
public class Numbers { /** * Returns the arithmetic mean of the given values . This method is not
 * subject to overflow .
 * @ param values the values .
 * @ return the arithmetic mean of the given values .
 * @ throws NullPointerException if { @ code values } is { @ code null } .
 * @ throws IllegalArgumentException if { @ code values } is empty . */
public static double mean ( long ... values ) { } }

implementation: Parameters . checkCondition ( values . length > 0 ) ; BigDecimal sum = BigDecimal . ZERO ; for ( long value : values ) { sum = sum . add ( BigDecimal . valueOf ( value ) ) ; } return sum . divide ( BigDecimal . valueOf ( values . length ) ) . doubleValue ( ) ;


signature:
public class Numbers { /** * Returns the absolute value of the given value , provided the result
 * fits into a { @ code long } .
 * @ param a the value .
 * @ return the absolute value of { @ code a } .
 * @ throws ArithmeticException if the absolute value of { @ code a } can ' t
 * be represented by a { @ code long } . */
public static long safeAbs ( long a ) { } }

implementation: if ( a == Long . MIN_VALUE ) { throw new ArithmeticException ( "Long overflow: abs(" + a + ")" ) ; } return Math . abs ( a ) ;


signature:
public class Numbers { /** * Returns the absolute value of the given value , provided the result
 * fits into an { @ code int } .
 * @ param a the value .
 * @ return the absolute value of { @ code a } .
 * @ throws ArithmeticException if the absolute value of { @ code a } can ' t
 * be represented by an { @ code int } . */
public static int safeAbs ( int a ) { } }

implementation: if ( a == Integer . MIN_VALUE ) { throw new ArithmeticException ( "Int overflow: abs(" + a + ")" ) ; } return Math . abs ( a ) ;


signature:
public class Numbers { /** * Returns the difference of { @ code a } and { @ code b } , provided the
 * result fits into a { @ code long } .
 * @ param a the first operand .
 * @ param b the second operand .
 * @ return { @ code a - b } .
 * @ throws ArithmeticException if { @ code a - b } can ' t be represented by
 * a { @ code long } . */
public static long safeSubtract ( long a , long b ) { } }

implementation: long diff = a - b ; if ( a < 0L != diff < 0L && a < 0L != b < 0L ) { throw new ArithmeticException ( "Long overflow: " + a + " - " + b ) ; } return diff ;


signature:
public class Numbers { /** * Returns the product of { @ code a } and { @ code b } , provided the result
 * fits into a { @ code long } .
 * @ param a the first operand .
 * @ param b the second operand .
 * @ return { @ code a * b } .
 * @ throws ArithmeticException if { @ code a * b } can ' t be represented by
 * a { @ code long } . */
public static long safeMultiply ( long a , long b ) { } }

implementation: if ( a == 0L || b == 0L ) { return 0L ; } long max = a < 0L == b < 0L ? Long . MAX_VALUE : Long . MIN_VALUE ; if ( ( b > 0L && b > max / a ) || ( b < 0L && b < max / a ) ) { throw new ArithmeticException ( "Long overflow: " + a + " * " + b ) ; } return a * b ;


signature:
public class Numbers { /** * Returns the product of { @ code a } and { @ code b } , provided the result
 * fits into an { @ code int } .
 * @ param a the first operand .
 * @ param b the second operand .
 * @ return { @ code a * b } .
 * @ throws ArithmeticException if { @ code a * b } can ' t be represented by
 * an { @ code int } . */
public static int safeMultiply ( int a , int b ) { } }

implementation: if ( a == 0 || b == 0 ) { return 0 ; } long max = a < 0 == b < 0 ? Integer . MAX_VALUE : Integer . MIN_VALUE ; if ( ( b > 0 && b > max / a ) || ( b < 0 && b < max / a ) ) { throw new ArithmeticException ( "Int overflow: " + a + " * " + b ) ; } return a * b ;


signature:
public class Numbers { /** * Returns the result of the integer division of the first number by the
 * second , provided the result fits into a { @ code long } .
 * @ param a the dividend .
 * @ param b the divisor .
 * @ return { @ code a / b } .
 * @ throws ArithmeticException if { @ code b } is equal to { @ code 0 } or if
 * { @ code a / b } can ' t be represented by a { @ code long } . */
public static long safeDivide ( long a , long b ) { } }

implementation: if ( a == Long . MIN_VALUE && b == - 1L ) { throw new ArithmeticException ( "Long overflow: " + a + " / " + b ) ; } return a / b ;


signature:
public class Numbers { /** * Returns the result of the integer division of the first number by the
 * second , provided the result fits into an { @ code int } .
 * @ param a the dividend .
 * @ param b the divisor .
 * @ return { @ code a / b } .
 * @ throws ArithmeticException if { @ code b } is equal to { @ code 0 } or if
 * { @ code a / b } can ' t be represented by an { @ code int } . */
public static int safeDivide ( int a , int b ) { } }

implementation: if ( a == Integer . MIN_VALUE && b == - 1L ) { throw new ArithmeticException ( "Int overflow: " + a + " / " + b ) ; } return a / b ;


signature:
public class Numbers { /** * Returns the value of the first argument raised to the power of the
 * second , provided the result fits into a { @ code long } . This method
 * implements the exponentiation by squaring method . Please refer to
 * < a href = " http : / / en . wikipedia . org / wiki / Exponentiation _ by _ squaring " >
 * Wikipedia < / a > for further information .
 * @ param a the base .
 * @ param b the exponent .
 * @ return { @ code a ^ b } .
 * @ throws IllegalArgumentException if { @ code b < 0 } .
 * @ throws ArithmeticException if { @ code a ^ b } can ' t be represented by
 * a { @ code long } . */
public static long safePow ( long a , int b ) { } }

implementation: Parameters . checkCondition ( b >= 0 ) ; if ( b == 0 ) { return 1L ; } long base = a ; int exponent = b ; long result = 1L ; try { while ( exponent > 1 ) { if ( ( exponent & 1 ) != 0 ) { result = safeMultiply ( result , base ) ; exponent -= 1 ; } base = safeMultiply ( base , base ) ; exponent >>= 1 ; } return safeMultiply ( result , base ) ; } catch ( ArithmeticException e ) { throw new ArithmeticException ( "Long overflow: " + a + " ^ " + b ) ; }


signature:
public class Numbers { /** * Returns the greatest common divisor of the absolute value of the
 * given two numbers . This method first computes the absolute values of
 * the given numbers , thus it doesn ' t accept { @ code Long . MIN _ VALUE } .
 * Also , note that if one of the given values is { @ code 0 } , this method
 * will return the absolute value of the second argument .
 * This method implements the binary GCD algorithm ( also known as
 * Stein ' s algorithm ) . For further information on this algorithm , please
 * refer to < a href = " http : / / en . wikipedia . org / wiki / Binary _ GCD _ algorithm " >
 * Wikipedia < / a > .
 * @ param a the first number .
 * @ param b the second number .
 * @ return the greatest common divisor of { @ code a } and { @ code b } .
 * @ throws ArithmeticException if { @ code a } or { @ code b } is equal to
 * { @ code Long . MIN _ VALUE } . */
public static long gcd ( long a , long b ) { } }

implementation: if ( a < 0L || b < 0L ) { try { return gcd ( safeAbs ( a ) , safeAbs ( b ) ) ; } catch ( ArithmeticException e ) { throw new ArithmeticException ( "Long overflow: gcd(" + a + ", " + b + ")" ) ; } } if ( a == 0L ) { return b ; } if ( b == 0L ) { return a ; } int shift = 0 ; while ( ( ( a | b ) & 1L ) == 0 ) { a >>= 1 ; b >>= 1 ; shift ++ ; } while ( ( a & 1L ) == 0L ) { a >>= 1 ; } do { while ( ( b & 1L ) == 0L ) { b >>= 1 ; } if ( a > b ) { long tmp = b ; b = a ; a = tmp ; } b -= a ; } while ( b != 0L ) ; return a << shift ;


signature:
public class Numbers { /** * Returns the greatest common divisor of the absolute value of the
 * given two numbers . This method first computes the absolute values of
 * the given numbers , thus it doesn ' t accept { @ code Integer . MIN _ VALUE } .
 * Also , note that if one of the given values is { @ code 0 } , this method
 * will return the absolute value of the second argument .
 * This method implements the binary GCD algorithm ( also known as
 * Stein ' s algorithm ) . For further information on this algorithm , please
 * refer to < a href = " http : / / en . wikipedia . org / wiki / Binary _ GCD _ algorithm " >
 * Wikipedia < / a > .
 * @ param a the first number .
 * @ param b the second number .
 * @ return the greatest common divisor of { @ code a } and { @ code b } .
 * @ throws ArithmeticException if { @ code a } or { @ code b } is equal to
 * { @ code Integer . MIN _ VALUE } . */
public static int gcd ( int a , int b ) { } }

implementation: try { if ( a < 0 || b < 0 ) { return gcd ( safeAbs ( a ) , safeAbs ( b ) ) ; } return ( int ) gcd ( ( long ) a , ( long ) b ) ; } catch ( ArithmeticException e ) { throw new ArithmeticException ( "Int overflow: gcd(" + a + ", " + b + ")" ) ; }


signature:
public class Numbers { /** * Returns the least common multiple of the absolute value of the given
 * two numbers . This method first computes the absolute values of the
 * given numbers , thus it doesn ' t accept { @ code Long . MIN _ VALUE } . Also ,
 * note that if one of the given values is { @ code 0 } , this method will
 * return the absolute value of the second argument . This method uses
 * the formula { @ code lcm ( a , b ) = ( a / gcd ( a , b ) ) * b } . Please refer to
 * < a href = " http : / / en . wikipedia . org / wiki / Least _ common _ multiple " >
 * Wikipedia < / a > for further information .
 * @ param a the first number .
 * @ param b the second number .
 * @ return the least common multiple of { @ code a } and { @ code b } .
 * @ throws ArithmeticException if { @ code a } or { @ code b } is equal to
 * { @ code Long . MIN _ VALUE } . */
public static long lcm ( long a , long b ) { } }

implementation: try { if ( a < 0L || b < 0L ) { return lcm ( safeAbs ( a ) , safeAbs ( b ) ) ; } if ( a == 0L ) { return b ; } if ( b == 0L ) { return a ; } return safeMultiply ( a / gcd ( a , b ) , b ) ; } catch ( ArithmeticException e ) { throw new ArithmeticException ( "Long overflow: lcm(" + a + ", " + b + ")" ) ; }


signature:
public class Numbers { /** * Casts the given { @ code long } value to { @ code int } , if possible .
 * @ param a the value to cast to { @ code int } .
 * @ return the casted value .
 * @ throws ArithmeticException if { @ code a } cannot be cast into an
 * { @ code int } . */
public static int safeToInt ( long a ) { } }

implementation: if ( a >= Integer . MIN_VALUE && a <= Integer . MAX_VALUE ) { return ( int ) a ; } throw new ArithmeticException ( a + " can't be cast to int" ) ;


signature:
public class Parameters { /** * Checks that the given reference is not { @ code null } and returns it
 * in case of success .
 * @ param < T > the type of the given reference .
 * @ param ref the reference to test .
 * @ param msg the error message format string .
 * @ param args the error message arguments .
 * @ return the validated ( non - { @ code null } ) reference .
 * @ throws NullPointerException if the given reference is { @ code null } . */
public static < T > T checkNotNull ( T ref , String msg , Object ... args ) { } }

implementation: if ( ref == null ) { throw new NullPointerException ( format ( msg , args ) ) ; } return ref ;


signature:
public class Parameters { /** * Checks the truth of the given condition checking parameters validity .
 * @ param condition the boolean condition to test .
 * @ param msg the error message format string .
 * @ param args the error message arguments .
 * @ throws IllegalArgumentException if the condition is { @ code false } . */
public static void checkCondition ( boolean condition , String msg , Object ... args ) { } }

implementation: if ( ! condition ) { throw new IllegalArgumentException ( format ( msg , args ) ) ; }


signature:
public class Parameters { /** * Checks the type of the given reference and , in case of success , casts
 * and returns it .
 * @ param < T > the expected type of the given reference .
 * @ param ref the reference to test .
 * @ param type the expected type of the given reference .
 * @ return the given reference in the expected type .
 * @ throws NullPointerException if { @ code type } is { @ code null } .
 * @ throws ClassCastException if the given reference doesn ' t represent
 * an instance of the expected class . */
public static < T > T checkType ( Object ref , Class < T > type ) { } }

implementation: if ( type . isInstance ( ref ) ) { return type . cast ( ref ) ; } throw new ClassCastException ( ) ;


signature:
public class Parameters { /** * Checks the type of the given reference and , in case of success , casts
 * and returns it .
 * @ param < T > the expected type of the given reference .
 * @ param ref the reference to test .
 * @ param type the expected type of the given reference .
 * @ param msg the error message format string .
 * @ param args the error message arguments .
 * @ return the given reference in the expected type .
 * @ throws NullPointerException if { @ code type } is { @ code null } .
 * @ throws ClassCastException if the given reference doesn ' t represent
 * an instance of the given class . */
public static < T > T checkType ( Object ref , Class < T > type , String msg , Object ... args ) { } }

implementation: if ( type . isInstance ( ref ) ) { return type . cast ( ref ) ; } throw new ClassCastException ( format ( msg , args ) ) ;


signature:
public class Booleans { /** * Performs a logical " and " on the given values , that is , this method
 * returns { @ code true } if , and only if , all the given { @ code Boolean }
 * values are { @ code true } , and { @ code false } in all other cases .
 * @ param bools the { @ code Boolean } values .
 * @ return the result of the logical " and " on the given values .
 * @ throws NullPointerException if { @ code bools } is { @ code null } or if
 * it contains a { @ code null } reference .
 * @ throws IllegalArgumentException if { @ code bools } is empty . */
public static Boolean and ( Boolean ... bools ) { } }

implementation: Parameters . checkCondition ( bools . length > 0 ) ; for ( Boolean bool : bools ) { if ( ! bool ) { return FALSE ; } } return TRUE ;


signature:
public class Booleans { /** * Performs an " exclusive or " on the given values , that is , this method
 * returns { @ code true } if , and only if , only one of the given
 * { @ code Boolean } values is { @ code true } , and { @ code false } in all
 * other cases .
 * @ param bools the { @ code Boolean } values .
 * @ return the result of the " exclusive or " on the given values .
 * @ throws NullPointerException if { @ code bools } is { @ code null } or if
 * it contains a { @ code null } reference .
 * @ throws IllegalArgumentException if { @ code bools } is empty . */
public static Boolean xor ( Boolean ... bools ) { } }

implementation: Parameters . checkCondition ( bools . length > 0 ) ; boolean xor = false ; for ( Boolean bool : bools ) { if ( bool ) { if ( xor ) { return FALSE ; } else { xor = true ; } } } return xor ? TRUE : FALSE ;


signature:
public class Booleans { /** * Parses the given { @ code String } into a { @ code Boolean } . This method
 * returns { @ code true } if the given { @ code String } contains " true " ,
 * " yes " , " 1 " or " on " .
 * @ param bool the { @ code String } to parse .
 * @ return the parsed { @ code Boolean } .
 * @ throws NullPointerException if { @ code bool } is { @ code null } . */
public static Boolean valueOf ( String bool ) { } }

implementation: String s = bool . replaceAll ( "\\s" , "" ) ; boolean b = "true" . equalsIgnoreCase ( s ) || "yes" . equalsIgnoreCase ( s ) || "on" . equalsIgnoreCase ( s ) || "1" . equalsIgnoreCase ( s ) ; return b ? TRUE : FALSE ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will use the specified separator
 * to split { @ code String } s .
 * @ param separator the separator .
 * @ return the created { @ code Splitter } .
 * @ throws NullPointerException if { @ code separator } is { @ code null } . */
public static Splitter on ( String separator ) { } }

implementation: return on ( Pattern . compile ( Pattern . quote ( separator ) ) ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will use the specified pattern
 * to split { @ code String } s .
 * @ param pattern the separator pattern .
 * @ return the created { @ code Splitter } .
 * @ throws NullPointerException if { @ code pattern } is { @ code null } . */
public static Splitter on ( Pattern pattern ) { } }

implementation: return new Splitter ( - 1 , false , pattern , null , null , "" , false ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will behave as this one except
 * that it will limit the number of times the splitting pattern is
 * applied . If { @ code limit } is strictly positive , then the pattern will
 * be applied at most { @ code limit - 1 } times . If { @ code limit } is
 * non - positive then the splitting pattern will be applied as many times
 * as possible .
 * @ param limit the splitting limit .
 * @ return a new { @ code Splitter } with the desired configuration . */
public Splitter limit ( int limit ) { } }

implementation: return new Splitter ( limit == 0 ? - 1 : limit , trim , pattern , prefix , suffix , forEmpty , ignoreEmptyStrings ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will behave as this one except
 * that it will ignore the given prefix .
 * @ param prefix the prefix to ignore .
 * @ return a new { @ code Splitter } with the desired configuration .
 * @ throws NullPointerException if { @ code prefix } is { @ code null } . */
public Splitter ignorePrefix ( String prefix ) { } }

implementation: Parameters . checkNotNull ( prefix ) ; return new Splitter ( limit , trim , pattern , prefix , suffix , forEmpty , ignoreEmptyStrings ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will behave as this one except
 * that it will ignore the given suffix .
 * @ param suffix the suffix to ignore .
 * @ return a new { @ code Splitter } with the desired configuration .
 * @ throws NullPointerException if { @ code suffix } is { @ code null } . */
public Splitter ignoreSuffix ( String suffix ) { } }

implementation: Parameters . checkNotNull ( suffix ) ; return new Splitter ( limit , trim , pattern , prefix , suffix , forEmpty , ignoreEmptyStrings ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will behave as this one except
 * that it will ignore empty results .
 * @ return a new { @ code Splitter } with the desired configuration . */
public Splitter ignoreEmptyStrings ( ) { } }

implementation: return new Splitter ( limit , trim , pattern , prefix , suffix , forEmpty , true ) ;


signature:
public class Splitter { /** * Returns a new { @ code Splitter } that will behave as this one except
 * that it will replace empty results by the specified { @ code String } .
 * @ param forEmpty the value to use for empty { @ code String } s .
 * @ return a new { @ code Splitter } with the desired configuration . */
public Splitter replaceEmptyStringWith ( String forEmpty ) { } }

implementation: return new Splitter ( limit , trim , pattern , prefix , suffix , forEmpty , false ) ;


signature:
public class Splitter { /** * Splits the given { @ code String } into parts according to its
 * configuration .
 * @ param s the { @ code String } to split .
 * @ return the parts , as an unmodifiable { @ code List } .
 * @ throws NullPointerException if { @ code s } is { @ code null } . */
public List < String > split ( String s ) { } }

implementation: String [ ] parts = pattern . split ( removePrefixAndSuffix ( s ) , limit ) ; List < String > results = new ArrayList < String > ( parts . length ) ; for ( String part : parts ) { String str = trim ? part . trim ( ) : part ; if ( ! str . isEmpty ( ) ) { results . add ( str ) ; } else if ( ! ignoreEmptyStrings ) { results . add ( forEmpty ) ; } } return Collections . unmodifiableList ( results ) ;


signature:
public class Comparators { /** * Returns a { @ code Comparator } that will call each { @ code Comparator }
 * in the given array until one of them returns a non - zero result ( will
 * return { @ code 0 } if they all return { @ code 0 } ) .
 * @ param < T > the parameters type of the returned { @ code Comparator } .
 * @ param comparators the { @ code Comparator } s to compose .
 * @ return the composed { @ code Comparator } .
 * @ throws NullPointerException if { @ code comparators } is { @ code null }
 * of if it contains a { @ code null } reference .
 * @ throws IllegalArgumentException if { @ code comparators } is empty . */
public static < T > Comparator < T > compose ( Comparator < ? super T > ... comparators ) { } }

implementation: return compose ( Arrays . asList ( comparators ) ) ;


signature:
public class Comparators { /** * Returns a { @ code Comparator } that will call each { @ code Comparator }
 * in the given { @ code Iterable } until one of them returns a non - zero
 * result ( will return { @ code 0 } if they all return { @ code 0 } ) .
 * @ param < T > the parameters type of the returned { @ code Comparator } .
 * @ param comparators the { @ code Comparator } s to compose .
 * @ return the composed { @ code Comparator } .
 * @ throws NullPointerException if { @ code comparators } is { @ code null }
 * of if it contains a { @ code null } reference .
 * @ throws IllegalArgumentException if { @ code comparators } is empty . */
public static < T > Comparator < T > compose ( Iterable < ? extends Comparator < ? super T > > comparators ) { } }

implementation: return new CompositeComparator < T > ( comparators ) ;


signature:
public class Comparators { /** * Returns a { @ code Comparator } that represents the reverse ordering of
 * the given one . Namely , the returned { @ code Comparator } will return
 * a negative value if the original returns a positive value and ,
 * conversely , will return a positive value if it returns a negative
 * value .
 * @ param < T > the parameters type of the { @ code Comparator } s .
 * @ param comparator the comparator to invert .
 * @ return the inverted { @ code Comparator } .
 * @ throws NullPointerException if { @ code comparator } is { @ code null } . */
public static < T > Comparator < T > reverse ( final Comparator < T > comparator ) { } }

implementation: Parameters . checkNotNull ( comparator ) ; return new Comparator < T > ( ) { @ Override public int compare ( T o1 , T o2 ) { return - comparator . compare ( o1 , o2 ) ; } } ;


signature:
public class Comparators { /** * Returns a { @ code Comparator } that compares { @ code Comparable } objects
 * in natural order . The returned comparator doesn ' t accept { @ code null }
 * values .
 * @ param < T > the { @ code Comparable } type .
 * @ return a { @ code Comparator } that compares { @ code Comparable } objects . */
public static < T extends Comparable < ? super T > > Comparator < T > naturalOrder ( ) { } }

implementation: return new Comparator < T > ( ) { @ Override public int compare ( T o1 , T o2 ) { return o1 . compareTo ( Parameters . checkNotNull ( o2 ) ) ; } } ;


signature:
public class Comparators { /** * Returns a new { @ code Comparator } that considers { @ code null } values
 * as less than all other values and compares non - { @ code null } values
 * with the given { @ code Comparator } .
 * @ param < T > the parameters type of the { @ code Comparator } .
 * @ param comparator the non - { @ code null } values { @ code Comparator }
 * @ return the created { @ code Comparator } .
 * @ throws NullPointerException if { @ code comparator } is { @ code null } . */
public static < T > Comparator < T > withNullsFirst ( final Comparator < T > comparator ) { } }

implementation: Parameters . checkNotNull ( comparator ) ; return new Comparator < T > ( ) { @ Override public int compare ( T o1 , T o2 ) { return o1 == o2 ? 0 : o1 == null ? - 1 : o2 == null ? 1 : comparator . compare ( o1 , o2 ) ; } } ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will trim inputs before joining them .
 * @ return a new { @ code Joiner } with the desired configuration . */
public Joiner trimInputs ( ) { } }

implementation: return new Joiner ( separator , prefix , suffix , true , ignoreNull , ignoreEmpty , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will ignore { @ code null } input values .
 * @ return a new { @ code Joiner } with the desired configuration . */
public Joiner ignoreNulls ( ) { } }

implementation: return new Joiner ( separator , prefix , suffix , trim , true , ignoreEmpty , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will ignore empty input { @ code String } s .
 * @ return a new { @ code Joiner } with the desired configuration . */
public Joiner ignoreEmptyStrings ( ) { } }

implementation: return new Joiner ( separator , prefix , suffix , trim , ignoreNull , true , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will replace { @ code null } input values with the specified
 * { @ code String } .
 * @ param forNull the { @ code String } to use for { @ code null } s .
 * @ return a new { @ code Joiner } with the desired configuration .
 * @ throws NullPointerException if { @ code forNull } is { @ code null } . */
public Joiner replaceNullWith ( String forNull ) { } }

implementation: return new Joiner ( separator , prefix , suffix , trim , false , ignoreEmpty , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will replace empty input { @ code String } s with the specified value .
 * @ param forEmpty the value to use for empty { @ code String } s .
 * @ return a new { @ code Joiner } with the desired configuration .
 * @ throws NullPointerException if { @ code forEmpty } is { @ code null } . */
public Joiner replaceEmptyStringWith ( String forEmpty ) { } }

implementation: return new Joiner ( separator , prefix , suffix , trim , ignoreNull , false , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Returns a new { @ code Joiner } that will behave as this one except that
 * it will use the specified prefix when joining { @ code String } s .
 * @ param prefix the prefix .
 * @ return a new { @ code Joiner } with the desired configuration .
 * @ throws NullPointerException if { @ code prefix } is { @ code null } . */
public Joiner withPrefix ( String prefix ) { } }

implementation: return new Joiner ( separator , prefix , suffix , trim , ignoreNull , ignoreEmpty , forNull , forEmpty ) ;


signature:
public class Joiner { /** * Joins the given { @ code String } s according to its configuration .
 * @ param parts the parts to join .
 * @ return the created { @ code String } .
 * @ throws NullPointerException if { @ code parts } is { @ code null } . */
public String join ( Iterable < ? > parts ) { } }

implementation: boolean first = true ; StringBuilder sb = new StringBuilder ( prefix ) ; for ( Object part : parts ) { String s = format ( part ) ; if ( s != null ) { if ( first ) { first = false ; } else { sb . append ( separator ) ; } sb . append ( s ) ; } } return sb . append ( suffix ) . toString ( ) ;


signature:
public class Factory { /** * Creates and returns a { @ link Digest } instance corresponding to the
 * given algorithm .
 * @ param algorithm the digest algorithm .
 * @ return the created { @ link Digest } instance .
 * @ throws NullPointerException if { @ code algorithm } is { @ code null } .
 * @ throws IllegalArgumentException if the given algorithm is unknown . */
static Digest newDigest ( Algorithm < Digest > algorithm ) { } }

implementation: Parameters . checkNotNull ( algorithm ) ; Digest digest ; if ( algorithm == Algorithm . MD2 ) { digest = Digests . md2 ( ) ; } else if ( algorithm == Algorithm . MD4 ) { digest = Digests . md4 ( ) ; } else if ( algorithm == Algorithm . MD5 ) { digest = Digests . md5 ( ) ; } else if ( algorithm == Algorithm . SHA1 ) { digest = Digests . sha1 ( ) ; } else if ( algorithm == Algorithm . SHA256 ) { digest = Digests . sha256 ( ) ; } else if ( algorithm == Algorithm . SHA512 ) { digest = Digests . sha512 ( ) ; } else if ( algorithm == Algorithm . KECCAK224 ) { digest = Digests . keccak224 ( ) ; } else if ( algorithm == Algorithm . KECCAK256 ) { digest = Digests . keccak256 ( ) ; } else if ( algorithm == Algorithm . KECCAK384 ) { digest = Digests . keccak384 ( ) ; } else if ( algorithm == Algorithm . KECCAK512 ) { digest = Digests . keccak512 ( ) ; } else { throw new IllegalArgumentException ( "Unknown algorithm" ) ; } return digest ;


signature:
public class Factory { /** * Creates and returns a { @ link MAC } instance corresponding to the given
 * algorithm , initialized with the provided secret key .
 * @ param algorithm the MAC algorithm .
 * @ param key the secret key .
 * @ return the created { @ link MAC } instance .
 * @ throws NullPointerException if { @ code algorithm } is { @ code null } .
 * @ throws IllegalArgumentException if the given algorithm is unknown . */
static MAC newMAC ( Algorithm < MAC > algorithm , byte [ ] key ) { } }

implementation: Parameters . checkNotNull ( algorithm ) ; MAC mac ; if ( algorithm == Algorithm . HMAC_MD2 ) { mac = HMAC . md2 ( key ) ; } else if ( algorithm == Algorithm . HMAC_MD4 ) { mac = HMAC . md4 ( key ) ; } else if ( algorithm == Algorithm . HMAC_MD5 ) { mac = HMAC . md5 ( key ) ; } else if ( algorithm == Algorithm . HMAC_SHA1 ) { mac = HMAC . sha1 ( key ) ; } else if ( algorithm == Algorithm . HMAC_SHA256 ) { mac = HMAC . sha256 ( key ) ; } else if ( algorithm == Algorithm . HMAC_SHA512 ) { mac = HMAC . sha512 ( key ) ; } else if ( algorithm == Algorithm . HMAC_KECCAK224 ) { mac = HMAC . keccak224 ( key ) ; } else if ( algorithm == Algorithm . HMAC_KECCAK256 ) { mac = HMAC . keccak256 ( key ) ; } else if ( algorithm == Algorithm . HMAC_KECCAK384 ) { mac = HMAC . keccak384 ( key ) ; } else if ( algorithm == Algorithm . HMAC_KECCAK512 ) { mac = HMAC . keccak512 ( key ) ; } else { throw new IllegalArgumentException ( "Unknown algorithm" ) ; } return mac ;


signature:
public class ImmutableBag { /** * Creates a new { @ code ImmutableBag } from the given { @ code Collection } .
 * @ param < E > the type of the { @ code Bag } ' s elements .
 * @ param c the source { @ code Collection } .
 * @ return the created { @ code ImmutableBag } .
 * @ throws NullPointerException if { @ code c } is { @ code null } . */
public static < E > Bag < E > copyOf ( Collection < ? extends E > c ) { } }

implementation: return new ImmutableBag < E > ( new ArrayBag < E > ( c ) ) ;


signature:
public class ImmutableBag { /** * Creates a new { @ code ImmutableBag } from the given { @ code Iterable } .
 * @ param < E > the type of the { @ code Bag } ' s elements .
 * @ param i the source { @ code Iterable } .
 * @ return the created { @ code ImmutableBag } .
 * @ throws NullPointerException if { @ code i } is { @ code null } . */
public static < E > Bag < E > copyOf ( Iterable < ? extends E > i ) { } }

implementation: return new ImmutableBag < E > ( new ArrayBag < E > ( i ) ) ;


signature:
public class ImmutableBag { /** * Creates a new { @ code ImmutableBag } from the given { @ code Iterator } .
 * @ param < E > the type of the { @ code Bag } ' s elements .
 * @ param i the source { @ code Iterator } .
 * @ return the created { @ code ImmutableBag } .
 * @ throws NullPointerException if { @ code i } is { @ code null } . */
public static < E > Bag < E > copyOf ( Iterator < ? extends E > i ) { } }


signature:
public class ImmutableBag { /** * Creates a new { @ code ImmutableBag } containing the given elements .
 * @ param < E > the type of the { @ code Bag } ' s elements .
 * @ param values the { @ code Bag } ' s elements .
 * @ return the created { @ code ImmutableBag } .
 * @ throws NullPointerException if { @ code values } is { @ code null } . */
public static < E > Bag < E > copyOf ( E [ ] values ) { } }

implementation: return new ImmutableBag < E > ( new ArrayBag < E > ( values ) ) ;


signature:
public class ImmutableBag { /** * Creates a new { @ code ImmutableBag } containing the given elements .
 * @ param < E > the type of the { @ code Bag } ' s elements .
 * @ param values the { @ code Bag } ' s elements .
 * @ return the created { @ code ImmutableBag } .
 * @ throws NullPointerException if { @ code values } is { @ code null } . */
public static < E > Bag < E > of ( E ... values ) { } }


signature: public class HalResourceInvocationHandler { private String getRelationHref ( Link link , Object [ ] args , Annotation [ ] [ ] parameterAnnotations ) { } }

implementation: HalLink halLink = halResource . getLink ( link . relation ( ) ) ; if ( halLink == null ) { throw new UnsupportedOperationException ( link . relation ( ) ) ; } if ( halLink . getDeprecation ( ) != null ) { log . warn ( "Link '" + link + "' has been deprecated: " + halLink . getDeprecation ( ) ) ; } String href ; if ( halLink . isTemplated ( ) ) { try { UriTemplate uriTemplate = UriTemplate . fromTemplate ( halLink . getHref ( ) ) ; for ( int i = 0 ; i < args . length ; i ++ ) { for ( Annotation annotation : parameterAnnotations [ i ] ) { if ( annotation . annotationType ( ) == UriVariable . class ) { UriVariable uriVariable = ( UriVariable ) annotation ; assignTemplateValue ( uriTemplate , uriVariable . name ( ) , args [ i ] ) ; } } } for ( int i = 0 ; i < link . uriValues ( ) . length ; i ++ ) { UriValue uriValue = link . uriValues ( ) [ i ] ; assignTemplateValue ( uriTemplate , uriValue . name ( ) , uriValue . value ( ) ) ; } href = uriTemplate . expand ( ) ; } catch ( MalformedUriTemplateException | VariableExpansionException e ) { throw new RuntimeException ( e ) ; } } else { href = halLink . getHref ( ) ; } return href ;


signature: public class StatusCodeErrorResponseHandler { public AmazonServiceException handle ( HttpResponse response ) throws Exception { } }

implementation:
JSONObject jsonBody = getBodyAsJson ( response ) ; Class < ? extends AmazonServiceException > exceptionClass = exceptionClasses . get ( response . getStatusCode ( ) ) ; AmazonServiceException result ; // Support other attribute names for the message ?
// TODO : Inspect exception type ( caching details ) and apply other values from the body
String message = jsonBody . has ( "message" ) ? jsonBody . getString ( "message" ) : jsonBody . getString ( "Message" ) ; if ( exceptionClass != null ) { result = exceptionClass . getConstructor ( String . class ) . newInstance ( message ) ; } else { result = AmazonServiceException . class . getConstructor ( String . class ) . newInstance ( message ) ; } result . setServiceName ( response . getRequest ( ) . getServiceName ( ) ) ; result . setStatusCode ( response . getStatusCode ( ) ) ; if ( response . getStatusCode ( ) < 500 ) { result . setErrorType ( ErrorType . Client ) ; } else { result . setErrorType ( ErrorType . Service ) ; } for ( Entry < String , String > headerEntry : response . getHeaders ( ) . entrySet ( ) ) { if ( headerEntry . getKey ( ) . equalsIgnoreCase ( "X-Amzn-RequestId" ) ) { result . setRequestId ( headerEntry . getValue ( ) ) ; } } return result ;


signature: public class StatusCodeErrorResponseHandler { private JSONObject getBodyAsJson ( HttpResponse response ) { } }

implementation: try ( InputStream stream = response . getContent ( ) ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String line = reader . readLine ( ) ; if ( line == null ) { break ; } sb . append ( line ) ; } return new JSONObject ( sb . length ( ) == 0 ? "{}" : sb . toString ( ) ) ; } catch ( IOException e ) { throw new AmazonClientException ( "Unable to read error response: " + e . getMessage ( ) , e ) ; } catch ( JSONException e ) { throw new AmazonClientException ( "Unable to parse error response: " + e . getMessage ( ) , e ) ; }


signature: public class HalJsonEmbeddedUnmarshaller { @ Override public Map < String , HalResource > unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation:
Map < String , HalResource > embedded = new LinkedHashMap < > ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != JsonToken . END_OBJECT ) { if ( token == JsonToken . FIELD_NAME ) { // Ignore the field name and move to the next token . The item ' s key will be the embedded resource ' s selfHref .
token = context . nextToken ( ) ; if ( token == JsonToken . START_ARRAY ) { List < HalResource > halResources = new HalJsonArrayUnmarshaller < > ( HalJsonResourceUnmarshaller . getInstance ( ) ) . unmarshall ( context ) ; for ( HalResource halResource : halResources ) { embedded . put ( halResource . _getSelfHref ( ) , halResource ) ; } } else { HalResource halResource = HalJsonResourceUnmarshaller . getInstance ( ) . unmarshall ( context ) ; embedded . put ( halResource . _getSelfHref ( ) , halResource ) ; } } token = context . nextToken ( ) ; } return embedded ;


signature: public class HalService { private HalClient getHalClient ( ) { } }

implementation: if ( halClient == null ) { this . halClient = new HalClient ( clientConfiguration == null ? new ClientConfiguration ( ) : clientConfiguration , endpoint , serviceName , awsCredentialsProvider == null ? new DefaultAWSCredentialsProviderChain ( ) : awsCredentialsProvider , resourceCache == null ? ImmediatelyExpiringCache . getInstance ( ) : resourceCache , errorResponseHandler ) ; if ( regionId != null ) { halClient . setSignerRegionOverride ( regionId ) ; } } return halClient ;


signature: public class HalJsonListUnmarshaller { @ Override public List < Object > unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation: List < Object > list = new ArrayList < > ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != JsonToken . END_ARRAY ) { if ( token . isScalarValue ( ) ) { list . add ( JsonUnmarshallerUtil . getObjectForToken ( token , context ) ) ; } else if ( token == JsonToken . START_OBJECT ) { context . nextToken ( ) ; list . add ( HalJsonMapUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else if ( token == JsonToken . START_ARRAY ) { context . nextToken ( ) ; list . add ( HalJsonListUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } token = context . nextToken ( ) ; } return list ;


signature: public class HalJsonMapUnmarshaller { @ Override public Map < String , Object > unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation: Map < String , Object > map = new HashMap < > ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != JsonToken . END_OBJECT ) { if ( token == JsonToken . FIELD_NAME ) { String property = context . readText ( ) ; token = context . nextToken ( ) ; if ( token == JsonToken . START_OBJECT ) { context . nextToken ( ) ; map . put ( property , HalJsonMapUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else if ( token == JsonToken . START_ARRAY ) { context . nextToken ( ) ; map . put ( property , HalJsonListUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else { map . put ( property , JsonUnmarshallerUtil . getObjectForToken ( token , context ) ) ; } } token = context . nextToken ( ) ; } return map ;


signature: public class HalClient { public < T > T getResource ( Class < T > resourceClass , String resourcePath ) { } }

implementation: return getResource ( null , resourceClass , resourcePath , false ) ;


signature: public class HalClient { < T > T getResource ( HalResource sourceResource , Class < T > resourceClass , String resourcePath , boolean lazy ) { } }

implementation: if ( resourceCache . containsKey ( resourcePath ) ) { return resourceClass . cast ( resourceCache . get ( resourcePath ) ) ; } HalResource halResource ; if ( sourceResource != null && sourceResource . getEmbedded ( ) . containsKey ( resourcePath ) ) { halResource = sourceResource . getEmbedded ( ) . get ( resourcePath ) ; } else if ( lazy ) { halResource = null ; } else { halResource = getHalResource ( resourcePath ) ; } return createAndCacheResource ( resourceClass , resourcePath , halResource ) ;


signature: public class HalClient { private < T > T invoke ( HttpMethodName httpMethodName , String resourcePath , Object representation , HttpResponseHandler < AmazonWebServiceResponse < T > > responseHandler ) throws AmazonClientException { } }

implementation: ExecutionContext executionContext = createExecutionContext ( ) ; AWSRequestMetrics awsRequestMetrics = executionContext . getAwsRequestMetrics ( ) ; awsRequestMetrics . startEvent ( AWSRequestMetrics . Field . RequestMarshallTime . name ( ) ) ; Request request = buildRequest ( httpMethodName , resourcePath , representation ) ; awsRequestMetrics . endEvent ( AWSRequestMetrics . Field . RequestMarshallTime . name ( ) ) ; awsRequestMetrics . startEvent ( AWSRequestMetrics . Field . CredentialsRequestTime . name ( ) ) ; AWSCredentials credentials = awsCredentialsProvider . getCredentials ( ) ; awsRequestMetrics . endEvent ( AWSRequestMetrics . Field . CredentialsRequestTime . name ( ) ) ; executionContext . setCredentials ( credentials ) ; awsRequestMetrics . startEvent ( AWSRequestMetrics . Field . ClientExecuteTime . name ( ) ) ; Response < T > response = client . execute ( request , responseHandler , errorResponseHandler , executionContext ) ; awsRequestMetrics . endEvent ( AWSRequestMetrics . Field . ClientExecuteTime . name ( ) ) ; awsRequestMetrics . log ( ) ; return response . getAwsResponse ( ) ;


signature:
public class ConvertingMap { /** * TODO : test w / map of Integer . . . */
@ Override public Object get ( Object key ) { } }

implementation:
Object value = backingMap . get ( key ) ; // When a value is accessed , it ' s intended type can either be a
// class or some other type ( like a ParameterizedType ) .
// If the target type is a class and the value is of that type ,
// we return it . If the value is not of that type , we convert
// it and store the converted value ( trusting it was converted
// properly ) back to the backing store .
// If the target type is not a class , it may be ParameterizedType
// like List < T > or Map < K , V > . We check if the value is already
// a converting type and if so , we return it . If the value is
// not , we convert it and if it ' s now a converting type , we store
// the new value in the backing store .
if ( type instanceof Class ) { if ( ! ( ( Class ) type ) . isInstance ( value ) ) { value = convert ( type , value ) ; // noinspection unchecked
backingMap . put ( key , value ) ; } } else { if ( ! ( value instanceof ConvertingMap ) && ! ( value instanceof ConvertingList ) ) { value = convert ( type , value ) ; if ( value instanceof ConvertingMap || value instanceof ConvertingList ) { // noinspection unchecked
backingMap . put ( key , value ) ; } } } return value ;


signature: public class JsonUnmarshallerUtil { static Object getObjectForToken ( JsonToken token , JsonUnmarshallerContext context ) throws IOException { } }

implementation: switch ( token ) { case VALUE_STRING : return context . getJsonParser ( ) . getText ( ) ; case VALUE_NUMBER_FLOAT : case VALUE_NUMBER_INT : return context . getJsonParser ( ) . getNumberValue ( ) ; case VALUE_FALSE : return Boolean . FALSE ; case VALUE_TRUE : return Boolean . TRUE ; case VALUE_NULL : return null ; default : throw new RuntimeException ( "We expected a VALUE token but got: " + token ) ; }


signature: public class HalJsonLinksUnmarshaller { @ Override public Map < String , HalLink > unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation: Map < String , HalLink > links = new LinkedHashMap < > ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != JsonToken . END_OBJECT ) { if ( token == JsonToken . FIELD_NAME ) { if ( context . testExpression ( "curie" ) ) { context . nextToken ( ) ; HalJsonCurieUnmarshaller . getInstance ( ) . unmarshall ( context ) ; } else { String relation = context . readText ( ) ; token = context . nextToken ( ) ; if ( token == JsonToken . START_ARRAY ) { List < HalLink > halLinks = new HalJsonArrayUnmarshaller < > ( HalJsonLinkUnmarshaller . getInstance ( ) ) . unmarshall ( context ) ; int i = 0 ; for ( HalLink halLink : halLinks ) { links . put ( relation + "_" + i ++ , halLink ) ; } } else { links . put ( relation , HalJsonLinkUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } } } token = context . nextToken ( ) ; } return links ;


signature: public class HalJsonArrayUnmarshaller { @ Override public List < T > unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation: List < T > list = new ArrayList < > ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != END_ARRAY ) { if ( token == JsonToken . START_OBJECT ) { list . add ( itemUnmarshaller . unmarshall ( context ) ) ; } token = context . nextToken ( ) ; } return list ;


signature: public class OptionalJsonResponseHandler { @ Override protected void registerAdditionalMetadataExpressions ( JsonUnmarshallerContext unmarshallerContext ) { } }

implementation: Map < String , String > headers = unmarshallerContext . getHttpResponse ( ) . getHeaders ( ) ; if ( headers . containsKey ( "Location" ) ) { location = headers . get ( "Location" ) ; } else if ( headers . containsKey ( "location" ) ) { location = headers . get ( "location" ) ; }


signature: public class HalJsonResourceUnmarshaller { @ Override public HalResource unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation: HalResource halResource = new HalResource ( ) ; JsonToken token = context . getCurrentToken ( ) ; if ( token == null ) { token = context . nextToken ( ) ; } while ( token != null && token != JsonToken . END_OBJECT ) { if ( token == JsonToken . FIELD_NAME ) { if ( context . testExpression ( "_links" ) ) { context . nextToken ( ) ; halResource . setLinks ( HalJsonLinksUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else if ( context . testExpression ( "_embedded" ) ) { context . nextToken ( ) ; halResource . setEmbedded ( HalJsonEmbeddedUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else { String property = context . readText ( ) ; token = context . nextToken ( ) ; if ( token == JsonToken . START_OBJECT ) { context . nextToken ( ) ; halResource . addProperty ( property , HalJsonMapUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else if ( token == JsonToken . START_ARRAY ) { context . nextToken ( ) ; halResource . addProperty ( property , HalJsonListUnmarshaller . getInstance ( ) . unmarshall ( context ) ) ; } else { halResource . addProperty ( property , JsonUnmarshallerUtil . getObjectForToken ( token , context ) ) ; } } } token = context . nextToken ( ) ; } return halResource ;


signature: public class ConvertingList { @ Override public Object get ( int index ) { } }

implementation:
Object value = backingList . get ( index ) ; // When a value is accessed , it ' s intended type can either be a
// class or some other type ( like a ParameterizedType ) .
// If the target type is a class and the value is of that type ,
// we return it . If the value is not of that type , we convert
// it and store the converted value ( trusting it was converted
// properly ) back to the backing store .
// If the target type is not a class , it may be ParameterizedType
// like List < T > or Map < K , V > . We check if the value is already
// a converting type and if so , we return it . If the value is
// not , we convert it and if it ' s now a converting type , we store
// the new value in the backing store .
if ( type instanceof Class ) { if ( ! ( ( Class ) type ) . isInstance ( value ) ) { value = convert ( type , value ) ; // noinspection unchecked
backingList . set ( index , value ) ; } } else { if ( ! ( value instanceof ConvertingMap ) && ! ( value instanceof ConvertingList ) ) { value = convert ( type , value ) ; if ( value instanceof ConvertingMap || value instanceof ConvertingList ) { // noinspection unchecked
backingList . set ( index , value ) ; } } } return value ;


signature: public class ConversionUtil { static Type getCollectionType ( Type type , int index , Class defaultClass ) { } }

implementation: if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; return parameterizedType . getActualTypeArguments ( ) [ index ] ; } else { return defaultClass ; }


signature: public class ConversionUtil { private static Object convertFromNull ( Type type ) { } }

implementation: if ( ! ( type instanceof Class ) ) { return null ; } Class < ? > clazz = ( Class ) type ; if ( ! clazz . isPrimitive ( ) ) { return null ; } if ( int . class . isAssignableFrom ( clazz ) ) { return 0 ; } else if ( long . class . isAssignableFrom ( clazz ) ) { return 0L ; } else if ( short . class . isAssignableFrom ( clazz ) ) { return 0 ; } else if ( double . class . isAssignableFrom ( clazz ) ) { return 0.0 ; } else if ( float . class . isAssignableFrom ( clazz ) ) { return 0.0F ; } else if ( boolean . class . isAssignableFrom ( clazz ) ) { return Boolean . FALSE ; } else if ( char . class . isAssignableFrom ( clazz ) ) { return 0 ; } else if ( byte . class . isAssignableFrom ( clazz ) ) { return 0 ; } else { throw new RuntimeException ( "Unexpected primitive type: " + clazz . getSimpleName ( ) ) ; }


signature: public class HalJsonLinkUnmarshaller { @ Override public HalLink unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation:
HalLink halLink = new HalLink ( ) ; JsonToken token = context . getCurrentToken ( ) ; while ( token != null && token != JsonToken . END_OBJECT ) { if ( token == JsonToken . FIELD_NAME ) { if ( context . testExpression ( "href" ) ) { context . nextToken ( ) ; halLink . setHref ( context . readText ( ) ) ; } else if ( context . testExpression ( "name" ) ) { context . nextToken ( ) ; halLink . setName ( context . readText ( ) ) ; } else if ( context . testExpression ( "title" ) ) { context . nextToken ( ) ; halLink . setTitle ( context . readText ( ) ) ; } else if ( context . testExpression ( "templated" ) ) { context . nextToken ( ) ; halLink . setTemplated ( Boolean . valueOf ( context . readText ( ) ) ) ; } else if ( context . testExpression ( "deprecation" ) ) { context . nextToken ( ) ; halLink . setDeprecation ( context . readText ( ) ) ; } else { // Ignore this . Likely one of hreflang , profile , type
context . nextToken ( ) ; } } token = context . nextToken ( ) ; } return halLink ;


signature: public class HalJsonCurieUnmarshaller { @ Override public HalLink unmarshall ( JsonUnmarshallerContext context ) throws Exception { } }

implementation:
HalLink halLink = new HalLink ( ) ; JsonToken token = context . getCurrentToken ( ) ; // Ignore curies for now .
while ( token != null && token != JsonToken . END_OBJECT ) { token = context . nextToken ( ) ; } return halLink ;


signature:
public class LocationforecastLTSService { /** * Fetch a LocationforecastLTS from the MET API , based on longitude , latitude and altitude .
 * @ param longitude
 * The longitude of the location where the forecast should be fetched for .
 * @ param latitude
 * The latitude of the location where the forecast should be fetched for .
 * @ param altitude
 * The altitude of the location where the forecast should be fetched for .
 * @ return A MeteoData object containing response information and data converted into a LocationForcast object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < LocationForecast > fetchContent ( double longitude , double latitude , int altitude ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( PARAM_LATITUDE , latitude ) . addParameter ( PARAM_LONGITUDE , longitude ) . addParameter ( PARAM_ALTITUDE , altitude ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class SunriseService { /** * Fetch a Sunrise from the MET API based on a given longitude , latitude and date .
 * @ param longitude
 * The longitude of the location where the Sunrise should be fetched from .
 * @ param latitude
 * The latitude of the location where the Sunrise should be fetched from .
 * @ param date
 * The date to fetch the Sunrise object for .
 * @ return A MeteoData object containing response information and sunrise result converted into a Sunrise object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < Sunrise > fetchContent ( double longitude , double latitude , LocalDate date ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( PARAM_LATITUDE , latitude ) . addParameter ( PARAM_LONGITUDE , longitude ) . addParameter ( PARAM_DATE , zonedDateTimeToYyyyMMdd ( date ) ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class SunriseService { /** * Fetch a Sunrise from the MET API based on a given longitude , latitude and date range .
 * @ param longitude
 * The longitude of the location where the Sunrise should be fetched from .
 * @ param latitude
 * The latitude of the location where the Sunrise should be fetched from .
 * @ param from
 * The date to fetch the Sunrise object from .
 * @ param to
 * The date to fetch the Sunrise object to .
 * @ return A MeteoData object containing response information and sunrise result converted into a Sunrise object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < Sunrise > fetchContent ( double longitude , double latitude , LocalDate from , LocalDate to ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( PARAM_LATITUDE , latitude ) . addParameter ( PARAM_LONGITUDE , longitude ) . addParameter ( PARAM_FROM , zonedDateTimeToYyyyMMdd ( from ) ) . addParameter ( PARAM_TO , zonedDateTimeToYyyyMMdd ( to ) ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class LocationForecastHelper { /** * Get all point forecasts from now and to the given hours ahead .
 * @ param hoursAhead
 * The number of hours to look ahead for point forecasts .
 * @ return List of found forecasts . */
public List < MeteoExtrasForecast > findHourlyPointForecastsFromNow ( int hoursAhead ) { } }

implementation: List < MeteoExtrasForecast > pointExtrasForecasts = new ArrayList < > ( ) ; ZonedDateTime now = getNow ( ) ; for ( int i = 0 ; i < hoursAhead ; i ++ ) { ZonedDateTime ahead = now . plusHours ( i ) ; Optional < PointForecast > pointForecast = getIndexer ( ) . getPointForecast ( ahead ) ; pointForecast . ifPresent ( pof -> { Optional < PeriodForecast > periodForecast = getIndexer ( ) . getTightestFitPeriodForecast ( pof . getFrom ( ) ) ; periodForecast . ifPresent ( pef -> pointExtrasForecasts . add ( new MeteoExtrasForecast ( pof , pef ) ) ) ; } ) ; } return pointExtrasForecasts ;


signature:
public class LocationForecastHelper { /** * Get the most accurate forecast for the given date .
 * @ param dateTime
 * The date to get the forecast for .
 * @ return Optional containing the forecast if found , else { @ link Optional # empty ( ) } */
public Optional < MeteoExtrasForecast > findNearestForecast ( ZonedDateTime dateTime ) { } }

implementation: ZonedDateTime dt = toZeroMSN ( dateTime . withZoneSameInstant ( METZONE ) ) ; PointForecast chosenForecast = null ; for ( Forecast forecast : getLocationForecast ( ) . getForecasts ( ) ) { if ( forecast instanceof PointForecast ) { PointForecast pointForecast = ( PointForecast ) forecast ; if ( isDateMatch ( dt , cloneZonedDateTime ( pointForecast . getFrom ( ) ) ) ) { chosenForecast = pointForecast ; break ; } else if ( chosenForecast == null ) { chosenForecast = pointForecast ; } else if ( isNearerDate ( pointForecast . getFrom ( ) , dt , chosenForecast . getFrom ( ) ) ) { chosenForecast = pointForecast ; } } } if ( chosenForecast == null ) { return Optional . empty ( ) ; } return Optional . of ( new MeteoExtrasForecast ( chosenForecast , getIndexer ( ) . getWidestFitPeriodForecast ( chosenForecast . getFrom ( ) ) . orElse ( null ) ) ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maxTemperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMaxTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMaxTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . Symbol } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "symbol" , scope = LocationType . class ) public JAXBElement < LocationType . Symbol > createLocationTypeSymbol ( LocationType . Symbol value ) { } }

implementation: return new JAXBElement < LocationType . Symbol > ( _LocationTypeSymbol_QNAME , LocationType . Symbol . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "highestTemperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeHighestTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeHighestTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Windspeed } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "windGust" , scope = LocationType . class ) public JAXBElement < Windspeed > createLocationTypeWindGust ( Windspeed value ) { } }

implementation: return new JAXBElement < Windspeed > ( _LocationTypeWindGust_QNAME , Windspeed . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "currentDirection" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeCurrentDirection ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeCurrentDirection_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . StateOfTheSea } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "stateOfTheSea" , scope = LocationType . class ) public JAXBElement < LocationType . StateOfTheSea > createLocationTypeStateOfTheSea ( LocationType . StateOfTheSea value ) { } }

implementation: return new JAXBElement < LocationType . StateOfTheSea > ( _LocationTypeStateOfTheSea_QNAME , LocationType . StateOfTheSea . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "meanabsoluteerror" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeMeanabsoluteerror ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeMeanabsoluteerror_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Precipitation } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maximumPrecipitation" , scope = LocationType . class ) public JAXBElement < Precipitation > createLocationTypeMaximumPrecipitation ( Precipitation value ) { } }

implementation: return new JAXBElement < Precipitation > ( _LocationTypeMaximumPrecipitation_QNAME , Precipitation . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Tidalwater } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "tidalwater" , scope = LocationType . class ) public JAXBElement < Tidalwater > createLocationTypeTidalwater ( Tidalwater value ) { } }

implementation: return new JAXBElement < Tidalwater > ( _LocationTypeTidalwater_QNAME , Tidalwater . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "waveHeight" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeWaveHeight ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeWaveHeight_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Precipitation } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "precipitation" , scope = LocationType . class ) public JAXBElement < Precipitation > createLocationTypePrecipitation ( Precipitation value ) { } }

implementation: return new JAXBElement < Precipitation > ( _LocationTypePrecipitation_QNAME , Precipitation . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Score } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "score" , scope = LocationType . class ) public JAXBElement < Score > createLocationTypeScore ( Score value ) { } }

implementation: return new JAXBElement < Score > ( _LocationTypeScore_QNAME , Score . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Windspeed } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "areaMaxWindSpeed" , scope = LocationType . class ) public JAXBElement < Windspeed > createLocationTypeAreaMaxWindSpeed ( Windspeed value ) { } }

implementation: return new JAXBElement < Windspeed > ( _LocationTypeAreaMaxWindSpeed_QNAME , Windspeed . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . SnowDepth } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "snowDepth" , scope = LocationType . class ) public JAXBElement < LocationType . SnowDepth > createLocationTypeSnowDepth ( LocationType . SnowDepth value ) { } }

implementation: return new JAXBElement < LocationType . SnowDepth > ( _LocationTypeSnowDepth_QNAME , LocationType . SnowDepth . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Cloudiness } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "lowClouds" , scope = LocationType . class ) public JAXBElement < Cloudiness > createLocationTypeLowClouds ( Cloudiness value ) { } }

implementation: return new JAXBElement < Cloudiness > ( _LocationTypeLowClouds_QNAME , Cloudiness . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "minTemperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMinTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMinTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "bias" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeBias ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeBias_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "temperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . Weather } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "weather" , scope = LocationType . class ) public JAXBElement < LocationType . Weather > createLocationTypeWeather ( LocationType . Weather value ) { } }

implementation: return new JAXBElement < LocationType . Weather > ( _LocationTypeWeather_QNAME , LocationType . Weather . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "humidity" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeHumidity ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeHumidity_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "numberofobservations" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeNumberofobservations ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeNumberofobservations_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . WindDirection } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "windDirection" , scope = LocationType . class ) public JAXBElement < LocationType . WindDirection > createLocationTypeWindDirection ( LocationType . WindDirection value ) { } }

implementation: return new JAXBElement < LocationType . WindDirection > ( _LocationTypeWindDirection_QNAME , LocationType . WindDirection . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maxTemperatureDay" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMaxTemperatureDay ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMaxTemperatureDay_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Windspeed } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "windSpeed" , scope = LocationType . class ) public JAXBElement < Windspeed > createLocationTypeWindSpeed ( Windspeed value ) { } }

implementation: return new JAXBElement < Windspeed > ( _LocationTypeWindSpeed_QNAME , Windspeed . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "wavePeriod" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeWavePeriod ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeWavePeriod_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "minTemperatureNight" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMinTemperatureNight ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMinTemperatureNight_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Uv } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "uv" , scope = LocationType . class ) public JAXBElement < Uv > createLocationTypeUv ( Uv value ) { } }

implementation: return new JAXBElement < Uv > ( _LocationTypeUv_QNAME , Uv . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Cloudiness } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "highClouds" , scope = LocationType . class ) public JAXBElement < Cloudiness > createLocationTypeHighClouds ( Cloudiness value ) { } }

implementation: return new JAXBElement < Cloudiness > ( _LocationTypeHighClouds_QNAME , Cloudiness . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maxTemperatureNight" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMaxTemperatureNight ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMaxTemperatureNight_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "windProbability" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeWindProbability ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeWindProbability_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maxWaveHeight" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeMaxWaveHeight ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeMaxWaveHeight_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "surfaceTemperature" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeSurfaceTemperature ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeSurfaceTemperature_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Pressure } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "pressure" , scope = LocationType . class ) public JAXBElement < Pressure > createLocationTypePressure ( Pressure value ) { } }

implementation: return new JAXBElement < Pressure > ( _LocationTypePressure_QNAME , Pressure . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Cloudiness } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "cloudiness" , scope = LocationType . class ) public JAXBElement < Cloudiness > createLocationTypeCloudiness ( Cloudiness value ) { } }

implementation: return new JAXBElement < Cloudiness > ( _LocationTypeCloudiness_QNAME , Cloudiness . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "waveDirection" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeWaveDirection ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeWaveDirection_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "symbolProbability" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeSymbolProbability ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeSymbolProbability_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link UnitValue } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "temperatureProbability" , scope = LocationType . class ) public JAXBElement < UnitValue > createLocationTypeTemperatureProbability ( UnitValue value ) { } }

implementation: return new JAXBElement < UnitValue > ( _LocationTypeTemperatureProbability_QNAME , UnitValue . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Groundcover } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "groundCover" , scope = LocationType . class ) public JAXBElement < Groundcover > createLocationTypeGroundCover ( Groundcover value ) { } }

implementation: return new JAXBElement < Groundcover > ( _LocationTypeGroundCover_QNAME , Groundcover . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "minTemperatureDay" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeMinTemperatureDay ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeMinTemperatureDay_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Windspeed } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "maxWindSpeed" , scope = LocationType . class ) public JAXBElement < Windspeed > createLocationTypeMaxWindSpeed ( Windspeed value ) { } }

implementation: return new JAXBElement < Windspeed > ( _LocationTypeMaxWindSpeed_QNAME , Windspeed . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link LocationType . ForestFire } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "forest-fire" , scope = LocationType . class ) public JAXBElement < LocationType . ForestFire > createLocationTypeForestFire ( LocationType . ForestFire value ) { } }

implementation: return new JAXBElement < LocationType . ForestFire > ( _LocationTypeForestFire_QNAME , LocationType . ForestFire . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Cloudiness } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "mediumClouds" , scope = LocationType . class ) public JAXBElement < Cloudiness > createLocationTypeMediumClouds ( Cloudiness value ) { } }

implementation: return new JAXBElement < Cloudiness > ( _LocationTypeMediumClouds_QNAME , Cloudiness . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "dewpointTemperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeDewpointTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeDewpointTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Temperature } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "lowestTemperature" , scope = LocationType . class ) public JAXBElement < Temperature > createLocationTypeLowestTemperature ( Temperature value ) { } }

implementation: return new JAXBElement < Temperature > ( _LocationTypeLowestTemperature_QNAME , Temperature . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Cloudiness } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "fog" , scope = LocationType . class ) public JAXBElement < Cloudiness > createLocationTypeFog ( Cloudiness value ) { } }

implementation: return new JAXBElement < Cloudiness > ( _LocationTypeFog_QNAME , Cloudiness . class , LocationType . class , value ) ;


signature:
public class TextforecastService { /** * Fetch a textforecast for a named forecast
 * @ param query
 * One of the predefined available textforecasts .
 * @ return A MeteoData object containing response information and textforecast converted into an Weather object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < Weather > fetchContent ( ForecastQuery query ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( "forecast" , query . getName ( ) ) . addParameter ( "language" , query . getLanguage ( ) . getValue ( ) ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class LongtermForecastHelper { /** * Create a longterm forecast , but only with a small subset of the weather data fields . Typically for use in simple
 * weather reports where you only show the predicted weather icon and temperature , and not all the weather details .
 * @ return A long term forecast , which is a week in our view of the world .
 * @ throws MeteoException
 * If an error occurred while creating the simple longterm forecast . */
public MeteoExtrasLongTermForecast createSimpleLongTermForecast ( ) throws MeteoException { } }

implementation: List < MeteoExtrasForecastDay > forecastDays = new ArrayList < > ( ) ; ZonedDateTime dt = getNow ( ) ; for ( int i = 0 ; i <= 6 ; i ++ ) { ZonedDateTime dti = dt . plusDays ( i ) ; if ( getIndexer ( ) . hasForecastsForDay ( dti ) ) { MeteoExtrasForecastDay mefd = createSimpleForcastForDay ( dti ) ; if ( mefd != null && mefd . getForecasts ( ) . size ( ) > 0 ) { forecastDays . add ( mefd ) ; } } } return new MeteoExtrasLongTermForecast ( forecastDays ) ;


signature:
public class LongtermForecastHelper { /** * Create a longterm forecast .
 * @ return A long term forecast , which is a week in our view of the world . But how many days you will get in this
 * forecast depends on the given location forecast . So from 0-7 can be expected . */
public MeteoExtrasLongTermForecast createLongTermForecast ( ) { } }

implementation: List < MeteoExtrasForecastDay > forecastDays = new ArrayList < > ( ) ; ZonedDateTime dt = toZeroHMSN ( getLocationForecast ( ) . getCreated ( ) . plusDays ( 1 ) ) ; for ( int i = 0 ; i < series . getSeries ( ) . size ( ) ; i ++ ) { createLongTermForecastDay ( dt . plusDays ( i ) , series . getSeries ( ) . get ( i ) ) . ifPresent ( forecastDays :: add ) ; } return new MeteoExtrasLongTermForecast ( forecastDays ) ;


signature:
public class Location { /** * Create an untitled Location from coordinate string .
 * @ param coordinates Coordinate string on the format longitude , latitude , altitude . Eg : 20.3,123.3,123 or 20.3,123.3
 * @ return Instance of the location with the coordinates from the input string . */
public static Location fromCoordinates ( String coordinates ) { } }

implementation: if ( coordinates == null ) { throw new IllegalArgumentException ( "Cannot create Location from null input." ) ; } Matcher m = P . matcher ( coordinates ) ; if ( ! m . matches ( ) ) { throw new IllegalArgumentException ( coordinates + " must be on the pattern (longitude,latitude,altitude) : " + P . pattern ( ) ) ; } try { Double longitude = Double . valueOf ( m . group ( 1 ) ) ; Double latitude = Double . valueOf ( m . group ( 2 ) ) ; Integer altitude = 0 ; if ( m . group ( 3 ) != null ) { altitude = Integer . valueOf ( m . group ( 3 ) . substring ( 1 ) ) ; } return new Location ( longitude , latitude , altitude , "" ) ; } catch ( NumberFormatException e ) { throw new IllegalArgumentException ( coordinates + " must be on the pattern (longitude,latitude,altitude) : " + P . pattern ( ) ) ; }


signature:
public class AvailableTextforecastsService { /** * Fetch a list of all available textforecasts .
 * @ return A MeteoData object containing response information and available textforecasts converted into an
 * Available object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < Available > fetchContent ( ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( "available" , null ) . skipQuestionMarkInUrl ( ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link Probability } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "probability" , scope = LocationType . class ) public JAXBElement < Probability > createLocationTypeProbability ( Probability value ) { } }

implementation: return new JAXBElement < Probability > ( _LocationTypeProbability_QNAME , Probability . class , LocationType . class , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link String } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "productdescription" ) public JAXBElement < String > createProductdescription ( String value ) { } }

implementation: return new JAXBElement < String > ( _Productdescription_QNAME , String . class , null , value ) ;


signature:
public class ObjectFactory { /** * Create an instance of { @ link JAXBElement } { @ code < } { @ link String } { @ code > } } */
@ XmlElementDecl ( namespace = "" , name = "header" ) public JAXBElement < String > createHeader ( String value ) { } }

implementation: return new JAXBElement < String > ( _Header_QNAME , String . class , null , value ) ;


signature:
public class WindSymbolHelper { /** * Create name for a wind symbol .
 * This will be created as a mix of the Beaufort wind speed id and the wind direction . This name can be used to
 * identify what wind icon that should be used for a forecast .
 * @ param pointForecast
 * The point forecast to create a wind symbol name for .
 * @ return A wind symbol name . < code > null < / code > if wind information was missing from the given point forecast . */
public static Optional < String > createWindSymbolName ( PointForecast pointForecast ) { } }

implementation: if ( pointForecast == null || pointForecast . getWindDirection ( ) == null || pointForecast . getWindSpeed ( ) == null ) { return Optional . empty ( ) ; } return Optional . of ( pointForecast . getWindDirection ( ) . getName ( ) . toLowerCase ( ) + idFormat . format ( pointForecast . getWindSpeed ( ) . getBeaufort ( ) ) ) ;


signature:
public class WindSymbolHelper { /** * Find matching Beaufort level for a given point forecast .
 * This provides you with extra information about the wind speed specified in the forecast .
 * @ param pointForecast
 * Point forecast containing information about the wind speed .
 * @ return Matching Beaufort level object . < code > null < / code > if wind speed information is missing from the given
 * forecast . */
public static Optional < BeaufortLevel > findBeaufortLevel ( PointForecast pointForecast ) { } }

implementation: if ( pointForecast == null || pointForecast . getWindSpeed ( ) == null ) { return Optional . empty ( ) ; } return Optional . ofNullable ( findUnitById ( pointForecast . getWindSpeed ( ) . getBeaufort ( ) ) ) ;


signature:
public class MeteoNetUtils { /** * Wrap the construction of URL ' s to avoid throwing of checked MalformedURLException . Instead MeteoException
 * is thrown .
 * @ param uri The url string to be used as the spec for the create URL object .
 * @ return URL object created from the given url spec .
 * @ throws no . api . meteo . MeteoException If a URL couldn ' t be created from the given url spec . */
public static URI createUri ( String uri ) throws MeteoException { } }

implementation: if ( uri == null ) { throw new MeteoException ( "URI is null" ) ; } try { return new URI ( uri ) ; } catch ( URISyntaxException e ) { throw new MeteoException ( e ) ; }


signature:
public class SunriseDate { /** * Check if the sun is shining for a given time .
 * @ param currentDate
 * The time ( date ) to be checked .
 * @ return < code > true < / code > if the sun has raised , else < code > false < / code > . */
public boolean isSun ( ZonedDateTime currentDate ) { } }

implementation: if ( getSun ( ) . getNeverRise ( ) ) { return false ; } else if ( getSun ( ) . getNeverSet ( ) ) { return true ; } return timeWithinPeriod ( currentDate ) ;


signature:
public class MeteoForecastIndexer { /** * Get the PointForecast that matches the given time .
 * @ param dateTime
 * Date object used to find a matching PointForecast .
 * @ return A matching PointForecast if found , else < code > null < / code > . */
Optional < PointForecast > getPointForecast ( ZonedDateTime dateTime ) { } }

implementation: for ( Forecast forecast : forecasts ) { if ( forecast instanceof PointForecast ) { PointForecast pointForecast = ( PointForecast ) forecast ; if ( createHourIndexKey ( dateTime ) . equals ( createHourIndexKey ( cloneZonedDateTime ( pointForecast . getFrom ( ) ) ) ) ) { return Optional . of ( pointForecast ) ; } } } return Optional . empty ( ) ;


signature:
public class MeteoForecastIndexer { /** * Find the period forecast that is the widest fit for a point forecast .
 * < p > We use the exact same kind of logic to find the widest fit as we do for the tightest fit . The only change is
 * that we invert the span tightScore . Meaning that a large span will tightScore lower than a small span < / p > */
Optional < PeriodForecast > getWidestFitPeriodForecast ( ZonedDateTime from ) { } }

implementation: if ( from == null ) { return Optional . empty ( ) ; } return getWidestFitScoreForecast ( from ) . map ( ScoreForecast :: getPeriodForecast ) ;


signature:
public class MeteoForecastIndexer { /** * Find the period forecast that has the best fitted forecast for a given period .
 * This means a forecast covering the requested period , with to and from time closest possible to that period . If
 * this function only can find a period forecast that covers parts of the requested period , then the forecast
 * covering the most will be used . */
Optional < PeriodForecast > getBestFitPeriodForecast ( ZonedDateTime from , ZonedDateTime to ) { } }

implementation:
if ( from == null || to == null ) { return Optional . empty ( ) ; } // Making sure that we remove minutes , seconds and milliseconds from the request timestamps
ZonedDateTime requestFrom = toZeroMSN ( from ) ; ZonedDateTime requestTo = toZeroMSN ( to ) ; // Get list of period forecasts for the requested day . Return empty if date isn ' t present
List < PeriodForecast > forecastsList = dayIndex . get ( new DayIndexKey ( requestFrom ) ) ; if ( forecastsList == null ) { return Optional . empty ( ) ; } PeriodForecast chosenForecast = null ; long score = 0 ; long tmpScore = 0 ; for ( PeriodForecast forecast : forecastsList ) { ZonedDateTime actualFrom = cloneZonedDateTime ( forecast . getFrom ( ) ) ; ZonedDateTime actualTo = cloneZonedDateTime ( forecast . getTo ( ) ) ; if ( requestFrom . equals ( actualFrom ) && requestTo . equals ( actualTo ) ) { return Optional . of ( forecast ) ; } else if ( ( requestFrom . isBefore ( actualFrom ) && requestTo . isBefore ( actualFrom ) ) || ( requestFrom . isAfter ( actualTo ) && requestTo . isAfter ( actualTo ) ) || actualTo . isEqual ( actualFrom ) ) { continue ; // this period is outside the requested period or this is a point forecast .
} else if ( requestFrom . isBefore ( actualFrom ) && requestTo . isBefore ( actualTo ) ) { tmpScore = hoursBetween ( requestTo , actualFrom ) ; } else if ( ( actualFrom . isBefore ( requestFrom ) || actualFrom . isEqual ( requestFrom ) ) && actualTo . isBefore ( requestTo ) ) { tmpScore = hoursBetween ( actualTo , requestFrom ) ; } else if ( actualFrom . isAfter ( requestFrom ) && ( actualTo . isBefore ( requestTo ) || actualTo . isEqual ( requestTo ) ) ) { tmpScore = hoursBetween ( actualTo , actualFrom ) ; } else if ( actualFrom . isBefore ( requestFrom ) && actualTo . isAfter ( requestTo ) ) { tmpScore = hoursBetween ( requestTo , requestFrom ) ; } else { DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd:HH:mm" ) ; log . warn ( "Unhandled forecast Requested period:" + requestFrom . format ( formatter ) + "--" + requestTo . format ( formatter ) + ", Actual period: " + actualFrom . format ( formatter ) + "--" + actualTo . format ( formatter ) ) ; } tmpScore = Math . abs ( tmpScore ) ; if ( ( score == 0 && tmpScore > 0 ) || tmpScore > score ) { score = tmpScore ; chosenForecast = forecast ; } } return Optional . ofNullable ( chosenForecast ) ;


signature:
public class TextLocationService { /** * Fetch textforecasts and warnings for a geographical point or area , in Norwegian .
 * @ param longitude
 * The longitude for the geographical point .
 * @ param latitude
 * The latitude for the geographical point .
 * @ return A MeteoData object containing response information and textforecast converted into an TextLocationWeather
 * object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < TextLocationWeather > fetchContent ( double longitude , double latitude ) throws MeteoException { } }

implementation: return fetchContent ( longitude , latitude , TextLocationLanguage . NB ) ;


signature:
public class TextLocationService { /** * Fetch textforecasts and warnings for a geographical point or area .
 * @ param longitude
 * The longitude for the geographical point .
 * @ param latitude
 * The latitude for the geographical point .
 * @ param language
 * The chosen language for the forecast . Note that textforecasts in english are available for only some
 * areas and some types ( e . g textforecasts for the coastal areas ) .
 * @ return A MeteoData object containing response information and textforecast converted into an TextLocationWeather
 * object .
 * @ throws MeteoException
 * If a problem occurred while fetching or parsing the MET data . */
public MeteoData < TextLocationWeather > fetchContent ( double longitude , double latitude , TextLocationLanguage language ) throws MeteoException { } }

implementation: MeteoResponse response = getMeteoClient ( ) . fetchContent ( createServiceUriBuilder ( ) . addParameter ( "latitude" , latitude ) . addParameter ( "longitude" , longitude ) . addParameter ( "language" , language . getValue ( ) ) . build ( ) ) ; return new MeteoData < > ( parser . parse ( response . getData ( ) ) , response ) ;


signature:
public class FileConfigurationSource { /** * Retrieves the file extensions to use with the specified decoder .
 * If the specified Decoder doesn ' t have any file extensions explicitly associated with it , then a single empty string is returned . */
private static String [ ] getFileExtensions ( final Decoder decoder ) { } }

implementation: final Class < ? extends Decoder > decoderClass = decoder . getClass ( ) ; final FileExtensions fileExtensionsAnnotation = decoderClass . getAnnotation ( FileExtensions . class ) ; return ( fileExtensionsAnnotation == null ) ? new String [ ] { "" } : fileExtensionsAnnotation . value ( ) ;


signature:
public class FileConfigurationSource { /** * Convert a ( partial ) ServicePath into a file name to access . The file names are in the format
 * " cfg _ group _ subgroup _ appid _ ConfigurationClass [ . ext ] " .
 * @ param configClass the configuration class to try and acquire
 * @ param servicePath the partial or complete ServicePath in Name format
 * @ param fileNameDelimiter the symbol used to separate cfg , group , subgroup , appid and ConfigurationClass
 * @ param extension the file extension , or an empty string if there is no extension
 * @ return the constructed file name to try and access */
private String nameToFile ( final Class configClass , final Name servicePath , final String fileNameDelimiter , final String extension ) { } }

implementation: StringBuilder builder = new StringBuilder ( "cfg" ) ; for ( final String component : servicePath ) { builder . append ( fileNameDelimiter ) . append ( component ) ; } builder . append ( fileNameDelimiter ) . append ( configClass . getSimpleName ( ) ) ; if ( ! extension . isEmpty ( ) ) { builder . append ( '.' ) . append ( extension ) ; } return builder . toString ( ) ;


signature:
public class Application { /** * Checks connection , retrieves appropriate changelog and performs database update .
 * @ throws SQLException
 * @ throws LiquibaseException */
private void updateDB ( ) throws SQLException , LiquibaseException { } }

implementation:
System . out . println ( "About to perform DB update." ) ; try ( BasicDataSource dataSource = new BasicDataSource ( ) ) { dataSource . setUrl ( fullConnectionString ) ; dataSource . setUsername ( username ) ; dataSource . setPassword ( password ) ; try ( java . sql . Connection c = dataSource . getConnection ( ) ) { Database database = DatabaseFactory . getInstance ( ) . findCorrectDatabaseImplementation ( new JdbcConnection ( c ) ) ; // Check that the Database does indeed exist before we try to run the liquibase update .
Liquibase liquibase = null ; ClassLoaderResourceAccessor accessor = new ClassLoaderResourceAccessor ( ) ; try { if ( accessor . getResourcesAsStream ( "changelog-master.xml" ) != null ) { liquibase = new Liquibase ( "changelog-master.xml" , new ClassLoaderResourceAccessor ( ) , database ) ; } else if ( accessor . getResourcesAsStream ( "changelog.xml" ) != null ) { liquibase = new Liquibase ( "changelog.xml" , new ClassLoaderResourceAccessor ( ) , database ) ; } else { String errorMessage = "No liquibase changelog-master.xml or changelog.xml could be located" ; Logger . getLogger ( Application . class . getName ( ) ) . log ( Level . SEVERE , errorMessage , this ) ; throw new RuntimeException ( errorMessage ) ; } } catch ( final IOException ioe ) { Logger . getLogger ( Application . class . getName ( ) ) . log ( Level . SEVERE , ioe . getMessage ( ) , ioe ) ; } liquibase . getLog ( ) . setLogLevel ( logLevel ) ; liquibase . update ( new Contexts ( ) ) ; System . out . println ( "DB update finished." ) ; } }


signature:
public class JavascriptDecoder { /** * Executes the specified script . The source of the script is supplied as a UTF - 8 encoded { @ code InputStream } . The default
 * { @ code ScriptContext } for the { @ code ScriptEngine } is used .
 * @ param scriptEngine the scripting engine
 * @ param stream the source of the script , encoded in UTF - 8
 * @ return the value returned by the script
 * @ throws IOException if the { @ code InputStream } cannot be read
 * @ throws ScriptException if an error occurs in the script */
private static Object evaluateScript ( final ScriptEngine scriptEngine , final InputStream stream ) throws IOException , ScriptException { } }

implementation: try ( final InputStreamReader reader = new InputStreamReader ( stream , StandardCharsets . UTF_8 ) ) { return scriptEngine . eval ( reader ) ; }