Replace custom hashCode code with Objects.hash() / Arrays.deepHashCode()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2019-12-23 00:15:55 +00:00
parent ba6152503e
commit 66471836f5
56 changed files with 411 additions and 716 deletions

View File

@ -197,7 +197,7 @@ public class EscherComplexProperty extends EscherProperty {
@Override
public int hashCode() {
return getId() * 11;
return Arrays.deepHashCode(new Object[]{complexData, getId()});
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.poi.ddf;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.util.GenericRecordUtil;
@ -142,9 +143,8 @@ public class EscherSimpleProperty extends EscherProperty
* require the use of such things.
*/
@Override
public int hashCode()
{
return propertyValue;
public int hashCode() {
return Objects.hash(propertyValue, getId());
}
@Override

View File

@ -17,6 +17,8 @@
package org.apache.poi.hpsf;
import java.util.Objects;
/**
* This class represents custom properties in the document summary
* information stream. The difference to normal properties is that custom
@ -108,11 +110,11 @@ public class CustomProperty extends Property
*/
@Override
public int hashCode() {
return (int) this.getID();
return Objects.hash(name, getID());
}
@Override
public boolean equals(Object o) {
return (o instanceof CustomProperty) ? equalsContents(o) : false;
return (o instanceof CustomProperty) && equalsContents(o);
}
}

View File

@ -25,6 +25,7 @@ import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
@ -369,13 +370,7 @@ public class Property {
*/
@Override
public int hashCode() {
long hashCode = 0;
hashCode += id;
hashCode += type;
if (value != null) {
hashCode += value.hashCode();
}
return (int) (hashCode & 0x0ffffffffL );
return Objects.hash(id,type,value);
}

View File

@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -940,17 +941,9 @@ public class Section {
*/
@Override
public int hashCode() {
long hashCode = 0;
hashCode += getFormatID().hashCode();
final Property[] pa = getProperties();
for (Property aPa : pa) {
hashCode += aPa.hashCode();
}
return Math.toIntExact(hashCode & 0x0ffffffffL);
return Arrays.deepHashCode(new Object[]{getFormatID(),getProperties()});
}
/**
* @see Object#toString()
*/

View File

@ -18,6 +18,8 @@
package org.apache.poi.hssf.record;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndianOutput;
@ -1799,18 +1801,17 @@ public final class ExtendedFormatRecord extends StandardRecord {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + field_1_font_index;
result = prime * result + field_2_format_index;
result = prime * result + field_3_cell_options;
result = prime * result + field_4_alignment_options;
result = prime * result + field_5_indention_options;
result = prime * result + field_6_border_options;
result = prime * result + field_7_palette_options;
result = prime * result + field_8_adtl_palette_options;
result = prime * result + field_9_fill_palette_options;
return result;
return Objects.hash(
field_1_font_index
, field_2_format_index
, field_3_cell_options
, field_4_alignment_options
, field_5_indention_options
, field_6_border_options
, field_7_palette_options
, field_8_adtl_palette_options
, field_9_fill_palette_options
);
}
/**

View File

@ -458,22 +458,18 @@ public final class FontRecord extends StandardRecord {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime
* result
+ ((field_11_font_name == null) ? 0 : field_11_font_name
.hashCode());
result = prime * result + field_1_font_height;
result = prime * result + field_2_attributes;
result = prime * result + field_3_color_palette_index;
result = prime * result + field_4_bold_weight;
result = prime * result + field_5_super_sub_script;
result = prime * result + field_6_underline;
result = prime * result + field_7_family;
result = prime * result + field_8_charset;
result = prime * result + field_9_zero;
return result;
return Objects.hash(
field_1_font_height
, field_2_attributes
, field_3_color_palette_index
, field_4_bold_weight
, field_5_super_sub_script
, field_6_underline
, field_7_family
, field_8_charset
, field_9_zero
, field_11_font_name
);
}
/**

View File

@ -222,20 +222,7 @@ public class ExtRst implements Comparable<ExtRst> {
@Override
public int hashCode() {
int hash = reserved;
hash = 31*hash+formattingFontIndex;
hash = 31*hash+formattingOptions;
hash = 31*hash+numberOfRuns;
hash = 31*hash+phoneticText.hashCode();
if (phRuns != null) {
for (PhRun ph : phRuns) {
hash = 31*hash+ph.phoneticTextFirstCharacterOffset;
hash = 31*hash+ph.realTextFirstCharacterOffset;
hash = 31*hash+ph.realTextLength;
}
}
return hash;
return Arrays.deepHashCode(new Object[]{reserved, formattingFontIndex, formattingOptions, numberOfRuns, phoneticText, phRuns});
}
public ExtRst copy() {

View File

@ -17,6 +17,8 @@
package org.apache.poi.hssf.record.common;
import java.util.Objects;
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianInput;
@ -52,4 +54,9 @@ public class PhRun {
out.writeShort(realTextFirstCharacterOffset);
out.writeShort(realTextLength);
}
@Override
public int hashCode() {
return Objects.hash(phoneticTextFirstCharacterOffset, realTextFirstCharacterOffset, realTextLength);
}
}

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.poi.common.Duplicatable;
@ -103,13 +104,8 @@ public class UnicodeString implements Comparable<UnicodeString>, Duplicatable {
}
}
public int hashCode()
{
int stringHash = 0;
if (field_3_string != null) {
stringHash = field_3_string.hashCode();
}
return field_1_charCount + stringHash;
public int hashCode() {
return Objects.hash(field_1_charCount, field_3_string);
}
/**

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
import java.util.Objects;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherContainerRecord;
@ -332,6 +334,6 @@ public class HSSFComment extends HSSFTextbox implements Comment {
@Override
public int hashCode() {
return ((getRow()*17) + getColumn())*31;
return Objects.hash(getRow(),getColumn());
}
}

View File

@ -17,6 +17,8 @@
package org.apache.poi.hssf.usermodel;
import java.util.Objects;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Font;
@ -344,11 +346,7 @@ public final class HSSFFont implements Font {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((font == null) ? 0 : font.hashCode());
result = prime * result + index;
return result;
return Objects.hash(font,index);
}
public boolean equals(Object obj) {

View File

@ -22,6 +22,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import org.apache.poi.ss.usermodel.Color;
import org.apache.poi.util.Removal;
@ -348,10 +349,7 @@ public class HSSFColor implements Color {
@Override
public int hashCode() {
int result = color != null ? color.hashCode() : 0;
result = 31 * result + index;
result = 31 * result + index2;
return result;
return Objects.hash(color,index,index2);
}
/**

View File

@ -17,11 +17,18 @@
package org.apache.poi.ss.formula;
import java.text.CollationKey;
import java.text.Collator;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.BoolEval;
@ -283,10 +290,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
@Override
public int hashCode() {
int hash = sheet.getSheetName().hashCode();
hash = 31 * hash + formattingIndex;
hash = 31 * hash + ruleIndex;
return hash;
return Objects.hash(sheet.getSheetName(),formattingIndex,ruleIndex);
}
/**
@ -938,7 +942,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
@Override
public int hashCode() {
return (string == null ? 0 : string.hashCode()) * 37 * 37 + 37 * (value == null ? 0 : value.hashCode()) + (format == null ? 0 : format.hashCode());
return Objects.hash(string,value,format);
}
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.ss.util;
import static org.apache.poi.util.StringUtil.endsWithIgnoreCase;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -584,12 +585,6 @@ public class CellReference {
@Override
public int hashCode() {
int result = 17;
result = 31 * result + _rowIndex;
result = 31 * result + _colIndex;
result = 31 * result + (_isRowAbs ? 1 : 0);
result = 31 * result + (_isColAbs ? 1 : 0);
result = 31 * result + (_sheetName == null ? 0 : _sheetName.hashCode());
return result;
return Objects.hash(_rowIndex,_colIndex,_isRowAbs,_isColAbs,_sheetName);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.poi.openxml4j.opc;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
/**
* A part relationship.
@ -129,11 +130,7 @@ public final class PackageRelationship {
@Override
public int hashCode() {
return this.id.hashCode()
+ this.relationshipType.hashCode()
+ (this.source == null ? 0 : this.source.hashCode())
+ this.targetMode.hashCode()
+ this.targetUri.hashCode();
return Objects.hash(id,relationshipType,source,targetMode,targetUri);
}
/* Getters */

View File

@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -212,7 +213,7 @@ public final class ContentType {
@Override
public int hashCode() {
return this.toString().hashCode();
return Objects.hash(type,subType,parameters);
}
/* Getters */

View File

@ -17,6 +17,8 @@
package org.apache.poi.xssf.binary;
import java.util.Objects;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
@ -97,12 +99,7 @@ public class XSSFHyperlinkRecord {
@Override
public int hashCode() {
int result = cellRangeAddress != null ? cellRangeAddress.hashCode() : 0;
result = 31 * result + (relId != null ? relId.hashCode() : 0);
result = 31 * result + (location != null ? location.hashCode() : 0);
result = 31 * result + (toolTip != null ? toolTip.hashCode() : 0);
result = 31 * result + (display != null ? display.hashCode() : 0);
return result;
return Objects.hash(cellRangeAddress,relId,location,toolTip,display);
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.poi.hslf.model.textproperties;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.common.Duplicatable;
@ -100,11 +101,7 @@ public class HSLFTabStop implements TabStop, Duplicatable, GenericRecord {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + position;
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
return Objects.hash(position, type);
}
@Override

View File

@ -21,6 +21,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.sl.usermodel.TabStop.TabStopType;
@ -123,7 +124,7 @@ public class HSLFTabStopPropCollection extends TextProp {
@Override
public int hashCode() {
return 31 * super.hashCode() + tabStops.hashCode();
return Objects.hash(super.hashCode(), tabStops);
}
@Override

View File

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.common.Duplicatable;
@ -334,13 +335,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + charactersCovered;
result = prime * result + maskSpecial;
result = prime * result + indentLevel;
result = prime * result + textProps.hashCode();
return result;
return Objects.hash(charactersCovered,maskSpecial,indentLevel,textProps);
}
/**
* compares most properties apart of the covered characters length

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.BKFAbstractType;
import org.apache.poi.util.Internal;
@ -63,13 +65,8 @@ public final class BookmarkFirstDescriptor extends BKFAbstractType implements
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_ibkl;
result = prime * result + field_2_bkf_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_ibkl,field_2_bkf_flags);
}
public boolean isEmpty()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FibBaseAbstractType;
import org.apache.poi.util.Internal;
@ -84,22 +86,8 @@ public class FibBase extends FibBaseAbstractType {
@Override
@SuppressWarnings( "deprecation" )
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + field_10_flags2;
result = prime * result + field_11_Chs;
result = prime * result + field_12_chsTables;
result = prime * result + field_13_fcMin;
result = prime * result + field_14_fcMac;
result = prime * result + field_1_wIdent;
result = prime * result + field_2_nFib;
result = prime * result + field_3_unused;
result = prime * result + field_4_lid;
result = prime * result + field_5_pnNext;
result = prime * result + field_6_flags1;
result = prime * result + field_7_nFibBack;
result = prime * result + field_8_lKey;
result = prime * result + field_9_envr;
return result;
return Objects.hash(field_1_wIdent, field_2_nFib, field_3_unused, field_4_lid, field_5_pnNext, field_6_flags1,
field_7_nFibBack, field_8_lKey, field_9_envr, field_10_flags2, field_11_Chs, field_12_chsTables,
field_13_fcMin, field_14_fcMac);
}
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FibRgW97AbstractType;
import org.apache.poi.util.Internal;
@ -86,25 +88,10 @@ public class FibRgW97 extends FibRgW97AbstractType
@Override
@SuppressWarnings( "deprecation" )
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_10_reserved10;
result = prime * result + field_11_reserved11;
result = prime * result + field_12_reserved12;
result = prime * result + field_13_reserved13;
result = prime * result + field_14_lidFE;
result = prime * result + field_1_reserved1;
result = prime * result + field_2_reserved2;
result = prime * result + field_3_reserved3;
result = prime * result + field_4_reserved4;
result = prime * result + field_5_reserved5;
result = prime * result + field_6_reserved6;
result = prime * result + field_7_reserved7;
result = prime * result + field_8_reserved8;
result = prime * result + field_9_reserved9;
return result;
public int hashCode() {
return Objects.hash(field_1_reserved1, field_2_reserved2, field_3_reserved3, field_4_reserved4,
field_5_reserved5, field_6_reserved6, field_7_reserved7, field_8_reserved8, field_9_reserved9,
field_10_reserved10, field_11_reserved11, field_12_reserved12, field_13_reserved13, field_14_lidFE);
}
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FRDAbstractType;
import org.apache.poi.util.Internal;
@ -61,12 +63,8 @@ public final class FootnoteReferenceDescriptor extends FRDAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_nAuto;
return result;
public int hashCode() {
return Objects.hash(field_1_nAuto);
}
public boolean isEmpty()

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.HRESIAbstractType;
import org.apache.poi.hwpf.usermodel.CharacterProperties;
import org.apache.poi.util.Internal;
@ -79,13 +81,8 @@ public final class Hyphenation extends HRESIAbstractType implements Cloneable
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_hres;
result = prime * result + field_2_chHres;
return result;
public int hashCode() {
return Objects.hash(field_1_hres,field_2_chHres);
}
public boolean isEmpty()

View File

@ -104,8 +104,6 @@ public class LFOData
@Override
public int hashCode() {
int result = _cp;
result = 31 * result + Arrays.hashCode(_rgLfoLvl);
return result;
return Arrays.deepHashCode(_rgLfoLvl);
}
}

View File

@ -106,13 +106,8 @@ public final class ListData
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode( _levels );
result = prime * result + ( ( _lstf == null ) ? 0 : _lstf.hashCode() );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_levels,_lstf});
}
public int numLevels()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.Internal;
/**
@ -81,13 +83,8 @@ public final class ListFormatOverrideLevel
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _base.hashCode();
result = prime * result + ( _lvl != null ? _lvl.hashCode() : 0 );
return result;
public int hashCode() {
return Objects.hash(_base,_lvl);
}
public boolean isFormatting()

View File

@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -162,13 +163,8 @@ public final class ListTables
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _listMap.hashCode();
result = prime * result + ( ( _plfLfo == null ) ? 0 : _plfLfo.hashCode() );
return result;
public int hashCode() {
return Objects.hash(_listMap,_plfLfo);
}
@Override

View File

@ -111,38 +111,12 @@ public class PICF extends PICFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_10_padding2;
result = prime * result + field_11_dxaGoal;
result = prime * result + field_12_dyaGoal;
result = prime * result + field_13_mx;
result = prime * result + field_14_my;
result = prime * result + field_15_dxaReserved1;
result = prime * result + field_16_dyaReserved1;
result = prime * result + field_17_dxaReserved2;
result = prime * result + field_18_dyaReserved2;
result = prime * result + field_19_fReserved;
result = prime * result + field_1_lcb;
result = prime * result + field_20_bpp;
result = prime * result + Arrays.hashCode( field_21_brcTop80 );
result = prime * result + Arrays.hashCode( field_22_brcLeft80 );
result = prime * result + Arrays.hashCode( field_23_brcBottom80 );
result = prime * result + Arrays.hashCode( field_24_brcRight80 );
result = prime * result + field_25_dxaReserved3;
result = prime * result + field_26_dyaReserved3;
result = prime * result + field_27_cProps;
result = prime * result + field_2_cbHeader;
result = prime * result + field_3_mm;
result = prime * result + field_4_xExt;
result = prime * result + field_5_yExt;
result = prime * result + field_6_swHMF;
result = prime * result + field_7_grf;
result = prime * result + field_8_padding;
result = prime * result + field_9_mmPM;
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_lcb, field_2_cbHeader, field_3_mm, field_4_xExt, field_5_yExt,
field_6_swHMF, field_7_grf, field_8_padding, field_9_mmPM, field_10_padding2, field_11_dxaGoal,
field_12_dyaGoal, field_13_mx, field_14_my, field_15_dxaReserved1, field_16_dyaReserved1, field_17_dxaReserved2,
field_18_dyaReserved2, field_19_fReserved, field_20_bpp, field_21_brcTop80, field_22_brcLeft80,
field_23_brcBottom80, field_24_brcRight80, field_25_dxaReserved3, field_26_dyaReserved3, field_27_cProps});
}
}

View File

@ -18,6 +18,7 @@
package org.apache.poi.hwpf.model;
import java.nio.charset.Charset;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -89,12 +90,7 @@ public final class PieceDescriptor {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + descriptor;
result = prime * result + ( ( prm == null ) ? 0 : prm.hashCode() );
result = prime * result + ( unicode ? 1231 : 1237 );
return result;
return Objects.hash(descriptor,prm,unicode);
}
/**

View File

@ -192,14 +192,8 @@ public class PlfLfo
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _lfoMac;
result = prime * result + Arrays.hashCode( _rgLfo );
result = prime * result + Arrays.hashCode( _rgLfoData );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_lfoMac, _rgLfo, _rgLfoData});
}
void writeTo( FileInformationBlock fib, ByteArrayOutputStream outputStream )

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
@ -103,12 +105,8 @@ public final class PropertyModifier implements Cloneable
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + value;
return result;
public int hashCode() {
return Objects.hash(value);
}
public boolean isComplex()

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
@ -147,7 +148,7 @@ public abstract class PropertyNode<T extends PropertyNode<T>> implements Compara
@Override
public int hashCode() {
return this._cpStart * 31 + this._buf.hashCode();
return Objects.hash(_cpStart,_buf);
}
public boolean equals(Object o) {

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.Internal;
@ -67,12 +69,8 @@ public final class SavedByEntry
*
* @return the hash code.
*/
public int hashCode()
{
int hash = 29;
hash = hash * 13 + userName.hashCode();
hash = hash * 13 + saveLocation.hashCode();
return hash;
public int hashCode() {
return Objects.hash(userName,saveLocation);
}
/**

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StdfBaseAbstractType;
import org.apache.poi.util.Internal;
@ -59,16 +61,8 @@ class StdfBase extends StdfBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_info1;
result = prime * result + field_2_info2;
result = prime * result + field_3_info3;
result = prime * result + field_4_bchUpe;
result = prime * result + field_5_grfstd;
return result;
public int hashCode() {
return Objects.hash(field_1_info1, field_2_info2, field_3_info3, field_4_bchUpe, field_5_grfstd);
}
public byte[] serialize()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StdfPost2000AbstractType;
import org.apache.poi.util.Internal;
@ -55,15 +57,8 @@ class StdfPost2000 extends StdfPost2000AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_info1;
result = prime * result
+ (int) ( field_2_rsid ^ ( field_2_rsid >>> 32 ) );
result = prime * result + field_3_info3;
return result;
public int hashCode() {
return Objects.hash(field_1_info1, field_2_rsid, field_3_info3);
}
public byte[] serialize()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StshifAbstractType;
import org.apache.poi.util.Internal;
@ -67,20 +69,9 @@ class Stshif extends StshifAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cstd;
result = prime * result + field_2_cbSTDBaseInFile;
result = prime * result + field_3_info3;
result = prime * result + field_4_stiMaxWhenSaved;
result = prime * result + field_5_istdMaxFixedWhenSaved;
result = prime * result + field_6_nVerBuiltInNamesWhenSaved;
result = prime * result + field_7_ftcAsci;
result = prime * result + field_8_ftcFE;
result = prime * result + field_9_ftcOther;
return result;
public int hashCode() {
return Objects.hash(field_1_cstd, field_2_cbSTDBaseInFile, field_3_info3, field_4_stiMaxWhenSaved,
field_5_istdMaxFixedWhenSaved, field_6_nVerBuiltInNamesWhenSaved, field_7_ftcAsci, field_8_ftcFE, field_9_ftcOther);
}
public byte[] serialize()

View File

@ -220,13 +220,7 @@ public final class StyleDescription {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((_name == null) ? 0 : _name.hashCode());
result = prime * result
+ ((_stdfBase == null) ? 0 : _stdfBase.hashCode());
result = prime * result + Arrays.hashCode(_upxs);
return result;
return Arrays.deepHashCode(new Object[]{_name,_stdfBase,_upxs});
}
@Override

View File

@ -316,7 +316,7 @@ public class TextPieceTable implements CharIndexTranslator {
@Override
public int hashCode() {
return _textPieces.size();
return _textPieces.hashCode();
}
public boolean isIndexInTable(int bytePos) {

View File

@ -118,13 +118,8 @@ public class Xst
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _cch;
result = prime * result + Arrays.hashCode( _rgtchar );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_cch,_rgtchar});
}
public void serialize( byte[] data, int startOffset )

View File

@ -423,89 +423,20 @@ public abstract class CHPAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_grpfChp;
result = prime * result + field_2_hps;
result = prime * result + field_3_ftcAscii;
result = prime * result + field_4_ftcFE;
result = prime * result + field_5_ftcOther;
result = prime * result + field_6_ftcBi;
result = prime * result + field_7_dxaSpace;
result = prime * result
+ ((field_8_cv == null) ? 0 : field_8_cv.hashCode());
result = prime * result + field_9_ico;
result = prime * result + field_10_pctCharWidth;
result = prime * result + field_11_lidDefault;
result = prime * result + field_12_lidFE;
result = prime * result + field_13_kcd;
result = prime * result + ( field_14_fUndetermine? 1231 : 1237 );
result = prime * result + field_15_iss;
result = prime * result + ( field_16_fSpecSymbol? 1231 : 1237 );
result = prime * result + field_17_idct;
result = prime * result + field_18_idctHint;
result = prime * result + field_19_kul;
result = prime * result
+ ((field_20_hresi == null) ? 0 : field_20_hresi.hashCode());
result = prime * result + field_21_hpsKern;
result = prime * result + field_22_hpsPos;
result = prime * result
+ ((field_23_shd == null) ? 0 : field_23_shd.hashCode());
result = prime * result
+ ((field_24_brc == null) ? 0 : field_24_brc.hashCode());
result = prime * result + field_25_ibstRMark;
result = prime * result + field_26_sfxtText;
result = prime * result + ( field_27_fDblBdr? 1231 : 1237 );
result = prime * result + ( field_28_fBorderWS? 1231 : 1237 );
result = prime * result + field_29_ufel;
result = prime * result + field_30_copt;
result = prime * result + field_31_hpsAsci;
result = prime * result + field_32_hpsFE;
result = prime * result + field_33_hpsBi;
result = prime * result + field_34_ftcSym;
result = prime * result + field_35_xchSym;
result = prime * result + field_36_fcPic;
result = prime * result + field_37_fcObj;
result = prime * result + field_38_lTagObj;
result = prime * result + field_39_fcData;
result = prime * result
+ ((field_40_hresiOld == null) ? 0 : field_40_hresiOld.hashCode());
result = prime * result + field_41_ibstRMarkDel;
result = prime * result
+ ((field_42_dttmRMark == null) ? 0 : field_42_dttmRMark.hashCode());
result = prime * result
+ ((field_43_dttmRMarkDel == null) ? 0 : field_43_dttmRMarkDel.hashCode());
result = prime * result + field_44_istd;
result = prime * result + field_45_idslRMReason;
result = prime * result + field_46_idslReasonDel;
result = prime * result + field_47_cpg;
result = prime * result + field_48_Highlight;
result = prime * result + field_49_CharsetFlags;
result = prime * result + field_50_chse;
result = prime * result + ( field_51_fPropRMark? 1231 : 1237 );
result = prime * result + field_52_ibstPropRMark;
result = prime * result
+ ((field_53_dttmPropRMark == null) ? 0 : field_53_dttmPropRMark.hashCode());
result = prime * result + ( field_54_fConflictOrig? 1231 : 1237 );
result = prime * result + ( field_55_fConflictOtherDel? 1231 : 1237 );
result = prime * result + field_56_wConflict;
result = prime * result + field_57_IbstConflict;
result = prime * result
+ ((field_58_dttmConflict == null) ? 0 : field_58_dttmConflict.hashCode());
result = prime * result + ( field_59_fDispFldRMark? 1231 : 1237 );
result = prime * result + field_60_ibstDispFldRMark;
result = prime * result
+ ((field_61_dttmDispFldRMark == null) ? 0 : field_61_dttmDispFldRMark.hashCode());
result = prime * result + Arrays.hashCode( field_62_xstDispFldRMark );
result = prime * result + field_63_fcObjp;
result = prime * result + field_64_lbrCRJ;
result = prime * result + ( field_65_fSpecVanish? 1231 : 1237 );
result = prime * result + ( field_66_fHasOldProps? 1231 : 1237 );
result = prime * result + ( field_67_fSdtVanish? 1231 : 1237 );
result = prime * result + field_68_wCharScale;
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_grpfChp, field_2_hps, field_3_ftcAscii, field_4_ftcFE, field_5_ftcOther,
field_6_ftcBi, field_7_dxaSpace, field_8_cv, field_9_ico, field_10_pctCharWidth, field_11_lidDefault,
field_12_lidFE, field_13_kcd, field_14_fUndetermine, field_15_iss, field_16_fSpecSymbol, field_17_idct,
field_18_idctHint, field_19_kul, field_20_hresi, field_21_hpsKern, field_22_hpsPos, field_23_shd,
field_24_brc, field_25_ibstRMark, field_26_sfxtText, field_27_fDblBdr, field_28_fBorderWS, field_29_ufel,
field_30_copt, field_31_hpsAsci, field_32_hpsFE, field_33_hpsBi, field_34_ftcSym, field_35_xchSym,
field_36_fcPic, field_37_fcObj, field_38_lTagObj, field_39_fcData, field_40_hresiOld, field_41_ibstRMarkDel,
field_42_dttmRMark, field_43_dttmRMarkDel, field_44_istd, field_45_idslRMReason, field_46_idslReasonDel,
field_47_cpg, field_48_Highlight, field_49_CharsetFlags, field_50_chse, field_51_fPropRMark,
field_52_ibstPropRMark, field_53_dttmPropRMark, field_54_fConflictOrig, field_55_fConflictOtherDel,
field_56_wConflict, field_57_IbstConflict, field_58_dttmConflict, field_59_fDispFldRMark,
field_60_ibstDispFldRMark, field_61_dttmDispFldRMark, field_62_xstDispFldRMark, field_63_fcObjp,
field_64_lbrCRJ, field_65_fSpecVanish, field_66_fHasOldProps, field_67_fSdtVanish, field_68_wCharScale});
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -134,16 +136,8 @@ public abstract class FFDataBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result
+ (int) ( field_1_version ^ ( field_1_version >>> 32 ) );
result = prime * result + field_2_bits;
result = prime * result + field_3_cch;
result = prime * result + field_4_hps;
return result;
public int hashCode() {
return Objects.hash(field_1_version, field_2_bits, field_3_cch, field_4_hps);
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -155,25 +157,10 @@ public abstract class FibRgLw95AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cbMac;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_reserved3;
result = prime * result + field_5_reserved4;
result = prime * result + field_6_ccpText;
result = prime * result + field_7_ccpFtn;
result = prime * result + field_8_ccpHdd;
result = prime * result + field_9_ccpMcr;
result = prime * result + field_10_ccpAtn;
result = prime * result + field_11_ccpEdn;
result = prime * result + field_12_ccpTxbx;
result = prime * result + field_13_ccpHdrTxbx;
result = prime * result + field_14_reserved5;
return result;
public int hashCode() {
return Objects.hash(field_1_cbMac, field_2_reserved1, field_3_reserved2, field_4_reserved3, field_5_reserved4,
field_6_ccpText, field_7_ccpFtn, field_8_ccpHdd, field_9_ccpMcr, field_10_ccpAtn, field_11_ccpEdn,
field_12_ccpTxbx, field_13_ccpHdrTxbx, field_14_reserved5);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -205,33 +207,12 @@ public abstract class FibRgLw97AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cbMac;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_ccpText;
result = prime * result + field_5_ccpFtn;
result = prime * result + field_6_ccpHdd;
result = prime * result + field_7_reserved3;
result = prime * result + field_8_ccpAtn;
result = prime * result + field_9_ccpEdn;
result = prime * result + field_10_ccpTxbx;
result = prime * result + field_11_ccpHdrTxbx;
result = prime * result + field_12_reserved4;
result = prime * result + field_13_reserved5;
result = prime * result + field_14_reserved6;
result = prime * result + field_15_reserved7;
result = prime * result + field_16_reserved8;
result = prime * result + field_17_reserved9;
result = prime * result + field_18_reserved10;
result = prime * result + field_19_reserved11;
result = prime * result + field_20_reserved12;
result = prime * result + field_21_reserved13;
result = prime * result + field_22_reserved14;
return result;
public int hashCode() {
return Objects.hash(field_1_cbMac, field_2_reserved1, field_3_reserved2, field_4_ccpText, field_5_ccpFtn,
field_6_ccpHdd, field_7_reserved3, field_8_ccpAtn, field_9_ccpEdn, field_10_ccpTxbx, field_11_ccpHdrTxbx,
field_12_reserved4, field_13_reserved5, field_14_reserved6, field_15_reserved7, field_16_reserved8,
field_17_reserved9, field_18_reserved10, field_19_reserved11, field_20_reserved12, field_21_reserved13,
field_22_reserved14);
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
@ -98,12 +100,8 @@ public abstract class GrfhicAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_grfhic;
return result;
public int hashCode() {
return Objects.hash(field_1_grfhic);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.hwpf.model.Grfhic;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -122,19 +124,9 @@ public abstract class LFOAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_unused1;
result = prime * result + field_3_unused2;
result = prime * result + field_4_clfolvl;
result = prime * result + field_5_ibstFltAutoNum;
result = prime * result
+ ((field_6_grfhic == null) ? 0 : field_6_grfhic.hashCode());
result = prime * result + field_7_unused3;
return result;
public int hashCode() {
return Objects.hash(field_1_lsid, field_2_unused1, field_3_unused2, field_4_clfolvl, field_5_ibstFltAutoNum,
field_6_grfhic, field_7_unused3);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -99,13 +101,8 @@ public abstract class LFOLVLBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_iStartAt;
result = prime * result + field_2_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_iStartAt,field_2_flags);
}
public String toString()

View File

@ -123,16 +123,8 @@ public abstract class LSTFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_tplc;
result = prime * result + Arrays.hashCode( field_3_rgistdPara );
result = prime * result + field_4_flags;
result = prime * result + field_5_grfhic.hashCode();
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_lsid, field_2_tplc, field_3_rgistdPara, field_4_flags, field_5_grfhic});
}
public String toString()

View File

@ -155,22 +155,10 @@ public abstract class LVLFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_iStartAt;
result = prime * result + field_2_nfc;
result = prime * result + field_3_info;
result = prime * result + Arrays.hashCode( field_4_rgbxchNums );
result = prime * result + field_5_ixchFollow;
result = prime * result + field_6_dxaIndentSav;
result = prime * result + field_7_unused2;
result = prime * result + field_8_cbGrpprlChpx;
result = prime * result + field_9_cbGrpprlPapx;
result = prime * result + field_10_ilvlRestartLim;
result = prime * result + field_11_grfhic.hashCode();
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_iStartAt, field_2_nfc, field_3_info, field_4_rgbxchNums,
field_5_ixchFollow, field_6_dxaIndentSav, field_7_unused2, field_8_cbGrpprlChpx, field_9_cbGrpprlPapx,
field_10_ilvlRestartLim, field_11_grfhic});
}
public String toString()

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -91,12 +93,8 @@ public abstract class SHD80AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_value;
return result;
public int hashCode() {
return Objects.hash(field_1_value);
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.hwpf.model.Colorref;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -100,14 +102,8 @@ public abstract class SHDAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cvFore.hashCode();
result = prime * result + field_2_cvBack.hashCode();
result = prime * result + field_3_ipat;
return result;
public int hashCode() {
return Objects.hash(field_1_cvFore,field_2_cvBack,field_3_ipat);
}
public String toString()

View File

@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.poi.hwpf.model.BookmarksTables;
import org.apache.poi.hwpf.model.GenericPropertyNode;
@ -100,9 +101,8 @@ public class BookmarksImpl implements Bookmarks
}
@Override
public int hashCode()
{
return 31 + ( first == null ? 0 : first.hashCode() );
public int hashCode() {
return Objects.hash(first);
}
public void setName( String name )

View File

@ -81,8 +81,7 @@ public final class DropCapSpecifier implements Cloneable
}
@Override
public int hashCode()
{
public int hashCode() {
return _fdct;
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.usermodel;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.TLPAbstractType;
public class TableAutoformatLookSpecifier extends TLPAbstractType implements
@ -65,13 +67,8 @@ public class TableAutoformatLookSpecifier extends TLPAbstractType implements
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_itl;
result = prime * result + field_2_tlp_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_itl,field_2_tlp_flags);
}
public boolean isEmpty()