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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Óscar Servia González
DAAExample
Commits
71181c54
Commit
71181c54
authored
Mar 15, 2018
by
Óscar Servia González
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PetDataset class
parent
b372ec82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
PetDataset.java
src/test/java/es/uvigo/esei/daa/dataset/PetDataset.java
+72
-0
No files found.
src/test/java/es/uvigo/esei/daa/dataset/PetDataset.java
0 → 100644
View file @
71181c54
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
PetDataset
{
private
PetDataset
()
{}
public
static
Pet
[]
pets
()
{
return
new
Pet
[]
{
new
Pet
(
1
,
"Jimminy"
,
1
),
new
Pet
(
2
,
"Cisco"
,
2
),
new
Pet
(
3
,
"Phoenix"
,
3
),
new
Pet
(
4
,
"Rocky"
,
3
),
new
Pet
(
5
,
"Tallulah"
,
4
)
};
}
public
static
Pet
[]
petWithout
(
int
...
ids
)
{
Arrays
.
sort
(
ids
);
final
Predicate
<
Pet
>
hasValidId
=
Pet
->
binarySearch
(
ids
,
Pet
.
getIdPet
())
<
0
;
return
stream
(
pets
())
.
filter
(
hasValidId
)
.
toArray
(
Pet
[]::
new
);
}
public
static
Pet
Pet
(
int
id
)
{
return
stream
(
pets
())
.
filter
(
Pet
->
Pet
.
getIdPet
()
==
id
)
.
findAny
()
.
orElseThrow
(
IllegalArgumentException:
:
new
);
}
public
static
int
existentId
()
{
return
5
;
}
public
static
int
nonExistentId
()
{
return
1234
;
}
public
static
Pet
existentPet
()
{
return
Pet
(
existentId
());
}
public
static
Pet
nonExistentPet
()
{
return
new
Pet
(
nonExistentId
(),
"Jane"
,
4
);
}
public
static
String
newName
()
{
return
"John"
;
}
public
static
int
newIdMaster
()
{
return
12
;
}
public
static
Pet
newPet
()
{
return
new
Pet
(
pets
().
length
+
1
,
newName
(),
newIdMaster
());
}
}
\ No newline at end of file
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