Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daaexample
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Iago Gómez Salgado
daaexample
Commits
516d49aa
Commit
516d49aa
authored
Mar 10, 2017
by
Iago Gómez Salgado
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PetDataset
parent
4a5b03c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
PetsDataset.java
src/test/java/es/uvigo/esei/daa/dataset/PetsDataset.java
+75
-0
No files found.
src/test/java/es/uvigo/esei/daa/dataset/PetsDataset.java
0 → 100644
View file @
516d49aa
package
es
.
uvigo
.
esei
.
daa
.
dataset
;
import
static
java
.
util
.
Arrays
.
binarySearch
;
import
static
java
.
util
.
Arrays
.
stream
;
import
java.util.Arrays
;
import
java.util.function.Predicate
;
import
es.uvigo.esei.daa.entities.Pet
;
public
final
class
PetsDataset
{
private
PetsDataset
()
{}
public
static
Pet
[]
pets
()
{
return
new
Pet
[]
{
new
Pet
(
1
,
"Ron"
,
"Can"
,
"Moito"
,
1
),
new
Pet
(
2
,
"Paul"
,
"Gato"
,
"Alerxico"
,
2
),
new
Pet
(
3
,
"Punky"
,
"Gato"
,
"Alerxico"
,
2
)
};
}
public
static
Pet
[]
peopleWithout
(
int
...
ids
)
{
Arrays
.
sort
(
ids
);
final
Predicate
<
Pet
>
hasValidId
=
pet
->
binarySearch
(
ids
,
pet
.
getId
())
<
0
;
return
stream
(
pets
())
.
filter
(
hasValidId
)
.
toArray
(
Pet
[]::
new
);
}
public
static
Pet
pet
(
int
id
)
{
return
stream
(
pets
())
.
filter
(
pet
->
pet
.
getId
()
==
id
)
.
findAny
()
.
orElseThrow
(
IllegalArgumentException:
:
new
);
}
public
static
int
existentId
()
{
return
1
;
}
public
static
int
nonExistentId
()
{
return
1234
;
}
public
static
Pet
existentPet
()
{
return
pet
(
existentId
());
}
public
static
Pet
nonExistentPet
()
{
return
new
Pet
(
nonExistentId
(),
"Cospe"
,
"Gaivota"
,
"Pepera"
,
1
);
}
public
static
String
newName
()
{
return
"Tor"
;
}
public
static
String
newKind
()
{
return
"Pe"
;
}
public
static
String
newBreed
()
{
return
"QueFlipas"
;
}
public
static
int
newOwner
()
{
return
2
;
}
public
static
Pet
newPet
()
{
return
new
Pet
(
pets
().
length
+
1
,
newName
(),
newKind
(),
newBreed
(),
newOwner
());
}
}
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