signature:
public class GenericAssert { /** * Verifies that the actual value satisfies the given condition .
 * @ param condition the given condition .
 * @ return this assertion object .
 * @ throws NullPointerException if the given condition is { @ code null } .
 * @ throws AssertionError if the actual value does not satisfy the given condition .
 * @ see # is ( Condition ) */
public final @ NotNull S satisfies ( @ NotNull Condition < A > condition ) { } }

implementation: if ( matches ( condition ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( errorMessageIfConditionNotSatisfied ( condition ) ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value does not satisfy the given condition .
 * @ param condition the given condition .
 * @ return this assertion object .
 * @ throws NullPointerException if the given condition is { @ code null } .
 * @ throws AssertionError if the actual value satisfies the given condition .
 * @ see # isNot ( Condition ) */
public final @ NotNull S doesNotSatisfy ( @ NotNull Condition < A > condition ) { } }

implementation: if ( ! matches ( condition ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( errorMessageIfConditionSatisfied ( condition ) ) ;


signature:
public class GenericAssert { /** * Alias for { @ link # satisfies ( Condition ) } .
 * @ param condition the given condition .
 * @ return this assertion object .
 * @ throws NullPointerException if the given condition is { @ code null } .
 * @ throws AssertionError if the actual value does not satisfy the given condition .
 * @ since 1.2 */
public final @ NotNull S is ( @ NotNull Condition < A > condition ) { } }

implementation: if ( matches ( condition ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( errorMessageIfIsNot ( condition ) ) ;


signature:
public class GenericAssert { /** * Alias for { @ link # doesNotSatisfy ( Condition ) } .
 * @ param condition the given condition .
 * @ return this assertion object .
 * @ throws NullPointerException if the given condition is { @ code null } .
 * @ throws AssertionError if the actual value satisfies the given condition .
 * @ since 1.2 */
public final @ NotNull S isNot ( @ NotNull Condition < A > condition ) { } }

implementation: if ( ! matches ( condition ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( errorMessageIfIs ( condition ) ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is equal to the given one .
 * @ param expected the given value to compare the actual value to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is not equal to the given one . */
public @ NotNull S isEqualTo ( @ Nullable A expected ) { } }

implementation: failIfNotEqual ( customErrorMessage ( ) , rawDescription ( ) , actual , expected ) ; return myself ( ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is not equal to the given one .
 * @ param other the given value to compare the actual value to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is equal to the given one . */
public @ NotNull S isNotEqualTo ( @ Nullable A other ) { } }

implementation: failIfEqual ( customErrorMessage ( ) , rawDescription ( ) , actual , other ) ; return myself ( ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is the same as the given one .
 * @ param expected the given value to compare the actual value to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is not the same as the given one . */
public final @ NotNull S isSameAs ( @ Nullable A expected ) { } }

implementation: failIfNotSame ( customErrorMessage ( ) , rawDescription ( ) , actual , expected ) ; return myself ( ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is not the same as the given one .
 * @ param other the given value to compare the actual value to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is the same as the given one . */
public final @ NotNull S isNotSameAs ( @ Nullable A other ) { } }

implementation: failIfSame ( customErrorMessage ( ) , rawDescription ( ) , actual , other ) ; return myself ( ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is in the given collection .
 * @ param values the given collection to search the actual value in . must not be null .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is not in the given collection .
 * @ throws NullPointerException if the given collection is null . */
public final @ NotNull S isIn ( @ NotNull Collection < ? > values ) { } }

implementation: checkNotNull ( values ) ; if ( isActualIn ( values ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedNotIn ( actual , values ) ) ;


signature:
public class GenericAssert { /** * Verifies that the actual value is in the given collection .
 * @ param values the given collection to search the actual value in . must not be null .
 * @ return this assertion object .
 * @ throws AssertionError if the actual value is not in the given collection .
 * @ throws NullPointerException if the given collection is null . */
public final @ NotNull S isNotIn ( @ NotNull Collection < ? > values ) { } }

implementation: checkNotNull ( values ) ; if ( ! isActualIn ( values ) ) { return myself ( ) ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedIn ( actual , values ) ) ;


signature:
public class DoubleArrayAssert { /** * Verifies that the actual { @ code double } array is equal to the given array , within a positive delta .
 * @ param expected the given array to compare the actual array to .
 * @ param delta the given delta .
 * @ return this assertion object .
 * @ throws NullPointerException if { @ code delta } is { @ code null } .
 * @ throws AssertionError if the actual { @ code double } array is not equal to the given one .
 * @ since 1.1 */
public @ NotNull DoubleArrayAssert isEqualTo ( @ Nullable double [ ] expected , @ NotNull Delta delta ) { } }

implementation: checkNotNull ( delta ) ; if ( actual == expected ) { return this ; } if ( actual == null || expected == null ) { throw failureWhenNotEqual ( expected , delta ) ; } int length = expected . length ; if ( actual . length != length ) { failureWhenNotEqual ( expected , delta ) ; } for ( int i = 0 ; i < length ; i ++ ) { if ( ! equals ( expected [ i ] , actual [ i ] , delta ) ) { failureWhenNotEqual ( expected , delta ) ; } } return this ;


signature:
public class DoubleArrayAssert { /** * Verifies that the actual { @ code double } array is not equal to the given array . Array equality is checked by
 * { @ link Arrays # equals ( double [ ] , double [ ] ) } .
 * @ param array the given array to compare the actual array to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code double } array is equal to the given one . */
@ Override public @ NotNull DoubleArrayAssert isNotEqualTo ( @ Nullable double [ ] array ) { } }

implementation: if ( ! Arrays . equals ( actual , array ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedEqual ( actual , array ) ) ;


signature:
public class ObjectArrayAssert { /** * Verifies that all the elements in the actual { @ code Object } array belong to the specified type . Matching includes
 * subclasses of the given type .
 * For example , consider the following code listing :
 * < pre >
 * Number [ ] numbers = { 2 , 6 , 8 } ;
 * assertThat ( numbers ) . hasAllElementsOfType ( Integer . class ) ;
 * < / pre >
 * The assertion { @ code hasAllElementsOfType } will be successful .
 * @ param type the expected type .
 * @ return this assertion object .
 * @ throws NullPointerException if the given type is { @ code null } .
 * @ throws AssertionError if the component type of the actual { @ code Object } array is not the same as the specified
 * one . */
public @ NotNull ObjectArrayAssert hasAllElementsOfType ( @ NotNull Class < ? > type ) { } }

implementation: checkNotNull ( type ) ; isNotNull ( ) ; for ( Object o : actual ) { if ( type . isInstance ( o ) ) { continue ; } failIfCustomMessageIsSet ( ) ; fail ( format ( "not all elements in array:<%s> belong to the type:<%s>" , actual , type ) ) ; } return this ;


signature:
public class ObjectArrayAssert { /** * Verifies that at least one element in the actual { @ code Object } array belong to the specified type . Matching
 * includes subclasses of the given type .
 * @ param type the expected type .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Object } does not have any elements of the given type . */
public @ NotNull ObjectArrayAssert hasAtLeastOneElementOfType ( @ NotNull Class < ? > type ) { } }

implementation: checkNotNull ( type ) ; isNotNull ( ) ; boolean found = false ; for ( Object o : actual ) { if ( ! type . isInstance ( o ) ) { continue ; } found = true ; break ; } if ( found ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "array:<%s> does not have any elements of type:<%s>" , actual , type ) ) ;


signature:
public class ObjectArrayAssert { /** * Verifies that the actual { @ code Object } array is equal to the given array . Array equality is checked by
 * { @ link Arrays # deepEquals ( Object [ ] , Object [ ] ) } .
 * @ param expected the given array to compare the actual array to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Object } array is not equal to the given one . */
@ Override public @ NotNull ObjectArrayAssert isEqualTo ( @ Nullable Object [ ] expected ) { } }

implementation: if ( Arrays . deepEquals ( actual , expected ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedNotEqual ( actual , expected ) ) ;


signature:
public class ObjectArrayAssert { /** * Verifies that the actual { @ code Object } array is not equal to the given array . Array equality is checked by
 * { @ link Arrays # deepEquals ( Object [ ] , Object [ ] ) } .
 * @ param array the given array to compare the actual array to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Object } array is equal to the given one . */
@ Override public @ NotNull ObjectArrayAssert isNotEqualTo ( @ Nullable Object [ ] array ) { } }

implementation: if ( ! Arrays . deepEquals ( actual , array ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedEqual ( actual , array ) ) ;


signature:
public class ObjectArrayAssert { /** * Creates a new instance of { @ link ObjectArrayAssert } whose target array contains the values of the
 * given property name from the elements of this { @ code ObjectArrayAssert } ' s array . Property access works with both
 * simple properties like { @ code Person . age } and nested properties { @ code Person . father . age } .
 * For example , let ' s say we have a array of { @ code Person } objects and you want to verify their age :
 * < pre >
 * assertThat ( persons ) . onProperty ( & quot ; age & quot ; ) . containsOnly ( 25 , 16 , 44 , 37 ) ; / / simple property
 * assertThat ( persons ) . onProperty ( " father . age " ) . containsOnly ( 55 , 46 , 74 , 62 ) ; / / nested property
 * @ param propertyName the name of the property to extract values from the actual array to build a new
 * { @ code ObjectArrayAssert } .
 * @ return a new { @ code ObjectArrayAssert } containing the values of the given property name from the elements of this
 * { @ code ObjectArrayAssert } ' s array .
 * @ throws AssertionError if the actual array is { @ code null } .
 * @ throws IntrospectionError if an element in the given array does not have a matching property .
 * @ since 1.3 */
@ Override public @ NotNull ObjectArrayAssert onProperty ( @ NotNull String propertyName ) { } }

implementation: isNotNull ( ) ; if ( actual . length == 0 ) { return new ObjectArrayAssert ( new Object [ 0 ] ) ; } List < Object > values = PropertySupport . instance ( ) . propertyValues ( propertyName , newArrayList ( actual ) ) ; return new ObjectArrayAssert ( values . toArray ( ) ) ;


signature:
public class Assert { /** * Sets the description of the actual value , to be used in as message of any { @ code AssertionError } thrown when an
 * assertion fails .
 * @ param d the new description . */
protected final void description ( @ Nullable String d ) { } }

implementation: description ( d == null ? null : new BasicDescription ( d ) ) ;


signature:
public class Assert { /** * Fails by throwing an { @ code AssertionError } .
 * @ param reason the reason for the failure , used as the message for the thrown exception .
 * @ param cause the root cause of the failure , included in the thrown exception .
 * @ throws NullPointerException if the given reason is { @ code null } . */
protected final void fail ( @ NotNull String reason , @ Nullable Throwable cause ) { } }

implementation: Fail . fail ( formattedErrorMessage ( reason ) , cause ) ;


signature:
public class Assert { /** * Creates an { @ code AssertionError } , adding the description of the actual value to the given message .
 * @ param reason the reason for the failure , used as the message for the thrown exception .
 * @ return the created exception . */
protected final @ NotNull AssertionError failure ( @ NotNull String reason ) { } }

implementation: return Fail . failure ( formattedErrorMessage ( reason ) ) ;


signature:
public class ByteAssert { /** * Verifies that the actual { @ code Byte } value is greater than the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Byte } value is not greater than the given one . */
public @ NotNull ByteAssert isGreaterThan ( byte other ) { } }

implementation:
// TODO check for NPE
if ( actual > other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedLessThanOrEqualTo ( actual , other ) ) ;


signature:
public class ByteAssert { /** * Verifies that the actual { @ code Byte } value is less than the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Byte } value is not less than the given one . */
public @ NotNull ByteAssert isLessThan ( byte other ) { } }

implementation: if ( actual < other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedGreaterThanOrEqualTo ( actual , other ) ) ;


signature:
public class ByteAssert { /** * Verifies that the actual { @ code Byte } value is greater or equal to the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Byte } value is not greater than or equal to the given one . */
public @ NotNull ByteAssert isGreaterThanOrEqualTo ( byte other ) { } }

implementation: if ( actual >= other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedLessThan ( actual , other ) ) ;


signature:
public class ByteAssert { /** * Verifies that the actual { @ code Byte } value is less or equal to the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Byte } value is not less than or equal to the given one . */
public @ NotNull ByteAssert isLessThanOrEqualTo ( byte other ) { } }

implementation: if ( actual <= other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedGreaterThan ( actual , other ) ) ;


signature:
public class CollectionAssert { /** * Creates a new instance of { @ link CollectionAssert } whose target collection contains the values of the given
 * property name from the elements of this { @ code CollectionAssert } ' s collection . Property access works with both
 * simple properties like { @ code Person . age } and nested properties { @ code Person . father . age } .
 * For example , let ' s say we have a collection of { @ code Person } objects and you want to verify their age :
 * < pre >
 * assertThat ( persons ) . onProperty ( & quot ; age & quot ; ) . containsOnly ( 25 , 16 , 44 , 37 ) ; / / simple property
 * assertThat ( persons ) . onProperty ( " father . age " ) . containsOnly ( 55 , 46 , 74 , 62 ) ; / / nested property
 * < / pre >
 * @ param propertyName the name of the property to extract values from the actual collection to build a new
 * { @ code CollectionAssert } .
 * @ return a new { @ code CollectionAssert } containing the values of the given property name from the elements of this
 * { @ code CollectionAssert } ' s collection .
 * @ throws AssertionError if the actual collection is { @ code null } .
 * @ throws NullPointerException if the given property name is { @ code null } .
 * @ throws IntrospectionError if an element in the given collection does not have a matching property .
 * @ since 1.3 */
@ Override public @ NotNull CollectionAssert onProperty ( @ NotNull String propertyName ) { } }

implementation: isNotNull ( ) ; checkNotNull ( propertyName ) ; if ( actual . isEmpty ( ) ) { return new CollectionAssert ( emptyList ( ) ) ; } return new CollectionAssert ( PropertySupport . instance ( ) . propertyValues ( propertyName , actual ) ) ;


signature:
public class IntArrayAssert { /** * Verifies that the actual { @ code int } array is equal to the given array . Array equality is checked by
 * { @ link Arrays # equals ( int [ ] , int [ ] ) } .
 * @ param expected the given array to compare the actual array to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code int } array is not equal to the given one . */
@ Override public @ NotNull IntArrayAssert isEqualTo ( @ Nullable int [ ] expected ) { } }

implementation: if ( Arrays . equals ( actual , expected ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedNotEqual ( actual , expected ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } is equal to the given one ignoring case .
 * @ param expected the given { @ code String } to compare the actual { @ code String } to .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } is not equal to the given one ignoring case . */
public @ NotNull StringAssert isEqualToIgnoringCase ( String expected ) { } }

implementation: if ( actual == null && expected == null ) { return this ; } isNotNull ( ) ; if ( actual . equalsIgnoreCase ( expected ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should be equal to :<%s> ignoring case" , actual , expected ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } contains the given one .
 * @ param expected the given { @ code String } expected to be contained in the actual one .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } does not contain the given one . */
public @ NotNull StringAssert contains ( String expected ) { } }

implementation: isNotNull ( ) ; if ( actual . indexOf ( expected ) != - 1 ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should contain the String:<%s>" , actual , expected ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } ends with the given one .
 * @ param expected the given { @ code String } expected to be at the end of the actual one .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } does not end with the given one . */
public @ NotNull StringAssert endsWith ( String expected ) { } }

implementation: isNotNull ( ) ; if ( actual . endsWith ( expected ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should end with:<%s>" , actual , expected ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } does not contains the given one .
 * @ param s the given { @ code String } expected not to be contained in the actual one .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } does contain the given one . */
public @ NotNull StringAssert excludes ( String s ) { } }

implementation: isNotNull ( ) ; if ( actual . indexOf ( s ) == - 1 ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should not contain the String:<%s>" , actual , s ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } does not match the given one .
 * @ param regex the given regular expression expected not to be matched by the actual one .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } matches the given regular expression . */
public @ NotNull StringAssert doesNotMatch ( String regex ) { } }

implementation: isNotNull ( ) ; if ( ! actual . matches ( regex ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should not match the regular expression:<%s>" , actual , regex ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } contains the given text regardless of the case .
 * @ param text the given text .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } does not contain the given text .
 * @ throws NullPointerException if the given { @ code String } is { @ code null } .
 * @ since 1.3 */
public @ NotNull StringAssert containsIgnoringCase ( @ NotNull String text ) { } }

implementation: checkNotNull ( text ) ; isNotNull ( ) ; if ( actual . toLowerCase ( ) . contains ( text . toLowerCase ( ) ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> does not contain <%s>" , actual , text ) ) ;


signature:
public class StringAssert { /** * Verifies that the actual { @ code String } does not contain the given text .
 * @ param text the given text .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code String } is { @ code null } .
 * @ throws AssertionError if the actual { @ code String } contains the given text .
 * @ throws NullPointerException if the given { @ code String } is { @ code null } .
 * @ since 1.3 */
public @ NotNull StringAssert doesNotContain ( @ NotNull String text ) { } }

implementation: checkNotNull ( text ) ; isNotNull ( ) ; if ( ! actual . contains ( text ) ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( format ( "<%s> should not contain <%s>" , actual , text ) ) ;


signature:
public class FloatAssert { /** * Verifies that the actual { @ code Float } is equal to the given one , within a positive delta .
 * @ param expected the value to compare the actual one to .
 * @ param delta the given delta .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Float } is not equal to the given one .
 * @ deprecated use method { @ link # isEqualTo ( float , org . fest . assertions . Delta ) } instead . This method will be removed in
 * version 2.0. */
@ Deprecated public @ NotNull FloatAssert isEqualTo ( float expected , @ NotNull Delta delta ) { } }

implementation: return isEqualTo ( expected , delta . value ) ;


signature:
public class FloatAssert { /** * Verifies that the actual { @ code Float } is equal to the given one , within a positive delta .
 * @ param expected the value to compare the actual one to .
 * @ param delta the given delta .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Float } is not equal to the given one .
 * @ since 1.2 */
public @ NotNull FloatAssert isEqualTo ( float expected , @ NotNull org . fest . assertions . Delta delta ) { } }

implementation: return isEqualTo ( expected , delta . floatValue ( ) ) ;


signature:
public class FloatAssert { /** * Verifies that the actual { @ code Float } is not equal to the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Float } is equal to the given one . */
public @ NotNull FloatAssert isNotEqualTo ( float other ) { } }

implementation: if ( compareTo ( other ) != 0 ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedEqual ( actual , other ) ) ;


signature:
public class FloatAssert { /** * Verifies that the actual { @ code Float } is greater than the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Float } is not greater than the given one . */
public @ NotNull FloatAssert isGreaterThan ( float other ) { } }

implementation: if ( compareTo ( other ) > 0 ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedLessThanOrEqualTo ( actual , other ) ) ;


signature:
public class ArrayInspection { /** * Copies the contents of the given array into an array of objects .
 * @ param array the array to copy .
 * @ return an array of objects containing the contents of the array .
 * @ throws NullPointerException if the given object is { @ code null } .
 * @ throws IllegalArgumentException if the given object is not an array . */
public static @ NotNull Object [ ] copy ( @ NotNull Object array ) { } }

implementation: return copyToList ( checkNotNull ( array ) ) . toArray ( ) ;


signature:
public class ArrayInspection { /** * Copies the contents of the given array into a list .
 * @ param array the array to copy .
 * @ return a list containing the contents of the array .
 * @ throws IllegalArgumentException if the given object is not an array .
 * @ since 1.3. */
public static @ NotNull List < Object > copyToList ( @ NotNull Object array ) { } }

implementation: return copy ( checkNotNull ( array ) , newArrayList ( ) ) ;


signature:
public class ArrayInspection { /** * Copies the contents of the given array into a list .
 * @ param array the array to copy .
 * @ return a list containing the contents of the array .
 * @ throws IllegalArgumentException if the given object is not an array .
 * @ since 1.3. */
public static @ NotNull Set < Object > copyToSet ( @ NotNull Object array ) { } }

implementation: return copy ( checkNotNull ( array ) , newLinkedHashSet ( ) ) ;


signature:
public class ArrayInspection { /** * Returns the size of the given array .
 * @ param array the array .
 * @ return the size of the given array .
 * @ throws NullPointerException if the given array is { @ code null } .
 * @ throws IllegalArgumentException if the given object is not an array . */
public static int sizeOf ( @ NotNull Object array ) { } }

implementation: checkNotNull ( array ) ; validateIsArray ( array ) ; return getLength ( array ) ;


signature:
public class IntAssert { /** * Verifies that the actual { @ code Integer } is greater than the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Integer } is not greater than the given one . */
public @ NotNull IntAssert isGreaterThan ( int other ) { } }

implementation: if ( actual > other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedLessThanOrEqualTo ( actual , other ) ) ;


signature:
public class IntAssert { /** * Verifies that the actual { @ code Integer } is less than the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Integer } is not less than the given one . */
public @ NotNull IntAssert isLessThan ( int other ) { } }

implementation: if ( actual < other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedGreaterThanOrEqualTo ( actual , other ) ) ;


signature:
public class IntAssert { /** * Verifies that the actual { @ code Integer } is greater or equal to the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Integer } is not greater than or equal to the given one . */
public @ NotNull IntAssert isGreaterThanOrEqualTo ( int other ) { } }

implementation: if ( actual >= other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedLessThan ( actual , other ) ) ;


signature:
public class IntAssert { /** * Verifies that the actual { @ code Integer } is less or equal to the given one .
 * @ param other the given value .
 * @ return this assertion object .
 * @ throws AssertionError if the actual { @ code Integer } is not less than or equal to the given one . */
public @ NotNull IntAssert isLessThanOrEqualTo ( int other ) { } }

implementation: if ( actual <= other ) { return this ; } failIfCustomMessageIsSet ( ) ; throw failure ( unexpectedGreaterThan ( actual , other ) ) ;


signature:
public class ViewHoldingListAdapter { /** * Declared by SpinnerAdapter , this method allows your spinner to show
 * different views in your drop down vs the ' closed ' spinned box . */
public View getDropDownView ( int index , View convertView , ViewGroup parent ) { } }

implementation: return dropDownViewFactory . getView ( convertView , itemList . get ( index ) ) ;


signature:
public class AbstractImmutableVocabulary { /** * { @ inheritDoc } */
@ Override public final T [ ] terms ( ) { } }

implementation: checkStatus ( Status . INITIALIZED ) ; @ SuppressWarnings ( "unchecked" ) T [ ] array = ( T [ ] ) Array . newInstance ( this . termClass , this . ordinal ) ; return this . terms . values ( ) . toArray ( array ) ;


signature:
public class AbstractImmutableVocabulary { /** * { @ inheritDoc } */
@ Override public final T fromName ( String name ) { } }

implementation: checkStatus ( Status . INITIALIZED ) ; requireNonNull ( name , "Term name cannot be null" ) ; Integer termOrdinal = this . nameOrdinal . get ( name ) ; if ( termOrdinal != null ) { return this . terms . get ( termOrdinal ) ; } return null ;


signature:
public class AbstractImmutableVocabulary { /** * { @ inheritDoc } */
@ Override public T fromOrdinal ( int ordinal ) { } }

implementation: checkStatus ( Status . INITIALIZED ) ; if ( ordinal < 0 || this . ordinal < ordinal ) { throw new IndexOutOfBoundsException ( "No term available with ordinal '" + ordinal + "'" ) ; } return this . terms . get ( ordinal ) ;


signature:
public class AbstractImmutableVocabulary { /** * { @ inheritDoc } */
@ Override public final < V > T fromValue ( V value ) { } }

implementation: checkStatus ( Status . INITIALIZED ) ; try { @ SuppressWarnings ( "unchecked" ) TypeAdapter < T , V > adapter = ( TypeAdapter < T , V > ) TypeAdapter . createAdapter ( this . termClass , value . getClass ( ) ) ; for ( T candidate : this . terms . values ( ) ) { if ( value . equals ( adapter . adapt ( candidate ) ) ) { return candidate ; } } return null ; } catch ( CannotAdaptClassesException e ) { throw new UnsupportedOperationException ( "Class '" + this . termClass . getCanonicalName ( ) + " cannot be transformed to '" + value . getClass ( ) . getCanonicalName ( ) + "'" , e ) ; }


signature:
public class AbstractImmutableVocabulary { /** * { @ inheritDoc } */
@ Override public final Iterator < Term > iterator ( ) { } }

implementation: checkStatus ( Status . INITIALIZED ) ; final Iterator < ? extends Term > iterator = this . terms . values ( ) . iterator ( ) ; return new Iterator < Term > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Term next ( ) { return iterator . next ( ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( "Removal not supported" ) ; } } ;


signature:
public class AbstractImmutableVocabulary { /** * Allow the reservation of term names during the initialization of the
 * vocabulary .
 * @ param name
 * then name of the term
 * @ return a number that represents the position in which the term was
 * reserved
 * @ throws IllegalArgumentException
 * if the specified name is not valid or it has been already
 * reserved .
 * @ throws IllegalStateException
 * if the vocabulary has been already initialized . */
protected final int reserveTermName ( String name ) { } }

implementation: checkStatus ( Status . INITIALIZING ) ; checkInitializationPrecondition ( TermUtils . isValidTermName ( name ) , "Object '%s' is not a valid term name" , name ) ; checkInitializationPrecondition ( ! this . nameOrdinal . containsKey ( name ) , "Term '%s' has been already reserved" , name ) ; this . nameOrdinal . put ( name , ++ this . ordinal ) ; return this . ordinal ;


signature:
public class AbstractImmutableVocabulary { /** * Upon reservation , the method enables registering the properly built
 * immutable term instance .
 * @ param term
 * the term to be registered .
 * @ throws IllegalArgumentException
 * if the specified term instance cannot be registered , either
 * because the ordinal is invalid or because another term
 * with the same name has already been registered .
 * @ throws IllegalStateException
 * if the vocabulary has been already initialized . */
protected final < S extends ImmutableTerm > void registerTerm ( S term ) { } }

implementation: checkStatus ( Status . INITIALIZING ) ; checkInitializationPrecondition ( this . nameOrdinal . containsKey ( term . name ( ) ) , "Term '%s' has not been reserved" , term . name ( ) ) ; checkInitializationPrecondition ( term . ordinal ( ) >= 0 && term . ordinal ( ) <= this . ordinal , "Invalid ordinal '%d' for reserved name '%s'" , term . ordinal ( ) , term . name ( ) ) ; this . terms . put ( term . ordinal ( ) , this . termClass . cast ( term ) ) ;


signature:
public class AbstractImmutableVocabulary { /** * Complete the initialization of the vocabulary . Beyond this point the
 * vocabulary can be put to use .
 * @ throws IllegalStateException
 * if the vocabulary has been already initialized or not all the
 * reserved names have been registered . */
protected final void initialize ( ) { } }

implementation: checkStatus ( Status . INITIALIZING ) ; if ( this . terms . size ( ) != this . nameOrdinal . size ( ) ) { throw new IllegalStateException ( String . format ( "Vocabulary '%s' (%s) initialization failure: not all reserved names have been registered" , this . namespace , getClass ( ) . getName ( ) ) ) ; } this . status = Status . INITIALIZED ;


signature:
public class JPAResource { /** * { @ inheritDoc } */
@ Override public Attachment findAttachment ( ResourceId resourceId ) { } }

implementation: checkNotNull ( resourceId , "Attached resource identifier cannot be null" ) ; return this . attachmentCollection . attachmendByResourceId ( resourceId ) ;


signature:
public class JPAResource { /** * { @ inheritDoc } */
@ Override public Resource attach ( String attachmentId , ResourceId resourceId ) { } }

implementation: return attach ( attachmentId , resourceId , Resource . class ) ;


signature:
public class JPAResource { /** * { @ inheritDoc } */
@ Override public < T extends Resource > T attach ( String attachmentId , ResourceId resourceId , Class < ? extends T > clazz ) { } }

implementation: checkNotNull ( attachmentId , "Attachment identifier cannot be null" ) ; checkNotNull ( resourceId , "Attached resource identifier cannot be null" ) ; checkNotNull ( clazz , "Attached resource class cannot be null" ) ; this . attachmentCollection . checkNotAttached ( attachmentId , resourceId ) ; ResourceTemplate attachmentTemplate = super . getTemplate ( resourceId ) ; checkState ( Resources . areCompatible ( clazz , attachmentTemplate ) , "Attachment '%s' is not of type '%s' (%s)" , attachmentId , clazz . getCanonicalName ( ) , attachmentTemplate . getClass ( ) . getCanonicalName ( ) ) ; JPAResource newResource = createChild ( resourceId , attachmentTemplate ) ; JPAAttachment newAttachment = this . attachmentCollection . attachmentById ( attachmentId ) ; newAttachment . bind ( resourceId ) ; return clazz . cast ( newResource ) ;


signature:
public class JPAResource { /** * { @ inheritDoc } */
@ Override public ConstraintReport addConstraintReport ( Constraints constraints , Date date , HttpRequest request ) { } }

implementation: ConstraintReportId reportId = nextConstraintReportId ( ) ; return new JPAConstraintReport ( reportId , date , request , constraints ) ;


signature:
public class JPAResource { /** * { @ inheritDoc } */
@ Override public Set < ConstraintReportId > constraintReports ( ) { } }

implementation: Set < String > currentFailures = null ; synchronized ( this ) { currentFailures = ImmutableSet . copyOf ( this . failures ) ; } Builder < ConstraintReportId > builder = ImmutableSet . builder ( ) ; for ( String failure : currentFailures ) { builder . add ( ConstraintReportId . create ( this . id , failure ) ) ; } return builder . build ( ) ;


signature:
public class JPAEndpoint { /** * { @ inheritDoc } */
@ Override public void modify ( EntityTag newEntityTag , Date newLastModified ) { } }

implementation: checkState ( this . deleted == null , "Endpoint is already deleted" ) ; this . entityTag = newEntityTag ; this . lastModified = new Date ( newLastModified . getTime ( ) ) ;


signature:
public class JPAEndpoint { /** * { @ inheritDoc } */
@ Override public void delete ( Date deleted ) { } }

implementation: checkState ( this . deleted == null , "Endpoint is already deleted" ) ; this . deleted = deleted ; this . resourceId = null ;


signature:
public class DefaultApplicationContext { /** * TODO : How do we do this transactionally */
private void registerConstraintReport ( Resource resource , InvalidContentException error ) { } }

implementation: ConstraintReport report = resource . addConstraintReport ( error . getConstraints ( ) , new Date ( ) , currentRequest ( ) ) ; this . constraintReportRepository . add ( report ) ; LOGGER . debug ( "Constraint validation failed. Registered constraint report {}" , report . id ( ) ) ; error . setConstraintsId ( report . id ( ) . failureId ( ) ) ;


signature:
public class DefaultApplicationContext { /** * Enforce http : / / tools . ietf . org / html / rfc7232 # section - 2.2:
 * if the clock in the request is ahead of the clock of the origin
 * server ( e . g . , I request from Spain the update of a resource held in USA )
 * the last - modified data should be changed to that of the request and not
 * a generated date from the origin server */
private Date lastModified ( ) { } }

implementation: Date clientDate = currentRequest ( ) . clientDate ( ) ; Date lastModified = new Date ( ) ; if ( clientDate != null && clientDate . after ( lastModified ) ) { lastModified = clientDate ; } return lastModified ;


signature:
public class DefaultApplicationContext { /** * { @ inheritDoc } */
@ Override public ApplicationContextOperation createOperation ( HttpRequest request ) { } }

implementation: checkNotNull ( request , "Http request cannot be null" ) ; DefaultApplicationOperation operation = this . currentOperation . get ( ) ; checkState ( operation == null , "An operation is ongoing on the current thread" ) ; operation = new DefaultApplicationOperation ( request ) ; this . currentOperation . set ( operation ) ; return operation ;


signature:
public class DefaultApplicationContext { /** * { @ inheritDoc } */
@ Override public void registerApplicationLifecycleListener ( ApplicationLifecycleListener listener ) { } }

implementation: checkNotNull ( listener , APPLICATION_LIFECYCLE_LISTENER_CANNOT_BE_NULL ) ; this . engine ( ) . applicationLifecycleService ( ) . registerApplicationLifecycleListener ( listener ) ;


signature:
public class DefaultApplicationContext { /** * { @ inheritDoc } */
@ Override public void deregisterApplicationLifecycleListener ( ApplicationLifecycleListener listener ) { } }

implementation: checkNotNull ( listener , APPLICATION_LIFECYCLE_LISTENER_CANNOT_BE_NULL ) ; this . engine ( ) . applicationLifecycleService ( ) . deregisterApplicationLifecycleListener ( listener ) ;


signature:
public class EnumObjectFactory { /** * { @ inheritDoc } */
@ Override public E fromString ( final String rawValue ) { } }

implementation: try { return Enum . valueOf ( this . targetClass , rawValue ) ; } catch ( Exception e ) { throw new ObjectParseException ( e , targetClass ( ) , rawValue ) ; }


signature:
public class PersonHandler { /** * { @ inheritDoc } < br >
 * Delete a person resource . */
@ Override public void delete ( ResourceSnapshot resource , WriteSession session ) throws UnknownResourceException { } }

implementation:
DataSet dataSet = get ( resource ) ; try { logDebug ( resource , "Deleting state:%n%s" , dataSet ) ; remove ( resource . name ( ) ) ; session . delete ( resource ) ; session . saveChanges ( ) ; } catch ( WriteSessionException e ) { // Recover if failed
add ( resource . name ( ) , dataSet ) ; throw new ApplicationRuntimeException ( "Deletion failed" , e ) ; }


signature:
public class PersonHandler { /** * { @ inheritDoc } < br >
 * Update a person resource . */
@ Override public void update ( ResourceSnapshot resource , DataSet content , WriteSession session ) throws InconsistentContentException , UnknownResourceException { } }

implementation:
DataSet dataSet = get ( resource ) ; logDebug ( resource , "Enforcing consistency..." ) ; enforceConsistency ( resource , content , dataSet ) ; try { logDebug ( resource , "Persisting new state:%n%s" , content ) ; add ( resource . name ( ) , content ) ; session . modify ( resource ) ; session . saveChanges ( ) ; } catch ( Exception e ) { // Recover if failed
add ( resource . name ( ) , dataSet ) ; logError ( resource , e , "Something went wrong" , e ) ; throw new ApplicationRuntimeException ( "Update failed" , e ) ; }


signature:
public class BadDataResourceHandler { /** * Get custom representation with bad data
 * @ return the representation */
public DataSet getRepresentation ( ) { } }

implementation: return DataDSL . dataSet ( ) . individual ( newReference ( ) . toLocalIndividual ( ) . named ( "anonymous" ) ) . hasLink ( KNOWS ) . referringTo ( newReference ( ) . toManagedIndividual ( "unknownTemplate1" ) . named ( "r1" ) ) . individual ( newReference ( ) . toLocalIndividual ( ) . named ( "anonymous" ) ) . hasProperty ( CREATED_ON ) . withValue ( new Date ( ) ) . hasLink ( KNOWS ) . referringTo ( newReference ( ) . toManagedIndividual ( "unknownTemplate2" ) . named ( "r1" ) ) . individual ( newReference ( ) . toManagedIndividual ( "unknownTemplate2" ) . named ( "r1" ) ) . hasProperty ( CREATION_DATE ) . withValue ( new Date ( ) ) . hasProperty ( AGE ) . withValue ( 34 ) . hasLink ( HAS_FATHER ) . toIndividual ( newReference ( ) . toLocalIndividual ( ) . named ( "Michel" ) ) . hasLink ( HAS_WIFE ) . referringTo ( newReference ( ) . toLocalIndividual ( ) . named ( "Consuelo" ) ) . build ( ) ;


signature:
public class RuntimeDelegate { /** * Obtain a { @ code RuntimeInstance } instance using the method described in
 * { @ link # getInstance } .
 * @ return an instance of { @ code RuntimeInstance } . */
private static RuntimeDelegate findDelegate ( ) { } }

implementation: try { RuntimeDelegate result = createRuntimeDelegateFromSPI ( ) ; if ( result == null ) { result = createRuntimeDelegateFromConfigurationFile ( ) ; } if ( result == null ) { String delegateClassName = System . getProperty ( LDP4J_SERVER_DATA_SPI_PROPERTY ) ; if ( delegateClassName != null ) { result = createRuntimeDelegateForClassName ( delegateClassName ) ; } } if ( result == null ) { result = new DefaultRuntimeInstance ( ) ; } return result ; } catch ( Exception ex ) { throw new IllegalStateException ( "Could not find runtime delegate" , ex ) ; }


signature:
public class RuntimeDelegate { /** * Obtain a { @ code RuntimeDelegate } instance . If an instance had not already
 * been created and set via { @ link # setInstance ( RuntimeDelegate ) } , the first
 * invocation will create an instance which will then be cached for future
 * use .
 * The algorithm used to locate the RuntimeDelegate subclass to use consists
 * of the following steps :
 * < ul >
 * < li >
 * If a resource with the name of
 * { @ code META - INF / services / org . ldp4j . server . data . spi . RuntimeDelegate } exists , then
 * its first line , if present , is used as the UTF - 8 encoded name of the
 * implementation class . < / li >
 * < li >
 * If the $ java . home / lib / ldp4j - server - data . properties file exists and it is readable by
 * the { @ code java . util . Properties . load ( InputStream ) } method and it contains
 * an entry whose key is { @ code org . ldp4j . server . data . spi . RuntimeDelegate } , then the
 * value of that entry is used as the name of the implementation class . < / li >
 * < li >
 * If a system property with the name
 * { @ code org . ldp4j . server . data . spi . RuntimeDelegate } is defined , then its value is
 * used as the name of the implementation class . < / li >
 * < li >
 * Finally , a default implementation class name is used . < / li >
 * < / ul >
 * @ return an instance of { @ code RuntimeDelegate } . */
public static RuntimeDelegate getInstance ( ) { } }

implementation: RuntimeDelegate result = RuntimeDelegate . CACHED_DELEGATE . get ( ) ; if ( result != null ) { return result ; } synchronized ( RuntimeDelegate . CACHED_DELEGATE ) { result = RuntimeDelegate . CACHED_DELEGATE . get ( ) ; if ( result == null ) { RuntimeDelegate . CACHED_DELEGATE . set ( findDelegate ( ) ) ; result = RuntimeDelegate . CACHED_DELEGATE . get ( ) ; } return result ; }


signature:
public class RuntimeDelegate { /** * Set the runtime delegate that will be used by Data API classe .
 * If this method is not called prior to { @ link # getInstance } then
 * an implementation will be sought as described in { @ link # getInstance } .
 * @ param delegate
 * the { @ code RuntimeInstance } runtime delegate instance .
 * @ throws SecurityException
 * if there is a security manager and the permission
 * ReflectPermission ( " suppressAccessChecks " ) has not been
 * granted . */
public static void setInstance ( final RuntimeDelegate delegate ) { } }

implementation: SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( suppressAccessChecksPermission ) ; } RuntimeDelegate . CACHED_DELEGATE . set ( delegate ) ;


signature:
public class URIUtils { /** * 5.2 . Relative Resolution
 * This section describes an algorithm for converting a URI reference
 * that might be relative to a given base URI into the parsed components
 * of the reference ' s target . The components can then be recomposed , as
 * described in Section 5.3 , to form the target URI . This algorithm
 * provides definitive results that can be used to test the output of
 * other implementations . Applications may implement relative reference
 * resolution by using some other algorithm , provided that the results
 * match what would be given by this one .
 * 5.2.1 . Pre - parse the Base URI
 * The base URI ( Base ) is established according to the procedure of
 * Section 5.1 and parsed into the five main components described in
 * Section 3 . Note that only the scheme component is required to be
 * present in a base URI ; the other components may be empty or
 * undefined . A component is undefined if its associated delimiter does
 * not appear in the URI reference ; the path component is never
 * undefined , though it may be empty .
 * Normalization of the base URI , as described in Sections 6.2.2 and
 * 6.2.3 , is optional . A URI reference must be transformed to its
 * target URI before it can be normalized .
 * 5.2.2 . Transform References
 * For each URI reference ( R ) , the following pseudocode describes an
 * algorithm for transforming R into its target URI ( T ) :
 * - - The URI reference is parsed into the five URI components
 * ( R . scheme , R . authority , R . path , R . query , R . fragment ) = parse ( R ) ;
 * - - A non - strict parser may ignore a scheme in the reference
 * - - if it is identical to the base URI ' s scheme .
 * if ( ( not strict ) and ( R . scheme = = Base . scheme ) ) then
 * undefine ( R . scheme ) ;
 * endif ;
 * if defined ( R . scheme ) then
 * T . scheme = R . scheme ;
 * T . authority = R . authority ;
 * T . path = remove _ dot _ segments ( R . path ) ;
 * T . query = R . query ;
 * else
 * if defined ( R . authority ) then
 * T . authority = R . authority ;
 * T . path = remove _ dot _ segments ( R . path ) ;
 * T . query = R . query ;
 * else
 * if ( R . path = = " " ) then
 * T . path = Base . path ;
 * if defined ( R . query ) then
 * T . query = R . query ;
 * else
 * T . query = Base . query ;
 * endif ;
 * else
 * if ( R . path starts - with " / " ) then
 * T . path = remove _ dot _ segments ( R . path ) ;
 * else
 * T . path = merge ( Base . path , R . path ) ;
 * T . path = remove _ dot _ segments ( T . path ) ;
 * endif ;
 * T . query = R . query ;
 * endif ;
 * T . authority = Base . authority ;
 * endif ;
 * T . scheme = Base . scheme ;
 * endif ;
 * T . fragment = R . fragment ; */
private static URIRef relativeResolution ( URI target , URI base ) { } }

implementation:
URIRef Base = URIRef . create ( base ) ; // NOSONAR
URIRef R = URIRef . create ( target ) ; // NOSONAR
URIRef T = URIRef . create ( ) ; // NOSONAR
if ( defined ( R . scheme ) ) { T . scheme = R . scheme ; T . authority = R . authority ; T . path = removeDotSegments ( R . path ) ; T . query = R . query ; } else { if ( defined ( R . authority ) ) { T . authority = R . authority ; T . path = removeDotSegments ( R . path ) ; T . query = R . query ; } else { resolvePathOnlyTarget ( Base , R , T ) ; } T . scheme = Base . scheme ; } T . fragment = R . fragment ; return T ;


signature:
public class URIUtils { /** * 5.2.3 . Merge Paths
 * The pseudocode above refers to a " merge " routine for merging a
 * relative - path reference with the path of the base URI . This is
 * accomplished as follows :
 * o If the base URI has a defined authority component and an empty
 * path , then return a string consisting of " / " concatenated with the
 * reference ' s path ; otherwise ,
 * o return a string consisting of the reference ' s path component
 * appended to all but the last segment of the base URI ' s path ( i . e . ,
 * excluding any characters after the right - most " / " in the base URI
 * path , or excluding the entire base URI path if it does not contain
 * any " / " characters ) .
 * @ param hasAuthority */
private static String merge ( String path , String relativePath , boolean hasAuthority ) { } }

implementation: String parent = path ; if ( hasAuthority && parent . isEmpty ( ) ) { parent = SLASH ; } return parent . substring ( 0 , parent . lastIndexOf ( '/' ) + 1 ) . concat ( relativePath ) ;


signature:
public class URIUtils { /** * 5.2.4 . Remove Dot Segments
 * The pseudocode also refers to a " remove _ dot _ segments " routine for
 * interpreting and removing the special " . " and " . . " complete path
 * segments from a referenced path . This is done after the path is
 * extracted from a reference , whether or not the path was relative , in
 * order to remove any invalid or extraneous dot - segments prior to
 * forming the target URI . Although there are many ways to accomplish
 * this removal process , we describe a simple method using two string
 * buffers .
 * 1 . The input buffer is initialized with the now - appended path
 * components and the output buffer is initialized to the empty
 * string .
 * 2 . While the input buffer is not empty , loop as follows :
 * A . If the input buffer begins with a prefix of " . . / " or " . / " ,
 * then remove that prefix from the input buffer ; otherwise ,
 * B . if the input buffer begins with a prefix of " / . / " or " / . " ,
 * where " . " is a complete path segment , then replace that
 * prefix with " / " in the input buffer ; otherwise ,
 * C . if the input buffer begins with a prefix of " / . . / " or " / . . " ,
 * where " . . " is a complete path segment , then replace that
 * prefix with " / " in the input buffer and remove the last
 * segment and its preceding " / " ( if any ) from the output
 * buffer ; otherwise ,
 * D . if the input buffer consists only of " . " or " . . " , then remove
 * that from the input buffer ; otherwise ,
 * E . move the first path segment in the input buffer to the end of
 * the output buffer , including the initial " / " character ( if
 * any ) and any subsequent characters up to , but not including ,
 * the next " / " character or the end of the input buffer .
 * 3 . Finally , the output buffer is returned as the result of
 * remove _ dot _ segments . */
private static String removeDotSegments ( String path ) { } }

implementation: Deque < String > outputBuffer = new LinkedList < String > ( ) ; String input = path == null ? EMPTY : path ; while ( ! input . isEmpty ( ) ) { input = processInput ( outputBuffer , input ) ; } return assembleInOrder ( outputBuffer ) ;


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public < T extends Resource > T resourceById ( ResourceId id , Class < ? extends T > expectedResourceClass ) { } }

implementation: checkNotNull ( expectedResourceClass , "Expected resource class cannot be null" ) ; Resource found = find ( id ) ; if ( expectedResourceClass . isInstance ( found ) ) { return expectedResourceClass . cast ( found ) ; } return null ;


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public Resource resourceOfId ( ResourceId id ) { } }

implementation: lock . readLock ( ) . lock ( ) ; try { return resources . get ( id ) ; } finally { lock . readLock ( ) . unlock ( ) ; }


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public Container containerOfId ( ResourceId id ) { } }

implementation: lock . readLock ( ) . lock ( ) ; try { return containers . get ( id ) ; } finally { lock . readLock ( ) . unlock ( ) ; }


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public void add ( Resource resource ) { } }

implementation: checkNotNull ( resource , "Resource cannot be null" ) ; lock . writeLock ( ) . lock ( ) ; try { checkState ( find ( resource . id ( ) ) == null , "A resource with identifier '%s' already exists" , resource . id ( ) ) ; resource . accept ( new ResourceVisitor ( ) { @ Override public void visitResource ( Resource resource ) { InMemoryResourceRepository . this . resources . put ( resource . id ( ) , resource ) ; } @ Override public void visitContainer ( Container resource ) { InMemoryResourceRepository . this . containers . put ( resource . id ( ) , resource ) ; } } ) ; } finally { lock . writeLock ( ) . unlock ( ) ; }


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public void remove ( Resource resource ) { } }

implementation: checkNotNull ( resource , "Resource cannot be null" ) ; lock . writeLock ( ) . lock ( ) ; try { resources . remove ( resource . id ( ) ) ; containers . remove ( resource . id ( ) ) ; } finally { lock . writeLock ( ) . unlock ( ) ; }


signature:
public class InMemoryResourceRepository { /** * { @ inheritDoc } */
@ Override public void shutdown ( ) throws LifecycleException { } }

implementation: lock . writeLock ( ) . lock ( ) ; try { resources . clear ( ) ; containers . clear ( ) ; } finally { lock . writeLock ( ) . unlock ( ) ; }


signature:
public class OperationContextImpl { /** * TODO : Add extension point to enable configuring the list of supported
 * charsets */
@ Override public List < Charset > supportedCharsets ( ) { } }

implementation: return ImmutableList . < Charset > builder ( ) . add ( StandardCharsets . UTF_8 ) . add ( StandardCharsets . ISO_8859_1 ) . add ( StandardCharsets . US_ASCII ) . add ( StandardCharsets . UTF_16 ) . add ( StandardCharsets . UTF_16LE ) . add ( StandardCharsets . UTF_16BE ) . build ( ) ;


signature:
public class AttachmentSnapshotCollection { /** * TODO : For the time being the name is not used in here , because the
 * checking should not just be local : we should check that that name has not
 * been used for any other resource of the same template , and that requires
 * a global checking . Whenever the check is done somewhere else , get rid of
 * this parameter */
Attachability attachability ( String attachmentId , Name < ? > name ) { } }

implementation:
// NOSONAR
Attachability result = null ; if ( this . attachmentsById . containsKey ( attachmentId ) ) { result = Attachability . ID_ALREADY_USED ; } else { result = Attachability . ATTACHABLE ; } return result ;


signature:
public class ImmutableTemplateLibrary { /** * { @ inheritDoc } */
@ Override public ResourceTemplate findByHandler ( Class < ? extends ResourceHandler > handlerClass ) { } }

implementation: return ImmutableTemplateFactory . newImmutable ( delegate ( ) . findByHandler ( handlerClass ) ) ;


signature:
public class ImmutableTemplateLibrary { /** * { @ inheritDoc } */
@ Override public ResourceTemplate findById ( String templateId ) { } }

implementation: return ImmutableTemplateFactory . newImmutable ( delegate ( ) . findById ( templateId ) ) ;


signature:
public class ImmutableQuery { /** * { @ inheritDoc } */
@ Override public Parameter getParameter ( String paramName ) { } }

implementation: checkNotNull ( paramName , "Parameter name cannot be null" ) ; return this . parameters . get ( paramName ) ;


signature:
public class JPASlug { /** * { @ inheritDoc } */
@ Override public synchronized String nextPath ( ) { } }

implementation: long id = this . version ++ ; String result = this . preferredPath ; if ( id > 0 ) { result += "_" + id ; } return result ;


signature:
public class EnvironmentImpl { /** * TODO : Check that root resources are published in different " branches " */
void configureRootResources ( ) throws ApplicationConfigurationException { } }

implementation: validateRootResources ( ) ; final Date creationDate = new Date ( ) ; for ( RootResource entry : this . candidates ) { publish ( entry , creationDate ) ; LOGGER . debug ( "Published resource '{}' at '{}'" , entry . resourceId ( ) , entry . path ( ) ) ; }


signature:
public class NamingScheme { /** * Concatenates elements to form a dotted name , discarding null values
 * and empty strings .
 * @ param name
 * the first element of the name
 * @ param names
 * the remaining elements of the name
 * @ return { @ code name } and { @ code names } concatenated by periods */
public Name < String > name ( String name , String ... names ) { } }

implementation: return createName ( assemble ( name , names ) ) ;


signature:
public class NamingScheme { /** * Concatenates a canonical class name and elements to form a dotted name , discarding any null values or empty strings
 * any null values or empty strings .
 * @ param clazz
 * the first element of the name
 * @ param names
 * the remaining elements of the name
 * @ return { @ code clazz } and { @ code names } concatenated by periods */
public Name < String > name ( Class < ? > clazz , String ... names ) { } }

implementation: return name ( clazz . getCanonicalName ( ) , names ) ;


signature:
public class DelegatedWriteSession { /** * { @ inheritDoc } */
@ Override public < S extends ResourceSnapshot > S find ( Class < ? extends S > snapshotClass , Name < ? > name , Class < ? extends ResourceHandler > handlerClass ) { } }

implementation: checkNotNull ( snapshotClass , "Resource snapshot class cannot be null" ) ; checkNotNull ( name , RESOURCE_NAME_CANNOT_BE_NULL ) ; checkNotNull ( handlerClass , "Resource handler class cannot be null" ) ; checkArgument ( ! ContainerSnapshot . class . isAssignableFrom ( snapshotClass ) || ContainerHandler . class . isAssignableFrom ( handlerClass ) , "Incompatible snapshot and handler classes ('%s' instances are not handled by '%s')" , snapshotClass . getCanonicalName ( ) , handlerClass . getCanonicalName ( ) ) ; ResourceTemplate template = this . writeSessionService . templateManagementService ( ) . templateOfHandler ( handlerClass ) ; checkArgument ( template != null , "Handler class '%s' is not associated to any existing template" , handlerClass . getCanonicalName ( ) ) ; checkArgument ( Snapshots . areCompatible ( snapshotClass , template ) , "Cannot wrap an object managed by '%s' with an snapshot of type '%s'" , handlerClass . getCanonicalName ( ) , snapshotClass . getCanonicalName ( ) ) ; checkState ( this . status . equals ( Status . ACTIVE ) , WRITE_SESSION_NOT_ACTIVE , this . status ) ; ResourceId id = ResourceId . createId ( name , template ) ; DelegatedResourceSnapshot resource = resolveResource ( id , template ) ; return snapshotClass . cast ( resource ) ;


signature:
public class DelegatedWriteSession { /** * { @ inheritDoc } */
@ Override public < S extends ResourceSnapshot > S resolve ( final Class < ? extends S > snapshotClass , final Individual < ? , ? > individual ) { } }

implementation: checkNotNull ( snapshotClass , "Resource snapshot class cannot be null" ) ; checkNotNull ( individual , "Individual cannot be null" ) ; checkState ( this . status . equals ( Status . ACTIVE ) , WRITE_SESSION_NOT_ACTIVE , this . status ) ; S result = null ; ResourceId id = getIdentifier ( individual ) ; if ( id != null ) { result = find ( snapshotClass , id ) ; } return result ;


signature:
public class DelegatedWriteSession { /** * { @ inheritDoc } */
@ Override public void modify ( ResourceSnapshot resource ) { } }

implementation: checkNotNull ( resource , RESOURCE_CANNOT_BE_NULL ) ; checkArgument ( resource instanceof DelegatedResourceSnapshot , "Unknown resource '%s'" , resource . name ( ) ) ; checkState ( this . status . equals ( Status . ACTIVE ) , WRITE_SESSION_NOT_ACTIVE , status ) ; DelegatedResourceSnapshot delegatedResource = ( DelegatedResourceSnapshot ) resource ; delegatedResource . modify ( ) ;


signature:
public class DelegatedWriteSession { /** * { @ inheritDoc } */
@ Override public void saveChanges ( ) throws WriteSessionException { } }

implementation: checkState ( this . status . equals ( Status . ACTIVE ) , WRITE_SESSION_NOT_ACTIVE , this . status ) ; this . status = Status . COMPLETED ; for ( Entry < ResourceId , DelegatedResourceSnapshot > entry : this . resourceCache . entrySet ( ) ) { DelegatedResourceSnapshot resource = entry . getValue ( ) ; resource . saveChanges ( ) ; } this . writeSessionService . commitSession ( this ) ;


signature:
public class DelegatedWriteSession { /** * { @ inheritDoc } */
@ Override public void discardChanges ( ) throws WriteSessionException { } }

implementation: checkState ( this . status . equals ( Status . ACTIVE ) , WRITE_SESSION_NOT_ACTIVE , this . status ) ; this . status = Status . ABORTED ; this . writeSessionService . rollbackSession ( this ) ;


signature:
public class NameEncoder { /** * { @ inheritDoc } */
@ SuppressWarnings ( "unchecked" ) @ Override protected < T extends Serializable > Name < T > assemble ( Serializable subject ) throws IOException { } }

implementation: return ( Name < T > ) subject ;


signature:
public class CharsetPreference { /** * Create a charset preference that matches the following grammar :
 * < pre >
 * { @ code
 * CHAR = < any US - ASCII character ( octets 0 - 127 ) >
 * DIGIT = < any US - ASCII digit " 0 " . . " 9 " >
 * CTL = < any US - ASCII control character
 * ( octets 0 - 31 ) and DEL ( 127 ) >
 * SP = < US - ASCII SP , space ( 32 ) >
 * HT = < US - ASCII HT , horizontal - tab ( 9 ) >
 * < " > = < US - ASCII double - quote mark ( 34 ) >
 * token = 1 * < any CHAR except CTLs or separators >
 * separators = " ( " | " ) " | " < " | " > " | " @ "
 * | " { " | " } " | SP | HT
 * charset = token
 * qvalue = ( " 0 " [ " . " 0*3DIGIT ] )
 * | ( " 1 " [ " . " 0*3 ( " 0 " ) ] )
 * preference = ( charset | " * " ) [ " ; " " q " " = " qvalue ] }
 * < / pre >
 * @ param str
 * a charset specifier
 * @ return the matching chartset preference , or { @ code null } if no one could
 * be found */
public static CharsetPreference valueOf ( final String str ) { } }

implementation: final String [ ] parts = str . split ( ";" ) ; if ( parts . length <= 2 ) { final String charsetName = parts [ 0 ] . trim ( ) ; if ( "*" . equals ( charsetName ) || TOKEN_MATCHER . matchesAllOf ( charsetName ) ) { int weight = MAX_WEIGHT ; if ( parts . length == 2 ) { final String weightValue = parts [ 1 ] . trim ( ) ; final Matcher matcher = QUALITY_PATTERN . matcher ( weightValue ) ; if ( ! matcher . matches ( ) ) { return null ; } if ( weightValue . charAt ( 2 ) == '0' ) { weight = Integer . parseInt ( Strings . padEnd ( weightValue . substring ( 4 ) , 3 , '0' ) ) ; } } return new CharsetPreference ( charsetName , weight ) ; } } return null ;


signature:
public class IndividualHelperImpl { /** * { @ inheritDoc } */
@ Override public Set < URI > types ( ) { } }

implementation: Property property = this . individual . property ( RDF . TYPE . as ( URI . class ) ) ; if ( property == null ) { return Collections . emptySet ( ) ; } TypeCollector collector = new TypeCollector ( ) ; for ( Value value : property ) { value . accept ( collector ) ; } return collector . collectedTypes ( ) ;


signature:
public class AbstractPersonContainerHandler { /** * { @ inheritDoc } < br >
 * Create a new person resource . */
@ Override public final ResourceSnapshot create ( ContainerSnapshot container , DataSet representation , WriteSession session ) { } }

implementation: Name < ? > name = NamingScheme . getDefault ( ) . name ( id . incrementAndGet ( ) ) ; DataSetHelper helper = DataSetUtils . newHelper ( representation ) ; ManagedIndividual individual = helper . replace ( DataSetHelper . SELF , ManagedIndividualId . createId ( name , PersonHandler . ID ) , ManagedIndividual . class ) ; individual . addValue ( URI . create ( "http://www.example.org/vocab#creationDate" ) , Literals . of ( new Date ( ) ) . dateTime ( ) ) ; try { this . handler . add ( name , representation ) ; ResourceSnapshot member = container . addMember ( name ) ; session . saveChanges ( ) ; return member ; } catch ( Exception e ) { this . handler . remove ( name ) ; throw new ApplicationRuntimeException ( "Could not create member" , e ) ; }


signature:
public class MediaTypes { /** * Set the preferred syntax to use for parsing media types . If the specified
 * syntax is { @ code null } , RFC7230 syntax will be used as default .
 * @ param syntax
 * the syntax */
public static void preferredSyntax ( MediaRangeSyntax syntax ) { } }

implementation: if ( syntax == null ) { SYNTAX . set ( MediaRangeSyntax . RFC7230 ) ; } else { SYNTAX . set ( syntax ) ; }


signature:
public class MediaTypes { /** * Create a wildcard media type for a given primary type
 * @ param type
 * The media type primary type
 * @ return a wildcard media type for the given primary type
 * @ throws NullPointerException
 * if the type is null
 * @ throws IllegalArgumentException
 * if the specified type is not valid */
public static MediaType wildcard ( String type ) { } }

implementation: requireNonNull ( type , TYPE_CANNOT_BE_NULL ) ; return new ImmutableMediaType ( MediaTypes . preferredSyntax ( ) , type , WILDCARD_TYPE , null , null ) ;


signature:
public class MediaTypes { /** * Create a wildcard structured - syntax media type for a given primary type
 * @ param type
 * The media type primary type
 * @ param suffix
 * The suffix associated to the structured - syntax
 * @ return a wildcard media type for the given primary type and suffix
 * @ throws NullPointerException
 * if the type or suffix is null
 * @ throws IllegalArgumentException
 * if the specified type or suffix is not valid */
public static MediaType wildcard ( String type , String suffix ) { } }

implementation: requireNonNull ( type , TYPE_CANNOT_BE_NULL ) ; requireNonNull ( suffix , "Suffix cannot be null" ) ; return new ImmutableMediaType ( MediaTypes . preferredSyntax ( ) , type , WILDCARD_TYPE , suffix , null ) ;


signature:
public class MediaTypes { /** * Create a media type
 * @ param type
 * The media type primary type
 * @ param subtype
 * The media type subtype
 * @ return A media type for the specified media range
 * @ throws NullPointerException
 * if any of the specified media range elements is null
 * @ throws InvalidMediaTypeException
 * if any of the specified media range elements is not valid */
public static MediaType of ( String type , String subtype ) { } }

implementation: requireNonNull ( type , TYPE_CANNOT_BE_NULL ) ; requireNonNull ( subtype , "Subtype cannot be null" ) ; return fromString ( type + "/" + subtype ) ;


signature:
public class MediaTypes { /** * Indicates whether the { @ linkplain MediaType # type ( ) type } is the
 * wildcard character < code > & # 42 ; < / code > .
 * @ param mediaType
 * the instance to verify
 * @ return whether the type of the specified instance is a wildcard
 * @ throws NullPointerException
 * if the specified instance is null */
public static boolean isWildcardType ( final MediaType mediaType ) { } }

implementation: requireNonNull ( mediaType , MEDIA_TYPE_CANNOT_BE_NULL ) ; return WILDCARD_TYPE . equals ( mediaType . type ( ) ) ;


signature:
public class MediaTypes { /** * Indicates whether the { @ linkplain MediaType # subType ( ) subtype } is the
 * wildcard character < code > & # 42 ; < / code > .
 * @ param mediaType
 * the instance to verify
 * @ return whether the subtype of the specified instance is a wildcard
 * @ throws NullPointerException
 * if the specified instance is null */
public static boolean isWildcardSubType ( final MediaType mediaType ) { } }

implementation: requireNonNull ( mediaType , MEDIA_TYPE_CANNOT_BE_NULL ) ; return WILDCARD_TYPE . equals ( mediaType . subType ( ) ) ;


signature:
public class MediaTypes { /** * Format the media type in a HTTP - header compliant manner using preferred
 * format .
 * @ param mediaType
 * the media type to format
 * @ return the compliant representation of the media type
 * @ see < a href = " https : / / tools . ietf . org / html / rfc7231 # section - 3.1.1.1 " > [ RFC
 * 7231 ] Hypertext Transfer Protocol ( HTTP / 1.1 ) : Semantics and Content ,
 * section 3.1.1.1 < / a > */
public static String toHeader ( final MediaType mediaType ) { } }

implementation: requireNonNull ( mediaType , REFERENCE_MEDIA_TYPE_CANNOT_BE_NULL ) ; final StringBuilder builder = new StringBuilder ( ) . append ( mediaType . type ( ) . toLowerCase ( Locale . ENGLISH ) ) . append ( '/' ) . append ( mediaType . subType ( ) . toLowerCase ( Locale . ENGLISH ) ) ; final String suffix = mediaType . suffix ( ) ; if ( suffix != null ) { builder . append ( '+' ) . append ( suffix . toLowerCase ( Locale . ENGLISH ) ) ; } final Charset charset = mediaType . charset ( ) ; if ( charset != null ) { builder . append ( ";charset=" ) . append ( charset . name ( ) . toLowerCase ( Locale . ENGLISH ) ) ; } for ( Entry < String , String > entry : mediaType . parameters ( ) . entrySet ( ) ) { final String key = entry . getKey ( ) ; if ( isStandardParameter ( key ) ) { continue ; } builder . append ( ';' ) . append ( key . toLowerCase ( Locale . ENGLISH ) ) . append ( '=' ) . append ( entry . getValue ( ) ) ; } return builder . toString ( ) ;


signature:
public class InMemoryModelFactory { /** * { @ inheritDoc } */
@ Override public Resource createResource ( ResourceTemplate template , Name < ? > name ) { } }

implementation: checkNotNull ( name , "Resource name cannot be null" ) ; checkArgument ( this . templateLibrary . contains ( template ) , "Unknown template " + template ) ; RootResourceCreator creator = new RootResourceCreator ( ResourceId . createId ( name , template ) ) ; template . accept ( creator ) ; return creator . createdResource ( ) ;


signature:
public class DynamicResourceResolver { /** * Update the resource representation adding the path where the resource is
 * published and whether or not if given that URI it can be resolved to the
 * same resource . */
@ Override public void run ( ) { } }

implementation: ApplicationContext ctx = ApplicationContext . getInstance ( ) ; LOGGER . debug ( "Starting resolution process on {}..." , new Date ( ) ) ; try ( WriteSession session = ctx . createSession ( ) ) { ResourceSnapshot snapshot = session . find ( ResourceSnapshot . class , this . name , DynamicResourceHandler . class ) ; DataSet dataSet = this . handler . get ( snapshot ) ; Individual < ? , ? > individual = dataSet . individualOfId ( ManagedIndividualId . createId ( snapshot . name ( ) , snapshot . templateId ( ) ) ) ; SnapshotResolver snapshotResolver = SnapshotResolver . builder ( ) . withReadSession ( session ) . withCanonicalBase ( CANONICAL_BASE ) . build ( ) ; URI snapshotEndpoint = snapshotResolver . toURI ( snapshot ) ; individual . addValue ( SNAPSHOT_ENDPOINT , Literals . newLiteral ( snapshotEndpoint ) ) ; individual . addValue ( SNAPSHOT_RESOLUTION , Literals . newLiteral ( roundtrip ( snapshotResolver , snapshotEndpoint , snapshot ) ) ) ; this . handler . update ( this . name , dataSet ) ; session . modify ( snapshot ) ; session . saveChanges ( ) ; } catch ( Exception e ) { LOGGER . error ( "Could not resolve resource" , e ) ; } finally { LOGGER . debug ( "Finalized resolution process" ) ; }


signature:
public class ImmutableTerm { /** * { @ inheritDoc } < br >
 * This method may be overridden , though it typically isn ' t necessary or
 * desirable . An term type should override this method when a more specific
 * value types are supported . */
@ Override public < V > V as ( Class < ? extends V > valueClass ) { } }

implementation: try { return TypeAdapter . adapt ( this , valueClass ) ; } catch ( CannotAdaptClassesException e ) { throw new UnsupportedOperationException ( "Class '" + getClass ( ) . getCanonicalName ( ) + " cannot be transformed to '" + valueClass . getCanonicalName ( ) + "'" , e ) ; }


signature:
public class ImmutableTerm { /** * Compares this term with the specified object for order . Returns a
 * negative integer , zero , or a positive integer as this object is less
 * than , equal to , or greater than the specified object .
 * Term constants are only comparable to other term constants of the same
 * vocabulary . The natural order implemented by this method is the order in
 * which the constants are declared . */
@ Override public int compareTo ( Term other ) { } }

implementation: ImmutableTerm self = this ; if ( self . getDeclaringVocabulary ( ) != other . getDeclaringVocabulary ( ) ) { throw new ClassCastException ( ) ; } return self . ordinal - other . ordinal ( ) ;


signature:
public class BookContainerHandler { /** * { @ inheritDoc } < br >
 * Create a new book resource . */
@ Override public ResourceSnapshot create ( ContainerSnapshot container , DataSet representation , WriteSession session ) { } }

implementation: NameProvider nameProvider = nameProvider ( container . name ( ) ) ; Name < ? > nextName = nameProvider . nextMemberName ( ) ; try { bookHandler ( ) . add ( nextName , representation ) ; ResourceSnapshot newMember = container . addMember ( nextName ) ; session . saveChanges ( ) ; return newMember ; } catch ( Exception e ) { bookHandler ( ) . remove ( nextName ) ; throw new ApplicationRuntimeException ( "Could not create member" , e ) ; }


signature:
public class InMemoryResourceHandler { /** * { @ inheritDoc }
 * @ throws UnknownResourceException if the resource is not known . */
@ Override public DataSet get ( ResourceSnapshot resource ) throws UnknownResourceException { } }

implementation: DataSet dataSet = this . resources . get ( resource . name ( ) ) ; if ( dataSet == null ) { throw new UnknownResourceException ( "Unknown resource '" + resource . name ( ) + "'" ) ; } return dataSet ;


signature:
public class InMemoryConstraintReportRepository { /** * { @ inheritDoc } */
@ Override public ConstraintReport constraintReportOfId ( ConstraintReportId id ) { } }

implementation: checkNotNull ( id , "Constraint report identifier cannot be null" ) ; this . lock . readLock ( ) . lock ( ) ; try { return this . reports . get ( id ) ; } finally { this . lock . readLock ( ) . unlock ( ) ; }


signature:
public class InMemoryConstraintReportRepository { /** * { @ inheritDoc } */
@ Override public void add ( ConstraintReport report ) { } }

implementation: checkNotNull ( report , "Constraint report cannot be null" ) ; this . lock . writeLock ( ) . lock ( ) ; try { ConstraintReportId id = report . id ( ) ; this . failureIds . put ( id . resourceId ( ) , id . failureId ( ) ) ; this . reports . put ( id , report ) ; } finally { this . lock . writeLock ( ) . unlock ( ) ; }


signature:
public class InMemoryConstraintReportRepository { /** * { @ inheritDoc } */
@ Override public void remove ( ConstraintReport report ) { } }

implementation: checkNotNull ( report , "Constraint report cannot be null" ) ; this . lock . writeLock ( ) . lock ( ) ; try { ConstraintReportId reportId = report . id ( ) ; this . failureIds . remove ( reportId . resourceId ( ) , reportId . failureId ( ) ) ; this . reports . remove ( reportId ) ; } finally { this . lock . writeLock ( ) . unlock ( ) ; }


signature:
public class InMemoryConstraintReportRepository { /** * { @ inheritDoc } */
@ Override public void removeByResource ( Resource resource ) { } }

implementation: checkNotNull ( resource , "Resource cannot be null" ) ; this . lock . writeLock ( ) . lock ( ) ; try { ResourceId resourceId = resource . id ( ) ; for ( String constraintsId : this . failureIds . get ( resourceId ) ) { this . reports . remove ( ConstraintReportId . create ( resourceId , constraintsId ) ) ; } this . failureIds . removeAll ( resourceId ) ; } finally { this . lock . writeLock ( ) . unlock ( ) ; }


signature:
public class InMemoryConstraintReportRepository { /** * { @ inheritDoc } */
@ Override public void shutdown ( ) throws LifecycleException { } }

implementation: this . lock . writeLock ( ) . lock ( ) ; try { this . reports . clear ( ) ; } finally { this . lock . writeLock ( ) . unlock ( ) ; }


signature:
public class AbstractMutableTemplate { /** * { @ inheritDoc } */
@ Override public Set < AttachedTemplate > attachedTemplates ( ) { } }

implementation: return Collections . unmodifiableSet ( new LinkedHashSet < AttachedTemplate > ( attachments . values ( ) ) ) ;


signature:
public class AbstractMutableTemplate { /** * { @ inheritDoc } */
@ Override public AttachedTemplate attachedTemplate ( String attachmentId ) { } }

implementation: checkNotNull ( attachmentId , "AttachmentSnapshot identifier cannot be null" ) ; return attachments . get ( attachmentId ) ;


signature:
public class IndividualPropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public < T > T firstValue ( Class < ? extends T > aClazz ) { } }

implementation: return this . pHelper . firstValue ( aClazz ) ;


signature:
public class IndividualPropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public < T extends Serializable , S extends Individual < T , S > > T firstIndividual ( Class < ? extends S > clazz ) { } }

implementation: return this . pHelper . firstIndividual ( clazz ) ;


signature:
public class IndividualPropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id , String managerId ) { } }

implementation: return this . pHelper . withIndividual ( id , managerId ) ;


signature:
public class NameProvider { /** * Return the pending names for the specified attachment .
 * @ param attachmentId
 * the name of the attachment .
 * @ return the pending names for the specified attachment . */
public List < Name < String > > pendingAttachmentNames ( String attachmentId ) { } }

implementation: List < Name < String > > result = new ArrayList < Name < String > > ( ) ; NameSource source = this . attachmentNameSources . get ( attachmentId ) ; if ( source != null ) { result . addAll ( source . pendingNames ) ; } return result ;


signature:
public class NameProvider { /** * Add a name to the list of available names for a given attachment .
 * @ param attachmentId
 * the name of the attachment .
 * @ param nextName
 * the member name . */
public void addAttachmentName ( String attachmentId , Name < String > nextName ) { } }

implementation: nameSource ( attachmentId ) . addName ( nextName ) ;


signature:
public class NameProvider { /** * Return the next available name for a given attachment . The name will be
 * removed from the list of available names for the specified attachment .
 * @ param attachmentId
 * the name of the attachment .
 * @ return the next available name for the specified attachment . */
public Name < String > nextAttachmentName ( String attachmentId ) { } }

implementation: NameSource result = this . attachmentNameSources . get ( attachmentId ) ; if ( result == null ) { result = new NameSource ( "attachment <<" + attachmentId + ">>" ) ; } return result . nextName ( ) ;


signature:
public class NameProvider { /** * Create a new name provider .
 * @ param resource
 * the name of the owner of the name provider .
 * @ return a name provider . */
public static NameProvider create ( Name < String > resource ) { } }

implementation: Objects . requireNonNull ( resource , "Owner name cannot be null" ) ; return new NameProvider ( resource ) ;


signature:
public class ImmutableMediaType { /** * Determine if the parameters in this { @ code MediaType } and the supplied
 * { @ code MediaType } are equal , ignoring parameters with special semantics
 * ( Charset and Q ) . */
private boolean hasSameCustomParameters ( final ImmutableMediaType that ) { } }

implementation: if ( this . parameters . size ( ) != that . parameters . size ( ) ) { return false ; } for ( final Entry < String , String > parameter : this . parameters . entrySet ( ) ) { final String key = parameter . getKey ( ) ; if ( MediaTypes . isStandardParameter ( key ) ) { continue ; } if ( ! Objects . equals ( parameter . getValue ( ) , that . parameters . get ( key ) ) ) { return false ; } } return true ;


signature:
public class ImmutableMediaType { /** * Parse the given String into a single { @ code MediaType } .
 * @ param mediaType
 * the string to parse
 * @ param syntax the syntax of the media type
 * @ return the mime type
 * @ throws InvalidMediaTypeException
 * if the string cannot be parsed */
static ImmutableMediaType fromString ( final String mediaType , final MediaRangeSyntax syntax ) { } }

implementation:
if ( mediaType == null ) { throw new InvalidMediaTypeException ( "Media type cannot be null" ) ; } if ( mediaType . isEmpty ( ) ) { throw new InvalidMediaTypeException ( mediaType , "Media type cannot be empty" ) ; } final String [ ] parts = mediaType . split ( PARAM_SEPARATOR ) ; String fullType = parts [ 0 ] ; // java . net . HttpURLConnection returns a * ; q = . 2 Accept header
if ( MediaTypes . WILDCARD_TYPE . equals ( fullType ) ) { fullType = "*/*" ; } final MediaRange mr = parseMediaRange ( mediaType , HttpUtils . trimWhitespace ( fullType ) ) ; final Map < String , String > parameters = parseParameters ( mediaType , parts ) ; try { return new ImmutableMediaType ( syntax , mr . type , mr . subType , mr . suffix , parameters ) ; } catch ( final IllegalArgumentException ex ) { throw new InvalidMediaTypeException ( mediaType , ex , "Could not create media type" ) ; }


signature:
public class ImmutableMediaType { /** * As per RFC 6838 , Section 4.2 structuring syntaxes specifier syntaxes are
 * defined after the last ' + ' symbol .
 * @ see < a href = " https : / / tools . ietf . org / html / rfc6838 # section - 4.2 > [ RFC 6838]
 * Media Type Specifications and Registration Procedures , Section
 * 4.2 < / a > */
private static void parseSuffix ( final MediaRange mr , final String mediaType ) { } }

implementation: final String subType = mr . subType ; final int plusIdx = subType . lastIndexOf ( '+' ) ; if ( plusIdx == 0 ) { throw new InvalidMediaTypeException ( mediaType , "missing subtype for structured media type (" + subType . substring ( 1 ) + ")" ) ; } else if ( plusIdx == subType . length ( ) - 1 ) { throw new InvalidMediaTypeException ( mediaType , "missing suffix for structured media type (" + subType . substring ( 0 , subType . length ( ) - 1 ) + ")" ) ; } else if ( plusIdx > 0 ) { mr . subType = subType . substring ( 0 , plusIdx ) ; mr . suffix = subType . substring ( plusIdx + 1 ) ; } // Otherwise the subtype does not define a structuring syntax .


signature:
public class ImmutableMediaType { /** * Checks the given quoted string for illegal characters , as defined in RFC
 * 7230 , section 3.2.6.
 * @ throws IllegalArgumentException
 * in case of illegal characters
 * @ see < a href = " http : / / tools . ietf . org / html / rfc7230 # section - 3.2.6 " > Hypertext
 * Transfer Protocol ( HTTP / 1.1 ) : Message Syntax and Routing , Section
 * 3.2.6 < / a > */
private static void checkQuotedString ( final String quotedString ) { } }

implementation: boolean quotedPair = false ; for ( int i = 0 ; i < quotedString . length ( ) ; i ++ ) { final char ch = quotedString . charAt ( i ) ; if ( quotedPair ) { checkArgument ( QUOTED_PAIR . get ( ch ) , "Invalid quoted-pair character '%s' in quoted string '%s' at %d" , ch , quotedString , i ) ; quotedPair = false ; } else if ( ch == SLASH ) { quotedPair = true ; } else { checkArgument ( QDTEXT . get ( ch ) , "Invalid character '%s' in quoted string '%s' at %d" , ch , quotedString , i ) ; } } checkArgument ( ! quotedPair , "Missing quoted-pair character in quoted string '%s' at %d" , quotedString , quotedString . length ( ) ) ;


signature:
public class DefaultPublicEndpoint { /** * { @ inheritDoc } */
@ Override public final Status status ( ) { } }

implementation: Status result = Status . PUBLISHED ; if ( this . endpoint . deleted ( ) != null ) { return Status . GONE ; } return result ;


signature:
public class DefaultPublicEndpoint { /** * { @ inheritDoc } */
@ Override public final Capabilities capabilities ( ) { } }

implementation: if ( this . capabilities == null ) { this . capabilities = this . applicationContext . endpointCapabilities ( this . endpoint ) ; } return this . capabilities ;


signature:
public class CodePointIterator { /** * Returns the next code point in the iteration .
 * @ return the next code point in the iteration
 * @ throws NoSuchElementException
 * if the iteration has no more code points */
@ Override public Integer next ( ) { } }

implementation: if ( ! hasNext ( ) ) { throw new NoSuchElementException ( "No more codepoints available in the CharSequence" ) ; } this . index = this . next ; final Integer codePoint = Character . codePointAt ( this . s , this . next ) ; this . next += Character . charCount ( codePoint ) ; return codePoint ;


signature:
public class DynamicResourceUpdater { /** * Update the resource representation adding a temporal timestamp of when
 * the resource was last updated . */
@ Override public void run ( ) { } }

implementation: ApplicationContext ctx = ApplicationContext . getInstance ( ) ; Date date = new Date ( ) ; LOGGER . debug ( "Starting update process on {}..." , date ) ; try ( WriteSession session = ctx . createSession ( ) ) { ResourceSnapshot snapshot = session . find ( ResourceSnapshot . class , this . name , DynamicResourceHandler . class ) ; DataSet dataSet = this . handler . get ( snapshot ) ; Individual < ? , ? > individual = dataSet . individualOfId ( ManagedIndividualId . createId ( this . name , DynamicResourceHandler . ID ) ) ; individual . addValue ( REFRESHED_ON , Literals . of ( date ) . dateTime ( ) ) ; this . handler . update ( this . name , dataSet ) ; session . modify ( snapshot ) ; session . saveChanges ( ) ; } catch ( Exception e ) { LOGGER . error ( "Could not update resource" , e ) ; } finally { LOGGER . debug ( "Finalized update process" ) ; }


signature:
public class URIRef { /** * 5.3 . Component Recomposition
 * Parsed URI components can be recomposed to obtain the corresponding
 * URI reference string . Using pseudocode , this would be :
 * result = " "
 * if defined ( scheme ) then
 * append scheme to result ;
 * append " : " to result ;
 * endif ;
 * if defined ( authority ) then
 * append " / / " to result ;
 * append authority to result ;
 * endif ;
 * append path to result ;
 * if defined ( query ) then
 * append " ? " to result ;
 * append query to result ;
 * endif ;
 * if defined ( fragment ) then
 * append " # " to result ;
 * append fragment to result ;
 * endif ;
 * return result ;
 * Note that we are careful to preserve the distinction between a
 * component that is undefined , meaning that its separator was not
 * present in the reference , and a component that is empty , meaning that
 * the separator was present and was immediately followed by the next
 * component separator or the end of the reference . */
URI toURI ( ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; if ( defined ( this . scheme ) ) { builder . append ( this . scheme ) ; builder . append ( ":" ) ; } if ( defined ( this . authority ) ) { builder . append ( "//" ) ; builder . append ( this . authority ) ; } if ( defined ( this . path ) ) { builder . append ( this . path ) ; } if ( defined ( this . query ) ) { builder . append ( "?" ) ; builder . append ( this . query ) ; } if ( defined ( this . fragment ) ) { builder . append ( "#" ) ; builder . append ( this . fragment ) ; } String rawURI = builder . toString ( ) ; return URI . create ( rawURI ) ;


signature:
public class RuntimeInstance { /** * Close an input stream logging possible failures .
 * @ param is The input stream that is to be closed .
 * @ param message The message to log in case of failure . */
private static void closeQuietly ( final InputStream is , final String message ) { } }

implementation: if ( is != null ) { try { is . close ( ) ; } catch ( final Exception e ) { if ( LOGGER . isWarnEnabled ( ) ) { LOGGER . warn ( message , e ) ; } } }


signature:
public class RuntimeInstance { /** * Obtain a { @ code RuntimeInstance } instance . If an instance had not already
 * been created and set via { @ link # setInstance ( RuntimeInstance ) } , the first
 * invocation will create an instance which will then be cached for future
 * use .
 * The algorithm used to locate the RuntimeInstance subclass to use consists
 * of the following steps :
 * < ul >
 * < li >
 * If a resource with the name of
 * { @ code META - INF / services / org . centeropenmiddleware . almistack . poc . clients . spi . RuntimeInstance } exists , then
 * its first line , if present , is used as the UTF - 8 encoded name of the
 * implementation class . < / li >
 * < li >
 * If the $ java . home / lib / poc - business - logic . properties file exists and it is readable by
 * the { @ code java . util . Properties . load ( InputStream ) } method and it contains
 * an entry whose key is { @ code org . centeropenmiddleware . almistack . poc . clients . spi . RuntimeInstance } , then the
 * value of that entry is used as the name of the implementation class . < / li >
 * < li >
 * If a system property with the name
 * { @ code org . centeropenmiddleware . almistack . poc . clients . spi . RuntimeInstance } is defined , then its value is
 * used as the name of the implementation class . < / li >
 * < li >
 * Finally , a default implementation class name is used . < / li >
 * < / ul >
 * @ return an instance of { @ code RuntimeInstance } . */
public static RuntimeInstance getInstance ( ) { } }

implementation: RuntimeInstance result = RuntimeInstance . CACHED_DELEGATE . get ( ) ; if ( result != null ) { return result ; } synchronized ( RuntimeInstance . CACHED_DELEGATE ) { result = RuntimeInstance . CACHED_DELEGATE . get ( ) ; if ( result == null ) { RuntimeInstance . CACHED_DELEGATE . set ( findDelegate ( ) ) ; result = RuntimeInstance . CACHED_DELEGATE . get ( ) ; } return result ; }


signature:
public class Characters { /** * Determines if a character is a Name start character .
 * @ param codePoint
 * The code point of the character to be tested . For UTF - 16
 * characters the code point corresponds to the value of the char
 * that represents the character .
 * @ return { @ code true } if { @ code codePoint } is a Name start character ,
 * otherwise { @ code false }
 * @ see < b > Name < / b > definition in the < a
 * href = " https : / / www . w3 . org / TR / REC - xml / # d0e804 " > Extensible Markup
 * Language ( XML ) 1.0 ( Fifth Edition ) < / a > specification . */
static boolean isNameStartChar ( final int codePoint ) { } }

implementation: return ( codePoint == ':' ) || ( codePoint >= 'A' && codePoint <= 'Z' ) || ( codePoint == '_' ) || ( codePoint >= 'a' && codePoint <= 'z' ) || ( codePoint >= 0xC0 && codePoint <= 0xD6 ) || ( codePoint >= 0xD8 && codePoint <= 0xF6 ) || ( codePoint >= 0xF8 && codePoint <= 0x2FF ) || ( codePoint >= 0x370 && codePoint <= 0x37D ) || ( codePoint >= 0x37F && codePoint <= 0x1FFF ) || ( codePoint >= 0x200C && codePoint <= 0x200D ) || ( codePoint >= 0x2070 && codePoint <= 0x218F ) || ( codePoint >= 0x2C00 && codePoint <= 0x2FEF ) || ( codePoint >= 0x3001 && codePoint <= 0xD7FF ) || ( codePoint >= 0xF900 && codePoint <= 0xFDCF ) || ( codePoint >= 0xFDF0 && codePoint <= 0xFFFD ) || ( codePoint >= 0x10000 && codePoint <= 0xEFFFF ) ;


signature:
public class Characters { /** * Determines if a character is a Name character .
 * @ param codePoint
 * The code point of the character to be tested . For UTF - 8 and UTF - 16
 * characters the code point corresponds to the value of the char
 * that represents the character .
 * @ return { @ code true } if { @ code codePoint } is a Name character ,
 * otherwise { @ code false }
 * @ see < b > Name < / b > definition in the < a
 * href = " https : / / www . w3 . org / TR / REC - xml / # d0e804 " > Extensible Markup
 * Language ( XML ) 1.0 ( Fifth Edition ) < / a > specification . */
static boolean isNameChar ( final int codePoint ) { } }

implementation: return isNameStartChar ( codePoint ) || ( codePoint == '-' ) || ( codePoint == '.' ) || ( codePoint >= '0' && codePoint <= '9' ) || ( codePoint == 0xB7 ) || ( codePoint >= 0x0300 && codePoint <= 0x036F ) || ( codePoint >= 0x203F && codePoint <= 0x2040 ) ;


signature:
public class Languages { /** * Create a { @ code Language } for a given { @ code Locale } .
 * @ param locale
 * the { @ code Locale } for the { @ code Language }
 * @ return a { @ code Language } instance with the specified { @ code Locale }
 * @ throws NullPointerException
 * if { @ code locale } is { @ code null }
 * @ throws IllegalArgumentException
 * if the provided locale is a variant ( i . e . ,
 * { @ link Locale # getVariant ( ) } is not empty ) */
public static Language of ( final Locale locale ) { } }

implementation: requireNonNull ( locale , "Locale cannot be null" ) ; checkArgument ( locale . getVariant ( ) . isEmpty ( ) , "Language does not allow locale variants (%s)" , locale . getVariant ( ) ) ; return new ImmutableLanguage ( locale ) ;


signature:
public class Languages { /** * Create a { @ code Language } instance from a valid { @ code language - range }
 * definition .
 * @ param language
 * the language - range for the language to be loaded .
 * @ return the { @ code Language } instance for the specified language - range
 * @ throws NullPointerException
 * if { @ code language } is null
 * @ throws IllegalArgumentException
 * if { @ code language } is not a valid { @ code language - range }
 * @ see < a href = " http : / / tools . ietf . org / html / rfc4674 # section - 2.1 " > RFC 4674 -
 * Section 2.1 < / a >
 * @ see < a href = " http : / / tools . ietf . org / html / rfc7231 # section - 5.3.5 " > RFC 7231
 * - Section 5.3.5 < / a > */
public static Language fromString ( final String language ) { } }

implementation: requireNonNull ( language , "Language cannot be null" ) ; if ( WILDCARD . equals ( language ) ) { return wildcard ( ) ; } else { return of ( parseLocale ( language ) ) ; }


signature:
public class Languages { /** * Implements Basic Filtering matching algorithm defined in
 * < a href = " https : / / tools . ietf . org / html / rfc4647 # section - 3.3.1 " > Section
 * 3.3.1 < / a > of the < b > Matching of Language Tags < / b > ( BCP 47)
 * @ param language1
 * the including language
 * @ param language2
 * the language that will be checked for inclusion
 * @ return true , if the { @ code language1 } includes { @ code language2}
 * attending to the aforementioned algorithm . */
public static boolean includes ( final Language language1 , final Language language2 ) { } }

implementation: if ( language1 == null || language2 == null ) { return false ; } if ( language1 . isWildcard ( ) ) { return true ; } if ( language2 . isWildcard ( ) ) { return false ; } return language1 . primaryTag ( ) . equals ( language2 . primaryTag ( ) ) && ( language1 . subTag ( ) . isEmpty ( ) || language1 . subTag ( ) . equals ( language2 . subTag ( ) ) ) ;


signature:
public class AbstractEncoder { /** * { @ inheritDoc } */
@ Override public final String encode ( Name < ? > name ) { } }

implementation: if ( name == null ) { return null ; } try { Serializable target = prepare ( name ) ; byte [ ] serializedData = SerializationUtils . serialize ( target ) ; return BaseEncoding . base64 ( ) . encode ( serializedData ) ; } catch ( IOException e ) { throw new AssertionError ( "Serialization should not fail" , e ) ; }


signature:
public class AbstractEncoder { /** * { @ inheritDoc } */
@ Override public final < T extends Serializable > Name < T > decode ( String data ) { } }

implementation: if ( data == null ) { return null ; } try { byte [ ] serializedData = BaseEncoding . base64 ( ) . decode ( data ) ; Serializable subject = SerializationUtils . deserialize ( serializedData , Serializable . class ) ; return assemble ( subject ) ; } catch ( IOException e ) { throw new AssertionError ( "Deserialization should not fail" , e ) ; }


signature:
public class NullPropertyHelper { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id , String managerId , URI path ) { } }

implementation: return this . iph ;


signature:
public class ModelUtils { /** * correct split if local name has no ' : ' and URI contains no ' # ' or ' / ' */
private static boolean isCorrectColonNamespaceURISplit ( String namespace , String localName , char lastNsChar ) { } }

implementation: return lastNsChar == COLON && isValidColonLocalName ( localName ) && isValidColonNamespace ( namespace ) ;


signature:
public class ModelUtils { /** * correct split if local name has no ' / ' and URI contains no ' # ' */
private static boolean isCorrectSlashNamespaceURISplit ( String namespace , String localName , char lastNsChar ) { } }

implementation: return lastNsChar == SLASH && isValidSlashLocalName ( localName ) && isValidSlashNamespace ( namespace ) ;


signature:
public class ModelUtils { /** * correct split if namespace has no other ' # ' */
private static boolean isCorrectHashNamespaceURISplit ( String namespace , int nsLength , char lastNsChar ) { } }

implementation: return lastNsChar == HASH && namespace . lastIndexOf ( HASH , nsLength - 2 ) == - 1 ;