Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mathieu Féry
mobile21
Commits
b3dc47f1
Commit
b3dc47f1
authored
Dec 11, 2020
by
Mathieu Féry (Mathius)
Browse files
Rework HashCode
parent
abfdfa02
Pipeline
#23351
failed with stages
in 2 minutes and 30 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/build.gradle
View file @
b3dc47f1
...
...
@@ -55,6 +55,7 @@ dependencies {
implementation
'com.koushikdutta.ion:ion:3.1.0'
implementation
'com.google.android.gms:play-services-base:17.5.0'
implementation
'com.github.bumptech.glide:glide:4.11.0'
implementation
'org.apache.commons:commons-lang3:3.1'
testImplementation
'junit:junit:4.+'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/DnDAttr.java
View file @
b3dc47f1
...
...
@@ -3,6 +3,8 @@ package fr.iutnantes.miar.dndgenerator.api.dnd;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
/**
...
...
@@ -51,7 +53,8 @@ public class DnDAttr implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
nameAttr
.
hashCode
()
*
value
.
hashCode
();
return
new
HashCodeBuilder
(
1
,
3
)
.
append
(
nameAttr
.
hashCode
()).
append
(
value
.
hashCode
()).
toHashCode
();
}
/**
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/DnDSaves.java
View file @
b3dc47f1
...
...
@@ -3,6 +3,8 @@ package fr.iutnantes.miar.dndgenerator.api.dnd;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
/**
...
...
@@ -54,11 +56,12 @@ public class DnDSaves implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
(
wands
!=
null
?
wands
.
hashCode
()
:
1
)
*
(
breath
!=
null
?
breath
.
hashCode
()
:
1
)
*
(
stone
!=
null
?
stone
.
hashCode
()
:
1
)
*
(
magic
!=
null
?
magic
.
hashCode
()
:
1
)
*
(
poison
!=
null
?
poison
.
hashCode
()
:
1
);
return
new
HashCodeBuilder
(
5
,
7
)
.
append
(
wands
!=
null
?
wands
.
hashCode
()
:
1
)
.
append
(
breath
!=
null
?
breath
.
hashCode
()
:
1
)
.
append
(
stone
!=
null
?
stone
.
hashCode
()
:
1
)
.
append
(
magic
!=
null
?
magic
.
hashCode
()
:
1
)
.
append
(
poison
!=
null
?
poison
.
hashCode
()
:
1
).
toHashCode
();
}
/**
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/DnDSheet.java
View file @
b3dc47f1
...
...
@@ -13,6 +13,8 @@ import com.google.gson.JsonObject;
import
com.koushikdutta.async.future.SimpleFuture
;
import
com.koushikdutta.ion.Ion
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
...
...
@@ -297,20 +299,16 @@ public class DnDSheet implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
(
hp
!=
null
?
hp
.
hashCode
()
:
1
)
*
(
thac9
!=
null
?
thac9
.
hashCode
()
:
1
)
*
(
ac
!=
null
?
ac
.
hashCode
()
:
1
)
*
(
appearance
!=
null
?
appearance
.
hashCode
()
:
1
)
*
caracterClass
.
hashCode
()
*
(
personality
!=
null
?
personality
.
hashCode
()
:
1
)
*
system
.
hashCode
()
*
languages
.
hashCode
()
*
equipment
.
hashCode
()
*
notes
.
hashCode
()
*
spells
.
hashCode
()
*
saves
.
hashCode
()
*
attr
.
hashCode
()
*
skills
.
hashCode
();
return
new
HashCodeBuilder
(
9
,
11
)
.
append
(
hp
!=
null
?
hp
.
hashCode
()
:
1
)
.
append
(
thac9
!=
null
?
thac9
.
hashCode
()
:
1
)
.
append
(
ac
!=
null
?
ac
.
hashCode
()
:
1
)
.
append
(
appearance
!=
null
?
appearance
.
hashCode
()
:
1
)
.
append
(
caracterClass
.
hashCode
())
.
append
(
personality
!=
null
?
personality
.
hashCode
()
:
1
)
.
append
(
system
.
hashCode
()).
append
(
languages
.
hashCode
()).
append
(
equipment
.
hashCode
())
.
append
(
notes
.
hashCode
()).
append
(
spells
.
hashCode
()).
append
(
saves
.
hashCode
())
.
append
(
attr
.
hashCode
()).
append
(
skills
.
hashCode
()).
toHashCode
();
}
/**
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/DnDSkill.java
View file @
b3dc47f1
...
...
@@ -3,6 +3,8 @@ package fr.iutnantes.miar.dndgenerator.api.dnd;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
/**
...
...
@@ -40,7 +42,8 @@ public class DnDSkill implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
skillName
.
hashCode
()
*
value
.
hashCode
();
return
new
HashCodeBuilder
(
13
,
15
)
.
append
(
skillName
.
hashCode
()).
append
(
value
.
hashCode
()).
toHashCode
();
}
/**
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/models/DnDSavesDB.java
View file @
b3dc47f1
...
...
@@ -65,7 +65,7 @@ public class DnDSavesDB extends BaseDB {
static
{
PRIMARY_KEY
=
Vars
.
_ID
;
TABLE_NAME
=
Vars
.
TABLE_NAME
;
DATABASE_VERSION
=
1
;
DATABASE_VERSION
=
DnDSheetDB
.
DATABASE_VERSION
;
DATABASE_NAME
=
TABLE_NAME
;
List
<
String
>
tempInt
=
new
ArrayList
<>();
tempInt
.
add
(
Vars
.
WANDS
);
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/dnd/models/DnDSheetDB.java
View file @
b3dc47f1
...
...
@@ -85,7 +85,7 @@ public class DnDSheetDB extends BaseDB {
static
{
PRIMARY_KEY
=
Vars
.
_ID
;
TABLE_NAME
=
Vars
.
TABLE_NAME
;
DATABASE_VERSION
=
3
;
DATABASE_VERSION
=
5
;
DATABASE_NAME
=
TABLE_NAME
;
List
<
String
>
tempInt
=
new
ArrayList
<>();
tempInt
.
add
(
Vars
.
HP
);
...
...
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/tenor/Dimension.java
View file @
b3dc47f1
...
...
@@ -2,6 +2,8 @@ package fr.iutnantes.miar.dndgenerator.api.tenor;
import
androidx.annotation.NonNull
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
import
java.util.List
;
...
...
@@ -64,6 +66,7 @@ public class Dimension implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
width
.
hashCode
()
*
height
.
hashCode
();
return
new
HashCodeBuilder
(
17
,
19
)
.
append
(
width
).
append
(
height
).
toHashCode
();
}
}
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/tenor/GIFArtifact.java
View file @
b3dc47f1
...
...
@@ -2,6 +2,8 @@ package fr.iutnantes.miar.dndgenerator.api.tenor;
import
androidx.annotation.NonNull
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
/**
...
...
@@ -58,4 +60,27 @@ public class GIFArtifact implements Serializable {
this
.
mediaFilter
=
mediaFilter
;
this
.
filterContent
=
filterContent
;
}
/**
* For compare Any Object with this artifact.
* @param obj : Object for comparison
* @return equals
*/
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
!=
null
&&
obj
.
getClass
()
==
this
.
getClass
())
return
this
.
hashCode
()
==
obj
.
hashCode
();
else
return
false
;
}
/**
* For identify artifact.
* @return hashCode
*/
@Override
public
int
hashCode
()
{
return
new
HashCodeBuilder
(
21
,
23
)
.
append
(
query
.
hashCode
()).
append
(
mediaFilter
.
hashCode
())
.
append
(
filterContent
.
hashCode
()).
toHashCode
();
}
}
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/tenor/MediaObject.java
View file @
b3dc47f1
...
...
@@ -3,6 +3,8 @@ package fr.iutnantes.miar.dndgenerator.api.tenor;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
org.apache.commons.lang3.builder.HashCodeBuilder
;
import
java.io.Serializable
;
import
java.util.List
;
...
...
@@ -105,6 +107,8 @@ public class MediaObject implements Serializable {
*/
@Override
public
int
hashCode
()
{
return
url
.
hashCode
()
*
preview
.
hashCode
()
*
dims
.
hashCode
();
return
new
HashCodeBuilder
(
25
,
27
)
.
append
(
url
.
hashCode
()).
append
(
preview
.
hashCode
()).
append
(
dims
.
hashCode
())
.
toHashCode
();
}
}
app/src/main/java/fr/iutnantes/miar/dndgenerator/api/tenor/models/GIFArtifactDB.java
View file @
b3dc47f1
...
...
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
fr.iutnantes.miar.dndgenerator.api.BaseDB
;
import
fr.iutnantes.miar.dndgenerator.api.dnd.models.DnDSheetDB
;
import
fr.iutnantes.miar.dndgenerator.api.tenor.FilterContent
;
import
fr.iutnantes.miar.dndgenerator.api.tenor.GIFArtifact
;
import
fr.iutnantes.miar.dndgenerator.api.tenor.MediaFilter
;
...
...
@@ -69,7 +70,7 @@ public class GIFArtifactDB extends BaseDB {
static
{
PRIMARY_KEY
=
Vars
.
_ID
;
TABLE_NAME
=
Vars
.
TABLE_NAME
;
DATABASE_VERSION
=
1
;
DATABASE_VERSION
=
DnDSheetDB
.
DATABASE_VERSION
;
DATABASE_NAME
=
TABLE_NAME
;
List
<
String
>
tempInt
=
new
ArrayList
<>();
tempInt
.
add
(
Vars
.
MEDIA_FILTER_ID
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment