@Override public String getMethodContent(IType objectClass, EqualsHashCodeGenerationData data) throws JavaModelException { boolean cacheProperty = getPreferencesManager() .getCurrentPreferenceValue(JeneratePreferences.CACHE_HASHCODE) .booleanValue(); String cachingField = getPreferencesManager() .getCurrentPreferenceValue(JeneratePreferences.HASHCODE_CACHING_FIELD); boolean isCacheable = MethodContentGenerations.createField( objectClass, data, cacheProperty, cachingField, int.class); return createHashCodeMethodContent(data, isCacheable, cachingField); }
private static String createHashCodeBuilderString(EqualsHashCodeGenerationData data) throws JavaModelException { StringBuffer content = new StringBuffer(); content.append("new HashCodeBuilder("); content.append(data.getInitMultNumbers().getValue()); content.append(")"); if (data.appendSuper()) { content.append(".appendSuper(super.hashCode())"); } IField[] checkedFields = data.getCheckedFields(); for (int i = 0; i < checkedFields.length; i++) { content.append(".append("); content.append( MethodContentGenerations.getFieldAccessorString( checkedFields[i], data.useGettersInsteadOfFields())); content.append(")"); } content.append(".toHashCode();\n"); return content.toString(); }
@Override public LinkedHashSet<String> getLibrariesToImport(EqualsHashCodeGenerationData data) { return MethodContentGenerations.createSingletonLinkedHashSet( CommonsLangMethodContentLibraries.getHashCodeBuilderLibrary(getStrategyIdentifier())); }