@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity",
		"checkstyle:booleanexpressioncomplexity"})
	private JvmOperation toHashCodeMethod(
			XtendTypeDeclaration sarlElement,
			final Iterable<JvmField> jvmFields,
			boolean generatePureAnnotation) {
		if (sarlElement == null) {
			return null;
		}
		final JvmOperation result = this.typeBuilder.toMethod(sarlElement, HASHCODE_FUNCTION_NAME,
				this._typeReferenceBuilder.typeRef(int.class), null);
		if (result == null) {
			return null;
		}
		addAnnotationSafe(result, Override.class);
		if (generatePureAnnotation) {
			addAnnotationSafe(result, Pure.class);
		}
		setBody(result, it -> {
			final TypeReferences refs = SARLJvmModelInferrer.this.typeReferences;
			it.append("int result = super.").append(HASHCODE_FUNCTION_NAME); //$NON-NLS-1$
			it.append("();"); //$NON-NLS-1$
			boolean firstAttr = true;
			for (final JvmField field : jvmFields) {
				if (isEqualityTestValidField(field.getType())) {
					if (firstAttr) {
						firstAttr = false;
						it.newLine().append("final int prime = 31;"); //$NON-NLS-1$
					}
					final JvmTypeReference type = field.getType();
					if (refs.is(type, Boolean.TYPE) || refs.is(type, Boolean.class)) {
						it.newLine().append("result = prime * result + (this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(" ? 1231 : 1237);"); //$NON-NLS-1$
					} else if (refs.is(type, Integer.TYPE) || refs.is(type, Integer.class)
							|| refs.is(type, Character.TYPE) || refs.is(type, Character.class)
							|| refs.is(type, Byte.TYPE) || refs.is(type, Byte.class)
							|| refs.is(type, Short.TYPE) || refs.is(type, Short.class)) {
						it.newLine().append("result = prime * result + this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(";"); //$NON-NLS-1$
					} else if (refs.is(type, Long.TYPE) || refs.is(type, Long.class)) {
						it.newLine().append("result = prime * result + (int) (this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(" ^ (this.").append(field.getSimpleName()); //$NON-NLS-1$
						it.append(" >>> 32));"); //$NON-NLS-1$
					} else if (refs.is(type, Float.TYPE) || refs.is(type, Float.class)) {
						it.newLine().append("result = prime * result + Float.floatToIntBits(this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
					} else if (refs.is(type, Double.TYPE) || refs.is(type, Double.class)) {
						it.newLine().append("result = prime * result + (int) (Double.doubleToLongBits(this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(") ^ (Double.doubleToLongBits(this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(") >>> 32));"); //$NON-NLS-1$
					} else {
						it.newLine().append("result = prime * result + "); //$NON-NLS-1$
						it.append(java.util.Objects.class).append(".hashCode(this."); //$NON-NLS-1$
						it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
					}
				}
			}
			it.newLine().append("return result;"); //$NON-NLS-1$
		});

		return result;
	}
@ SuppressWarnings ( { "checkstyle:npathcomplexity" , "checkstyle:cyclomaticcomplexity" , "checkstyle:booleanexpressioncomplexity" } ) private JvmOperation toHashCodeMethod ( XtendTypeDeclaration sarlElement , final Iterable < JvmField > jvmFields , boolean generatePureAnnotation ) { if ( sarlElement == null ) { return null ; } final JvmOperation result = this . typeBuilder . toMethod ( sarlElement , HASHCODE_FUNCTION_NAME , this . _typeReferenceBuilder . typeRef ( int . class ) , null ) ; if ( result == null ) { return null ; } addAnnotationSafe ( result , Override . class ) ; if ( generatePureAnnotation ) { addAnnotationSafe ( result , Pure . class ) ; } setBody ( result , it -> { final TypeReferences refs = SARLJvmModelInferrer . this . typeReferences ; it . append ( "int result = super." ) . append ( HASHCODE_FUNCTION_NAME ) ; it . append ( "();" ) ; boolean firstAttr = true ; for ( final JvmField field : jvmFields ) { if ( isEqualityTestValidField ( field . getType ( ) ) ) { if ( firstAttr ) { firstAttr = false ; it . newLine ( ) . append ( "final int prime = 31;" ) ; } final JvmTypeReference type = field . getType ( ) ; if ( refs . is ( type , Boolean . TYPE ) || refs . is ( type , Boolean . class ) ) { it . newLine ( ) . append ( "result = prime * result + (this." ) ; it . append ( field . getSimpleName ( ) ) . append ( " ? 1231 : 1237);" ) ; } else if ( refs . is ( type , Integer . TYPE ) || refs . is ( type , Integer . class ) || refs . is ( type , Character . TYPE ) || refs . is ( type , Character . class ) || refs . is ( type , Byte . TYPE ) || refs . is ( type , Byte . class ) || refs . is ( type , Short . TYPE ) || refs . is ( type , Short . class ) ) { it . newLine ( ) . append ( "result = prime * result + this." ) ; it . append ( field . getSimpleName ( ) ) . append ( ";" ) ; } else if ( refs . is ( type , Long . TYPE ) || refs . is ( type , Long . class ) ) { it . newLine ( ) . append ( "result = prime * result + (int) (this." ) ; it . append ( field . getSimpleName ( ) ) . append ( " ^ (this." ) . append ( field . getSimpleName ( ) ) ; it . append ( " >>> 32));" ) ; } else if ( refs . is ( type , Float . TYPE ) || refs . is ( type , Float . class ) ) { it . newLine ( ) . append ( "result = prime * result + Float.floatToIntBits(this." ) ; it . append ( field . getSimpleName ( ) ) . append ( ");" ) ; } else if ( refs . is ( type , Double . TYPE ) || refs . is ( type , Double . class ) ) { it . newLine ( ) . append ( "result = prime * result + (int) (Double.doubleToLongBits(this." ) ; it . append ( field . getSimpleName ( ) ) . append ( ") ^ (Double.doubleToLongBits(this." ) ; it . append ( field . getSimpleName ( ) ) . append ( ") >>> 32));" ) ; } else { it . newLine ( ) . append ( "result = prime * result + " ) ; it . append ( java . util . Objects . class ) . append ( ".hashCode(this." ) ; it . append ( field . getSimpleName ( ) ) . append ( ");" ) ; } } } it . newLine ( ) . append ( "return result;" ) ; } ) ; return result ; }
Generate the "hashCode()" operation.
This function was deprecated in Xbase, and should be provided by DSL
providers now.

@param sarlElement the SARL element for which the "hashCode" msut be generated.
@param jvmFields the fields declared in the container.
@return the "hashCode" function.