Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jh-boot
Project
Overview
Details
Activity
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
Jan Hrabal
jh-boot
Commits
c2bde5c5
Commit
c2bde5c5
authored
Oct 20, 2019
by
Jan Hrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maj
parent
ff400445
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
+58
-4
Converter.java
src/main/java/com/jh/boot/web/Converter.java
+21
-4
IdNameDto.java
src/main/java/com/jh/boot/web/IdNameDto.java
+37
-0
No files found.
src/main/java/com/jh/boot/web/Converter.java
View file @
c2bde5c5
package
com
.
jh
.
boot
.
web
;
package
com
.
jh
.
boot
.
web
;
import
com.jh.boot.jpa.AbstractIdEntity
;
import
com.jh.boot.web.list.Page
;
import
com.jh.boot.web.list.SortTrend
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.jh.boot.jpa.AbstractIdEntity
;
import
com.jh.boot.web.list.Page
;
import
com.jh.boot.web.list.SortTrend
;
public
class
Converter
{
public
class
Converter
{
private
Converter
()
{}
private
Converter
()
{}
...
@@ -43,6 +45,21 @@ public class Converter {
...
@@ -43,6 +45,21 @@ public class Converter {
return
new
Page
<
D
>(
page
.
getPage
(),
page
.
getPagesCount
(),
page
.
getPageSize
(),
page
.
getTotalElements
(),
content
,
page
.
getSortBy
(),
SortTrend
.
parse
(
page
.
getTrend
()));
return
new
Page
<
D
>(
page
.
getPage
(),
page
.
getPagesCount
(),
page
.
getPageSize
(),
page
.
getTotalElements
(),
content
,
page
.
getSortBy
(),
SortTrend
.
parse
(
page
.
getTrend
()));
}
}
public
static
<
T
>
List
<
IdNameDto
>
mapToDtos
(
Collection
<
T
>
collection
,
Function
<
T
,
Long
>
getId
,
Function
<
T
,
String
>
getName
)
{
if
(
collection
==
null
||
collection
.
isEmpty
()
||
getId
==
null
||
getName
==
null
)
{
return
Collections
.
emptyList
();
}
List
<
IdNameDto
>
result
=
new
ArrayList
<
IdNameDto
>();
for
(
T
t
:
collection
)
{
result
.
add
(
new
IdNameDto
(
getId
.
apply
(
t
),
getName
.
apply
(
t
)));
}
return
result
;
}
//public static <T> T toEntity(IdNameDto )
/**
/**
* Helper function to safely get id
* Helper function to safely get id
*
*
...
...
src/main/java/com/jh/boot/web/IdNameDto.java
0 → 100644
View file @
c2bde5c5
package
com
.
jh
.
boot
.
web
;
public
class
IdNameDto
{
private
Long
id
;
private
String
name
;
public
IdNameDto
()
{
}
public
IdNameDto
(
Long
id
,
String
name
)
{
super
();
this
.
id
=
id
;
this
.
name
=
name
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
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