Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tasty Pages
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SE2 Projekt
Tasty Pages
Commits
b12efe70
Commit
b12efe70
authored
1 year ago
by
Karsch Lukas
Browse files
Options
Downloads
Patches
Plain Diff
equals method for recipes and more
parent
d5ba8f5c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/mi/hdm/recipes/Recipe.java
+22
-9
22 additions, 9 deletions
src/main/java/mi/hdm/recipes/Recipe.java
with
22 additions
and
9 deletions
src/main/java/mi/hdm/recipes/Recipe.java
+
22
−
9
View file @
b12efe70
...
...
@@ -13,7 +13,7 @@ public class Recipe implements RecipeComponent {
private
String
description
;
private
List
<
String
>
preparation
;
private
List
<
Category
>
categories
;
private
I
nt
eger
preparationTimeMins
;
private
i
nt
preparationTimeMins
;
private
NutritionTable
nutritionTable
;
private
final
LocalDateTime
creationTime
;
...
...
@@ -33,7 +33,7 @@ public class Recipe implements RecipeComponent {
String
description
,
List
<
String
>
preparation
,
List
<
Category
>
categories
,
I
nt
eger
preparationTimeMins
)
{
i
nt
preparationTimeMins
)
{
//Das ruft den anderen Konstruktor dieser Klasse auf (siehe unten)
this
(
name
,
ingredients
,
description
,
preparation
,
categories
,
preparationTimeMins
,
NutritionCalculator
.
calculateNutritionTable
(
ingredients
));
...
...
@@ -56,7 +56,7 @@ public class Recipe implements RecipeComponent {
String
description
,
List
<
String
>
preparation
,
List
<
Category
>
categories
,
I
nt
eger
preparationTimeMins
,
i
nt
preparationTimeMins
,
NutritionTable
nutritionTable
)
{
if
(
ingredients
==
null
||
ingredients
.
size
()
==
0
)
{
...
...
@@ -68,17 +68,14 @@ public class Recipe implements RecipeComponent {
if
(
preparation
==
null
||
preparation
.
isEmpty
())
{
throw
new
InvalidRecipeException
(
"Preparation can not be null or empty"
);
}
if
(
categories
==
null
)
{
categories
=
new
ArrayList
<>();
}
this
.
ingredients
=
ingredients
;
this
.
name
=
name
;
this
.
description
=
description
;
this
.
preparation
=
preparation
;
this
.
categories
=
categories
;
this
.
preparationTimeMins
=
preparationTimeMins
;
this
.
nutritionTable
=
nutritionTable
;
setPreparationTimeMins
(
preparationTimeMins
);
setCategories
(
categories
);
this
.
creationTime
=
LocalDateTime
.
now
();
}
...
...
@@ -115,6 +112,10 @@ public class Recipe implements RecipeComponent {
}
public
void
setCategories
(
List
<
Category
>
categories
)
{
if
(
categories
==
null
)
{
categories
=
new
ArrayList
<>();
}
this
.
categories
=
categories
;
}
...
...
@@ -122,7 +123,7 @@ public class Recipe implements RecipeComponent {
categories
.
add
(
category
);
}
public
I
nt
eger
getPreparationTimeMins
()
{
public
i
nt
getPreparationTimeMins
()
{
return
preparationTimeMins
;
}
...
...
@@ -147,4 +148,16 @@ public class Recipe implements RecipeComponent {
public
NutritionTable
getNutritionTable
()
{
return
nutritionTable
;
}
public
Map
<
RecipeComponent
,
Integer
>
getIngredients
()
{
return
ingredients
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
o
instanceof
Recipe
r
)
{
return
r
.
getName
().
equals
(
this
.
name
);
}
return
false
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment