diff --git a/CodenameOne/src/com/codename1/io/services/ImageDownloadService.java b/CodenameOne/src/com/codename1/io/services/ImageDownloadService.java index 943700c5c1..c528c81e13 100644 --- a/CodenameOne/src/com/codename1/io/services/ImageDownloadService.java +++ b/CodenameOne/src/com/codename1/io/services/ImageDownloadService.java @@ -934,6 +934,13 @@ public boolean equals(Object o) { ((ImageDownloadService) o).cacheId.equals(cacheId); } + /** + * {@inheritDoc} + */ + public int hashCode() { + return cacheId != null ? cacheId.hashCode() : 0; + } + /** * @return the maintainAspectRatio */ diff --git a/CodenameOne/src/com/codename1/io/tar/TarEntry.java b/CodenameOne/src/com/codename1/io/tar/TarEntry.java index 85e3adc174..573e7902c5 100644 --- a/CodenameOne/src/com/codename1/io/tar/TarEntry.java +++ b/CodenameOne/src/com/codename1/io/tar/TarEntry.java @@ -1,296 +1,309 @@ -/** - * Copyright 2012 Kamran Zafar - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * The original source has been modified by Paul Williams. - */ - -package com.codename1.io.tar; - -import com.codename1.io.FileSystemStorage; - -import java.util.Date; - -/** - * @author Kamran Zafar - * - */ -public class TarEntry { - protected String file; - protected TarHeader header; - - private TarEntry() { - this.file = null; - this.header = new TarHeader(); - } - - public TarEntry(String file, String entryName) { - this(); - this.file = file; - this.extractTarHeader(entryName); - } - - public TarEntry(byte[] headerBuf) { - this(); - this.parseTarHeader(headerBuf); - } - - public boolean equals(TarEntry it) { - return this.header.name.toString().equals( it.header.name.toString() ); - } - - public boolean isDescendent(TarEntry desc) { - return desc.header.name.toString().startsWith(this.header.name.toString()); - } - - public TarHeader getHeader() { - return this.header; - } - - public String getName() { - return this.header.name.toString(); - } - - public void setName(String name) { - this.header.name = new StringBuffer(name); - } - - public int getUserId() { - return this.header.userId; - } - - public void setUserId(int userId) { - this.header.userId = userId; - } - - public int getGroupId() { - return this.header.groupId; - } - - public void setGroupId(int groupId) { - this.header.groupId = groupId; - } - - public String getUserName() { - return this.header.userName.toString(); - } - - public void setUserName(String userName) { - this.header.userName = new StringBuffer(userName); - } - - public String getGroupName() { - return this.header.groupName.toString(); - } - - public void setGroupName(String groupName) { - this.header.groupName = new StringBuffer(groupName); - } - - public void setIds(int userId, int groupId) { - this.setUserId(userId); - this.setGroupId(groupId); - } - - public Date getModTime() { - return new Date(this.header.modTime * 1000); - } - - public void setModTime(long time) { - this.header.modTime = time / 1000; - } - - public void setModTime(Date time) { - this.header.modTime = time.getTime() / 1000; - } - - public String getFile() { - return this.file; - } - - public long getSize() { - return this.header.size; - } - - public void setSize(long size) { - this.header.size = size; - } - - /** - * Checks if the org.xeustechnologies.jtar entry is a directory - * - * @return - */ - public boolean isDirectory() { - if (this.file != null) - return FileSystemStorage.getInstance().isDirectory(this.file); - - if (this.header != null) { - if (this.header.linkFlag == TarHeader.LF_DIR) - return true; - - return this.header.name.toString().endsWith("/"); - } - - return false; - } - - /** - * Extract header from File - * - * @param entryName - */ - public void extractTarHeader(String entryName) { - String name = entryName; - - FileSystemStorage fileSystem = FileSystemStorage.getInstance(); - - name = name.replace(fileSystem.getFileSystemSeparator(), '/'); - - if (name.startsWith("/")) - name = name.substring(1); - - header.linkName = new StringBuffer(); - - header.name = new StringBuffer(name); - - if (fileSystem.isDirectory(file)) { - header.mode = 040755; - header.linkFlag = TarHeader.LF_DIR; - if (header.name.charAt(header.name.length() - 1) != '/') { - header.name.append("/"); - } - header.size = 0; - } else { - header.size = fileSystem.getLength(file); - header.mode = 0100644; - header.linkFlag = TarHeader.LF_NORMAL; - } - - //header.modTime = file.lastModified() / 1000; - header.modTime = 0; - header.checkSum = 0; - header.devMajor = 0; - header.devMinor = 0; - } - - /** - * Calculate checksum - * - * @param buf - * @return - */ - public long computeCheckSum(byte[] buf) { - long sum = 0; - int blen = buf.length; - for (int i = 0; i < blen; ++i) { - sum += 255 & buf[i]; - } - - return sum; - } - - /** - * Writes the header to the byte buffer - * - * @param outbuf - */ - public void writeEntryHeader(byte[] outbuf) { - int offset = 0; - - offset = TarHeader.getNameBytes(this.header.name, outbuf, offset, TarHeader.NAMELEN); - offset = Octal.getOctalBytes(this.header.mode, outbuf, offset, TarHeader.MODELEN); - offset = Octal.getOctalBytes(this.header.userId, outbuf, offset, TarHeader.UIDLEN); - offset = Octal.getOctalBytes(this.header.groupId, outbuf, offset, TarHeader.GIDLEN); - - long size = this.header.size; - - offset = Octal.getLongOctalBytes(size, outbuf, offset, TarHeader.SIZELEN); - offset = Octal.getLongOctalBytes(this.header.modTime, outbuf, offset, TarHeader.MODTIMELEN); - - int csOffset = offset; - for (int c = 0; c < TarHeader.CHKSUMLEN; ++c) - outbuf[offset++] = (byte) ' '; - - outbuf[offset++] = this.header.linkFlag; - - offset = TarHeader.getNameBytes(this.header.linkName, outbuf, offset, TarHeader.NAMELEN); - offset = TarHeader.getNameBytes(this.header.magic, outbuf, offset, TarHeader.MAGICLEN); - offset = TarHeader.getNameBytes(this.header.userName, outbuf, offset, TarHeader.UNAMELEN); - offset = TarHeader.getNameBytes(this.header.groupName, outbuf, offset, TarHeader.GNAMELEN); - offset = Octal.getOctalBytes(this.header.devMajor, outbuf, offset, TarHeader.DEVLEN); - offset = Octal.getOctalBytes(this.header.devMinor, outbuf, offset, TarHeader.DEVLEN); - - int oblen = outbuf.length; - while (offset < oblen) { - outbuf[offset++] = 0; - } - - long checkSum = this.computeCheckSum(outbuf); - - Octal.getCheckSumOctalBytes(checkSum, outbuf, csOffset, TarHeader.CHKSUMLEN); - } - - /** - * Parses the tar header to the byte buffer - * - * @param header - * @param bh - */ - public void parseTarHeader(byte[] bh) { - int offset = 0; - - header.name = TarHeader.parseName(bh, offset, TarHeader.NAMELEN); - offset += TarHeader.NAMELEN; - - header.mode = (int) Octal.parseOctal(bh, offset, TarHeader.MODELEN); - offset += TarHeader.MODELEN; - - header.userId = (int) Octal.parseOctal(bh, offset, TarHeader.UIDLEN); - offset += TarHeader.UIDLEN; - - header.groupId = (int) Octal.parseOctal(bh, offset, TarHeader.GIDLEN); - offset += TarHeader.GIDLEN; - - header.size = Octal.parseOctal(bh, offset, TarHeader.SIZELEN); - offset += TarHeader.SIZELEN; - - header.modTime = Octal.parseOctal(bh, offset, TarHeader.MODTIMELEN); - offset += TarHeader.MODTIMELEN; - - header.checkSum = (int) Octal.parseOctal(bh, offset, TarHeader.CHKSUMLEN); - offset += TarHeader.CHKSUMLEN; - - header.linkFlag = bh[offset++]; - - header.linkName = TarHeader.parseName(bh, offset, TarHeader.NAMELEN); - offset += TarHeader.NAMELEN; - - header.magic = TarHeader.parseName(bh, offset, TarHeader.MAGICLEN); - offset += TarHeader.MAGICLEN; - - header.userName = TarHeader.parseName(bh, offset, TarHeader.UNAMELEN); - offset += TarHeader.UNAMELEN; - - header.groupName = TarHeader.parseName(bh, offset, TarHeader.GNAMELEN); - offset += TarHeader.GNAMELEN; - - header.devMajor = (int) Octal.parseOctal(bh, offset, TarHeader.DEVLEN); - offset += TarHeader.DEVLEN; - - header.devMinor = (int) Octal.parseOctal(bh, offset, TarHeader.DEVLEN); - } +/** + * Copyright 2012 Kamran Zafar + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The original source has been modified by Paul Williams. + */ + +package com.codename1.io.tar; + +import com.codename1.io.FileSystemStorage; + +import java.util.Date; + +/** + * @author Kamran Zafar + * + */ +public class TarEntry { + protected String file; + protected TarHeader header; + + private TarEntry() { + this.file = null; + this.header = new TarHeader(); + } + + public TarEntry(String file, String entryName) { + this(); + this.file = file; + this.extractTarHeader(entryName); + } + + public TarEntry(byte[] headerBuf) { + this(); + this.parseTarHeader(headerBuf); + } + + public boolean equals(TarEntry it) { + return this.header.name.toString().equals( it.header.name.toString() ); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof TarEntry) { + return equals((TarEntry) obj); + } + return false; + } + + @Override + public int hashCode() { + return this.header.name.toString().hashCode(); + } + + public boolean isDescendent(TarEntry desc) { + return desc.header.name.toString().startsWith(this.header.name.toString()); + } + + public TarHeader getHeader() { + return this.header; + } + + public String getName() { + return this.header.name.toString(); + } + + public void setName(String name) { + this.header.name = new StringBuffer(name); + } + + public int getUserId() { + return this.header.userId; + } + + public void setUserId(int userId) { + this.header.userId = userId; + } + + public int getGroupId() { + return this.header.groupId; + } + + public void setGroupId(int groupId) { + this.header.groupId = groupId; + } + + public String getUserName() { + return this.header.userName.toString(); + } + + public void setUserName(String userName) { + this.header.userName = new StringBuffer(userName); + } + + public String getGroupName() { + return this.header.groupName.toString(); + } + + public void setGroupName(String groupName) { + this.header.groupName = new StringBuffer(groupName); + } + + public void setIds(int userId, int groupId) { + this.setUserId(userId); + this.setGroupId(groupId); + } + + public Date getModTime() { + return new Date(this.header.modTime * 1000); + } + + public void setModTime(long time) { + this.header.modTime = time / 1000; + } + + public void setModTime(Date time) { + this.header.modTime = time.getTime() / 1000; + } + + public String getFile() { + return this.file; + } + + public long getSize() { + return this.header.size; + } + + public void setSize(long size) { + this.header.size = size; + } + + /** + * Checks if the org.xeustechnologies.jtar entry is a directory + * + * @return + */ + public boolean isDirectory() { + if (this.file != null) + return FileSystemStorage.getInstance().isDirectory(this.file); + + if (this.header != null) { + if (this.header.linkFlag == TarHeader.LF_DIR) + return true; + + return this.header.name.toString().endsWith("/"); + } + + return false; + } + + /** + * Extract header from File + * + * @param entryName + */ + public void extractTarHeader(String entryName) { + String name = entryName; + + FileSystemStorage fileSystem = FileSystemStorage.getInstance(); + + name = name.replace(fileSystem.getFileSystemSeparator(), '/'); + + if (name.startsWith("/")) + name = name.substring(1); + + header.linkName = new StringBuffer(); + + header.name = new StringBuffer(name); + + if (fileSystem.isDirectory(file)) { + header.mode = 040755; + header.linkFlag = TarHeader.LF_DIR; + if (header.name.charAt(header.name.length() - 1) != '/') { + header.name.append("/"); + } + header.size = 0; + } else { + header.size = fileSystem.getLength(file); + header.mode = 0100644; + header.linkFlag = TarHeader.LF_NORMAL; + } + + //header.modTime = file.lastModified() / 1000; + header.modTime = 0; + header.checkSum = 0; + header.devMajor = 0; + header.devMinor = 0; + } + + /** + * Calculate checksum + * + * @param buf + * @return + */ + public long computeCheckSum(byte[] buf) { + long sum = 0; + int blen = buf.length; + for (int i = 0; i < blen; ++i) { + sum += 255 & buf[i]; + } + + return sum; + } + + /** + * Writes the header to the byte buffer + * + * @param outbuf + */ + public void writeEntryHeader(byte[] outbuf) { + int offset = 0; + + offset = TarHeader.getNameBytes(this.header.name, outbuf, offset, TarHeader.NAMELEN); + offset = Octal.getOctalBytes(this.header.mode, outbuf, offset, TarHeader.MODELEN); + offset = Octal.getOctalBytes(this.header.userId, outbuf, offset, TarHeader.UIDLEN); + offset = Octal.getOctalBytes(this.header.groupId, outbuf, offset, TarHeader.GIDLEN); + + long size = this.header.size; + + offset = Octal.getLongOctalBytes(size, outbuf, offset, TarHeader.SIZELEN); + offset = Octal.getLongOctalBytes(this.header.modTime, outbuf, offset, TarHeader.MODTIMELEN); + + int csOffset = offset; + for (int c = 0; c < TarHeader.CHKSUMLEN; ++c) + outbuf[offset++] = (byte) ' '; + + outbuf[offset++] = this.header.linkFlag; + + offset = TarHeader.getNameBytes(this.header.linkName, outbuf, offset, TarHeader.NAMELEN); + offset = TarHeader.getNameBytes(this.header.magic, outbuf, offset, TarHeader.MAGICLEN); + offset = TarHeader.getNameBytes(this.header.userName, outbuf, offset, TarHeader.UNAMELEN); + offset = TarHeader.getNameBytes(this.header.groupName, outbuf, offset, TarHeader.GNAMELEN); + offset = Octal.getOctalBytes(this.header.devMajor, outbuf, offset, TarHeader.DEVLEN); + offset = Octal.getOctalBytes(this.header.devMinor, outbuf, offset, TarHeader.DEVLEN); + + int oblen = outbuf.length; + while (offset < oblen) { + outbuf[offset++] = 0; + } + + long checkSum = this.computeCheckSum(outbuf); + + Octal.getCheckSumOctalBytes(checkSum, outbuf, csOffset, TarHeader.CHKSUMLEN); + } + + /** + * Parses the tar header to the byte buffer + * + * @param header + * @param bh + */ + public void parseTarHeader(byte[] bh) { + int offset = 0; + + header.name = TarHeader.parseName(bh, offset, TarHeader.NAMELEN); + offset += TarHeader.NAMELEN; + + header.mode = (int) Octal.parseOctal(bh, offset, TarHeader.MODELEN); + offset += TarHeader.MODELEN; + + header.userId = (int) Octal.parseOctal(bh, offset, TarHeader.UIDLEN); + offset += TarHeader.UIDLEN; + + header.groupId = (int) Octal.parseOctal(bh, offset, TarHeader.GIDLEN); + offset += TarHeader.GIDLEN; + + header.size = Octal.parseOctal(bh, offset, TarHeader.SIZELEN); + offset += TarHeader.SIZELEN; + + header.modTime = Octal.parseOctal(bh, offset, TarHeader.MODTIMELEN); + offset += TarHeader.MODTIMELEN; + + header.checkSum = (int) Octal.parseOctal(bh, offset, TarHeader.CHKSUMLEN); + offset += TarHeader.CHKSUMLEN; + + header.linkFlag = bh[offset++]; + + header.linkName = TarHeader.parseName(bh, offset, TarHeader.NAMELEN); + offset += TarHeader.NAMELEN; + + header.magic = TarHeader.parseName(bh, offset, TarHeader.MAGICLEN); + offset += TarHeader.MAGICLEN; + + header.userName = TarHeader.parseName(bh, offset, TarHeader.UNAMELEN); + offset += TarHeader.UNAMELEN; + + header.groupName = TarHeader.parseName(bh, offset, TarHeader.GNAMELEN); + offset += TarHeader.GNAMELEN; + + header.devMajor = (int) Octal.parseOctal(bh, offset, TarHeader.DEVLEN); + offset += TarHeader.DEVLEN; + + header.devMinor = (int) Octal.parseOctal(bh, offset, TarHeader.DEVLEN); + } } \ No newline at end of file diff --git a/CodenameOne/src/com/codename1/location/Geofence.java b/CodenameOne/src/com/codename1/location/Geofence.java index 278eb7df49..1107c2ec2c 100644 --- a/CodenameOne/src/com/codename1/location/Geofence.java +++ b/CodenameOne/src/com/codename1/location/Geofence.java @@ -194,4 +194,19 @@ private boolean eq(Location l1, Location l2) { return true; // both null } } + + @Override + public int hashCode() { + int hash = 7; + hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0); + if (this.loc != null) { + long temp = Double.doubleToLongBits(this.loc.getLatitude()); + hash = 53 * hash + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.loc.getLongitude()); + hash = 53 * hash + (int) (temp ^ (temp >>> 32)); + } + hash = 53 * hash + this.radius; + hash = 53 * hash + (int) (this.expiration ^ (this.expiration >>> 32)); + return hash; + } } diff --git a/CodenameOne/src/com/codename1/properties/PropertyBase.java b/CodenameOne/src/com/codename1/properties/PropertyBase.java index aff0b2693a..8934bf7cf9 100644 --- a/CodenameOne/src/com/codename1/properties/PropertyBase.java +++ b/CodenameOne/src/com/codename1/properties/PropertyBase.java @@ -209,6 +209,11 @@ public boolean equals(Object obj) { return false; } + @Override + public int hashCode() { + return name.hashCode(); + } + T get() { return null; } diff --git a/CodenameOne/src/com/codename1/ui/CustomFont.java b/CodenameOne/src/com/codename1/ui/CustomFont.java index 0a31829209..9cab718a37 100644 --- a/CodenameOne/src/com/codename1/ui/CustomFont.java +++ b/CodenameOne/src/com/codename1/ui/CustomFont.java @@ -378,4 +378,16 @@ public boolean equals(Object o) { } return false; } + + @Override + public int hashCode() { + int hash = 7; + hash = 97 * hash + (this.charsets != null ? this.charsets.hashCode() : 0); + if (cutOffsets != null) { + for (int i : cutOffsets) { + hash = 97 * hash + i; + } + } + return hash; + } } diff --git a/CodenameOne/src/com/codename1/ui/Font.java b/CodenameOne/src/com/codename1/ui/Font.java index a863adff5f..f0a6099c31 100644 --- a/CodenameOne/src/com/codename1/ui/Font.java +++ b/CodenameOne/src/com/codename1/ui/Font.java @@ -617,6 +617,16 @@ public boolean equals(Object o) { return f.getFace() == getFace() && f.getSize() == getSize() && f.getStyle() == getStyle(); } + /** + * {@inheritDoc} + */ + public int hashCode() { + if (ttf && font != null) { + return font.hashCode(); + } + return getFace() ^ getSize() ^ getStyle(); + } + /** * The ascent is the amount by which the character ascends above the baseline. * diff --git a/CodenameOne/src/com/codename1/ui/Transform.java b/CodenameOne/src/com/codename1/ui/Transform.java index b5b6c320cf..9d8164f9a4 100644 --- a/CodenameOne/src/com/codename1/ui/Transform.java +++ b/CodenameOne/src/com/codename1/ui/Transform.java @@ -895,6 +895,31 @@ public boolean equals(Transform t2) { return out; } + @Override + public boolean equals(Object o) { + if (o instanceof Transform) { + return equals((Transform) o); + } + return false; + } + + @Override + public int hashCode() { + if (type == TYPE_IDENTITY) { + return 0; + } + int hash = 7; + hash = 29 * hash + this.type; + hash = 29 * hash + (this.nativeTransform != null ? this.nativeTransform.hashCode() : 0); + hash = 29 * hash + Float.floatToIntBits(this.translateX); + hash = 29 * hash + Float.floatToIntBits(this.translateY); + hash = 29 * hash + Float.floatToIntBits(this.translateZ); + hash = 29 * hash + Float.floatToIntBits(this.scaleX); + hash = 29 * hash + Float.floatToIntBits(this.scaleY); + hash = 29 * hash + Float.floatToIntBits(this.scaleZ); + return hash; + } + public static class NotInvertibleException extends Exception { } diff --git a/CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java b/CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java index c270ce5ff0..d47983354d 100644 --- a/CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java +++ b/CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java @@ -845,6 +845,11 @@ public boolean equals(Object o) { return false; } + @Override + public int hashCode() { + return centerBehavior + (landscapeSwap == null ? 0 : landscapeSwap.hashCode()); + } + /** * Indicates that the center shouldn't grow and should be placed exactly in the center of the layout * diff --git a/CodenameOne/src/com/codename1/ui/layouts/BoxLayout.java b/CodenameOne/src/com/codename1/ui/layouts/BoxLayout.java index 79cf3b9162..a839e7e46f 100644 --- a/CodenameOne/src/com/codename1/ui/layouts/BoxLayout.java +++ b/CodenameOne/src/com/codename1/ui/layouts/BoxLayout.java @@ -522,4 +522,9 @@ public String toString() { public boolean equals(Object o) { return super.equals(o) && axis == ((BoxLayout) o).axis; } + + @Override + public int hashCode() { + return super.hashCode() ^ axis; + } } diff --git a/CodenameOne/src/com/codename1/ui/layouts/FlowLayout.java b/CodenameOne/src/com/codename1/ui/layouts/FlowLayout.java index 097d24b028..47e83c46a7 100644 --- a/CodenameOne/src/com/codename1/ui/layouts/FlowLayout.java +++ b/CodenameOne/src/com/codename1/ui/layouts/FlowLayout.java @@ -634,4 +634,9 @@ public boolean equals(Object o) { ((FlowLayout) o).valign == valign && ((FlowLayout) o).fillRows == fillRows; } + + @Override + public int hashCode() { + return super.hashCode() ^ orientation ^ valign ^ (fillRows ? 1231 : 1237); + } } \ No newline at end of file diff --git a/CodenameOne/src/com/codename1/ui/layouts/GridLayout.java b/CodenameOne/src/com/codename1/ui/layouts/GridLayout.java index d32b9a48ac..7d5a96892e 100644 --- a/CodenameOne/src/com/codename1/ui/layouts/GridLayout.java +++ b/CodenameOne/src/com/codename1/ui/layouts/GridLayout.java @@ -356,6 +356,11 @@ public boolean equals(Object o) { ((GridLayout) o).getColumns() == getColumns() && ((GridLayout) o).autoFit == autoFit; } + @Override + public int hashCode() { + return super.hashCode() ^ getRows() ^ getColumns() ^ (autoFit ? 1231 : 1237); + } + /** * When set to true makes the grid layout fill the last row of the layout * entirely if the number of elements in that row is bigger. diff --git a/CodenameOne/src/com/codename1/ui/plaf/Border.java b/CodenameOne/src/com/codename1/ui/plaf/Border.java index 438fb5a402..cc95167e36 100644 --- a/CodenameOne/src/com/codename1/ui/plaf/Border.java +++ b/CodenameOne/src/com/codename1/ui/plaf/Border.java @@ -1126,6 +1126,24 @@ public boolean equals(Object obj) { return false; } + /** + * {@inheritDoc} + */ + public int hashCode() { + int hash = 7; + hash = 31 * hash + type; + hash = 31 * hash + (themeColors ? 1 : 0); + hash = 31 * hash + colorA; + hash = 31 * hash + colorB; + hash = 31 * hash + colorC; + hash = 31 * hash + colorD; + hash = 31 * hash + Float.floatToIntBits(thickness); + hash = 31 * hash + arcWidth; + hash = 31 * hash + arcHeight; + hash = 31 * hash + (outline ? 1 : 0); + return hash; + } + /** * Returns true if installing this border will override the painting of the component background * diff --git a/CodenameOne/src/com/codename1/ui/plaf/CSSBorder.java b/CodenameOne/src/com/codename1/ui/plaf/CSSBorder.java index 8500efd73b..fbbc6d20b2 100644 --- a/CodenameOne/src/com/codename1/ui/plaf/CSSBorder.java +++ b/CodenameOne/src/com/codename1/ui/plaf/CSSBorder.java @@ -369,6 +369,11 @@ public boolean equals(Object obj) { return obj == this; } + @Override + public int hashCode() { + return System.identityHashCode(this); + } + /** * Converts this border to a CSS string. * @@ -1343,6 +1348,12 @@ public boolean equals(Object obj) { return false; } + @Override + public int hashCode() { + if (value == 0) return 0; + return Float.floatToIntBits(value) ^ type; + } + boolean isZero() { return value == 0; } @@ -1526,6 +1537,11 @@ public boolean equals(Object obj) { return false; } + @Override + public int hashCode() { + return color ^ alpha; + } + boolean isTransparent() { return alpha == 0; } @@ -1657,6 +1673,11 @@ public boolean equals(Object obj) { return false; } + @Override + public int hashCode() { + return type ^ thickness.hashCode() ^ color.hashCode(); + } + boolean isVisible() { return color != null && !isTransparent(color) && type != STYLE_NONE && type != STYLE_HIDDEN; } diff --git a/CodenameOne/src/com/codename1/ui/plaf/RoundBorder.java b/CodenameOne/src/com/codename1/ui/plaf/RoundBorder.java index bc18ff0dcc..9fcb011355 100644 --- a/CodenameOne/src/com/codename1/ui/plaf/RoundBorder.java +++ b/CodenameOne/src/com/codename1/ui/plaf/RoundBorder.java @@ -717,6 +717,11 @@ public boolean equals(Object obj) { return obj == this; } + @Override + public int hashCode() { + return System.identityHashCode(this); + } + static class CacheValue { Image img; long modificationTime; diff --git a/CodenameOne/src/com/codename1/ui/plaf/RoundRectBorder.java b/CodenameOne/src/com/codename1/ui/plaf/RoundRectBorder.java index 2f745e6d82..7f756944d5 100644 --- a/CodenameOne/src/com/codename1/ui/plaf/RoundRectBorder.java +++ b/CodenameOne/src/com/codename1/ui/plaf/RoundRectBorder.java @@ -1142,6 +1142,11 @@ public boolean equals(Object obj) { return obj == this; } + @Override + public int hashCode() { + return System.identityHashCode(this); + } + /** * Returns true if this border corner is round and false if it's square diff --git a/CodenameOne/src/com/codename1/ui/plaf/Style.java b/CodenameOne/src/com/codename1/ui/plaf/Style.java index b73ff3d39a..004d5ac28c 100644 --- a/CodenameOne/src/com/codename1/ui/plaf/Style.java +++ b/CodenameOne/src/com/codename1/ui/plaf/Style.java @@ -3156,4 +3156,9 @@ public boolean equals(Object obj) { return this.surface == other.surface; } + @Override + public int hashCode() { + return System.identityHashCode(this); + } + } diff --git a/CodenameOne/src/com/codename1/ui/table/TableLayout.java b/CodenameOne/src/com/codename1/ui/table/TableLayout.java index eec19d357e..3593b41194 100644 --- a/CodenameOne/src/com/codename1/ui/table/TableLayout.java +++ b/CodenameOne/src/com/codename1/ui/table/TableLayout.java @@ -965,6 +965,11 @@ public boolean equals(Object o) { return super.equals(o) && ((TableLayout) o).getRows() == getRows() && ((TableLayout) o).getColumns() == getColumns(); } + @Override + public int hashCode() { + return super.hashCode() ^ getRows() ^ getColumns(); + } + /** * {@inheritDoc} */