1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.osgi.service.importer;
18
19 import org.osgi.framework.Filter;
20 import org.springframework.util.ObjectUtils;
21
22
23
24
25
26
27
28 public class DefaultOsgiServiceDependency implements OsgiServiceDependency {
29
30 private final String beanName;
31 private final Filter filter;
32 private final boolean mandatoryService;
33 private final String toString;
34 private final int hashCode;
35
36
37
38
39
40
41
42
43
44
45 public DefaultOsgiServiceDependency(String beanName, Filter filter, boolean mandatoryService) {
46 this.beanName = beanName;
47 this.filter = filter;
48 this.mandatoryService = mandatoryService;
49
50
51 toString = "DependencyService[Name=" + (beanName != null ? beanName : "null") + "][Filter=" + filter
52 + "][Mandatory=" + mandatoryService + "]";
53
54 int result = 17;
55 result = 37 * result + DefaultOsgiServiceDependency.class.hashCode();
56 result = 37 * result + (filter == null ? 0 : filter.hashCode());
57 result = 37 * result + (beanName == null ? 0 : beanName.hashCode());
58 result = 37 * result + (mandatoryService ? 0 : 1);
59 hashCode = result;
60 }
61
62 public String getBeanName() {
63 return beanName;
64 }
65
66 public Filter getServiceFilter() {
67 return filter;
68 }
69
70 public boolean isMandatory() {
71 return mandatoryService;
72 }
73
74 public String toString() {
75 return toString;
76 }
77
78 public boolean equals(Object obj) {
79 if (obj instanceof OsgiServiceDependency) {
80 OsgiServiceDependency other = (OsgiServiceDependency) obj;
81 return (other.isMandatory() == mandatoryService && filter.equals(other.getServiceFilter()) && ObjectUtils.nullSafeEquals(
82 beanName, other.getBeanName()));
83 }
84 return false;
85 }
86
87 public int hashCode() {
88 return hashCode;
89 }
90 }