ResourcesMetadata.java
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.yohoufo.resource.model;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.beanutils.BeanUtils;
import com.google.common.base.Throwables;
import com.yohoufo.dal.resource.model.Resources;
import com.yohoufo.dal.resource.model.ResourcesContentData;
import lombok.Data;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
@Data
@Builder
@Slf4j
public class ResourcesMetadata implements Serializable {
private String contentCode;
private Resources resources;
private List<ResourcesContentData> resourcesContentDatas;
//首页资源位焦点图个性化推荐数量
private int topBannerNum;
public ResourcesMetadata cloneBean() {
try {
ResourcesMetadataBuilder builder = ResourcesMetadata.builder().contentCode(contentCode);
builder.resources(cloneBean(resources));
builder.resourcesContentDatas(getResourcesContentDatas().stream().map(e -> cloneBean(e)).collect(Collectors.toList()));
builder.topBannerNum(topBannerNum);
return builder.build();
} catch (Exception e) {
log.error("clone {} exception.", ResourcesMetadata.class.getName(), e);
throw new RuntimeException("clone ResourcesMetadata exception:", e);
}
}
private <T> T cloneBean(T e) {
try {
return (T) BeanUtils.cloneBean(e);
} catch (Exception e1) {
throw Throwables.propagate(e1);
}
}
}