Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

OpenWiseSolutions / openhub-framework / 1198

4 Feb 2021 - 14:46 coverage decreased (-0.5%) to 70.196%
1198

Pull #129

travis-ci

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
Merge b150e80af into 382999a38
Pull Request #129: [OHFJIRA-85]: Upgrade to Spring Boot 2.0.9.RELEASE

23 of 66 new or added lines in 12 files covered. (34.85%)

28 existing lines in 4 files now uncovered.

4329 of 6167 relevant lines covered (70.2%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.15
/web/src/main/java/org/openhubframework/openhub/admin/web/common/rpc/BaseRpc.java
1
/*
2
 * Copyright 2002-2016 the original author or authors.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package org.openhubframework.openhub.admin.web.common.rpc;
18

19
import java.io.Serializable;
20
import javax.annotation.Nullable;
21

22
import org.apache.commons.lang3.builder.EqualsBuilder;
23
import org.apache.commons.lang3.builder.HashCodeBuilder;
24
import org.apache.commons.lang3.builder.ToStringBuilder;
25
import org.apache.commons.lang3.builder.ToStringStyle;
26
import org.springframework.util.Assert;
27

28
import org.openhubframework.openhub.api.entity.Identifiable;
29

30

31
/**
32
 * Reference-able read-only RPC entity.
33
 * Override {@link #init()} method for custom initialization needs.
34
 * <p>
35
 * If you need to create/update RPC then use {@link ChangeableRpc}.
36
 *
37
 * @author <a href="mailto:petr.juza@openwise.cz">Petr Juza</a>
38
 * @since 2.0
39
 * @see ChangeableRpc
40
 */
41
public abstract class BaseRpc<T extends Identifiable<ID>, ID extends Serializable> implements Identifiable<ID> {
42

43
    private ID id;
44

45
    /**
46
     * Empty constructor for deserialization from XML/JSON.
47
     */
48
    protected BaseRpc() {
1×
49
        init();
1×
50
    }
1×
51

52
    /**
53
     * Creates RPC from specified entity.
54
     *
55
     * @param entity The entity
56
     */
57
    protected BaseRpc(T entity) {
1×
58
        Assert.notNull(entity, "entity can not be null");
1×
59

60
        init();
1×
61

62
        this.id = entity.getId();
1×
63
    }
1×
64

65
    @Nullable
66
    @Override
67
    public ID getId() {
68
        return id;
1×
69
    }
70

71
    @Override
72
    public void setId(@Nullable final ID id) {
73
        this.id = id;
1×
74
    }
1×
75

76
    /**
77
     * Inits RPC => override it for specified needs.
78
     */
79
    protected void init() {
80
        // nothing to implement by default
81
    }
1×
82

83
    /**
84
     * Two entities are equal if their key values are equal.
85
     */
86
    @Override
87
    public boolean equals(@Nullable Object obj) {
88
        if (obj == this) {
!
89
            return true;
!
90
        } else if (obj instanceof BaseRpc) {
!
91
            BaseRpc en = (BaseRpc) obj;
!
92

93
            return new EqualsBuilder()
!
94
                    .append(id, en.id)
!
95
                    .isEquals();
!
96
        } else {
97
            return false;
!
98
        }
99
    }
100

101
    @Override
102
    public int hashCode() {
UNCOV
103
        return new HashCodeBuilder()
!
UNCOV
104
                .append(id)
!
UNCOV
105
                .toHashCode();
!
106
    }
107

108
    @Override
109
    public String toString() {
110
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
!
111
                .append("id", id)
!
112
                .toString();
!
113
    }
114
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2021 Coveralls, Inc