This project has retired. For details please refer to its
Attic page.
AbstractRepository xref
1 package org.apache.archiva.admin.model.beans;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.Serializable;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.Locale;
25 import java.util.Map;
26 import java.util.stream.Collectors;
27
28
29
30
31
32 public class AbstractRepository
33 implements Serializable
34 {
35
36 private Locale defaultLocale = Locale.getDefault();
37
38 private String type;
39
40 private String id;
41
42
43
44
45 private Map<Locale, String> name = new HashMap<>( );
46
47
48
49
50 private Map<Locale, String> description = new HashMap<>( );
51
52 private String layout = "default";
53
54 private String indexDirectory;
55
56
57
58
59 private String packedIndexDirectory;
60
61 private String toStringCache = null;
62
63
64 public AbstractRepository()
65 {
66
67 }
68
69 public AbstractRepository(Locale defaultLocale) {
70 this.defaultLocale = defaultLocale;
71 }
72
73 public AbstractRepository( Locale defaultLocale, String id, String name, String layout )
74 {
75 this.defaultLocale = defaultLocale;
76 setId(id);
77 setName(name);
78 setLayout(layout);
79 }
80
81 public AbstractRepository( String id, String name, String layout )
82 {
83 setId(id);
84 setName(name);
85 setLayout(layout);
86 }
87
88 public String getId()
89 {
90 return id;
91 }
92
93 public void setId( String id )
94 {
95 this.toStringCache=null;
96 this.id = id;
97 }
98
99 public String getName()
100 {
101 return name.get(defaultLocale);
102 }
103
104 public Map<String,String> getNames() {
105 if (this.name==null) {
106 return Collections.emptyMap();
107 }
108 return this.name.entrySet().stream().collect( Collectors.toMap( e -> e.getKey().toLanguageTag(), Map.Entry::getValue ) );
109 }
110
111 public void setName( String name )
112 {
113 this.toStringCache=null;
114 this.name.put(defaultLocale, name);
115 }
116
117 public void setName( String languageTag, String name ) {
118 this.toStringCache=null;
119 final Locale loc = Locale.forLanguageTag( languageTag );
120 this.name.put(loc, name);
121 }
122
123 public String getLayout()
124 {
125 return layout;
126 }
127
128 public void setLayout( String layout )
129 {
130 this.toStringCache=null;
131 this.layout = layout;
132 }
133
134
135
136 public String getIndexDirectory()
137 {
138 return indexDirectory;
139 }
140
141 public void setIndexDirectory( String indexDirectory )
142 {
143 this.toStringCache=null;
144 this.indexDirectory = indexDirectory;
145 }
146
147 public String getDescription()
148 {
149 return this.description.get(defaultLocale);
150 }
151
152 public Map<String,String> getDescriptions() {
153 if (this.description==null) {
154 return Collections.emptyMap();
155 }
156 return this.description.entrySet().stream().filter( e -> e!=null && e.getKey()!=null )
157 .collect( Collectors.toMap( e -> e.getKey().toLanguageTag(), e -> e.getValue()==null ? "" : e.getValue() ) );
158 }
159
160
161 public void setDescription( String description )
162 {
163 this.toStringCache=null;
164 this.description.put(defaultLocale, description);
165 }
166
167 public void setDescription( String languageTag, String description) {
168 this.toStringCache = null;
169 final Locale loc = Locale.forLanguageTag( languageTag );
170 this.description.put(loc, description);
171 }
172
173 @Override
174 public int hashCode()
175 {
176 int result = 17;
177 result = 37 * result + ( id != null ? id.hashCode() : 0 );
178 return result;
179 }
180
181 @Override
182 public boolean equals( Object other )
183 {
184 if ( this == other )
185 {
186 return true;
187 }
188
189 if ( !( other instanceof AbstractRepository ) )
190 {
191 return false;
192 }
193
194 AbstractRepository./../../org/apache/archiva/admin/model/beans/AbstractRepository.html#AbstractRepository">AbstractRepository that = (AbstractRepository) other;
195 boolean result = true;
196 result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
197 return result;
198 }
199
200 private String getLocaleString(Map<Locale, String> map) {
201 return map.entrySet().stream().map(entry -> entry.getKey().toLanguageTag()+'='+entry.getValue()).collect( Collectors.joining( ",") );
202 }
203
204 public String getType( )
205 {
206 return type;
207 }
208
209 public void setType(String type) {
210 toStringCache=null;
211 this.type = type;
212 }
213
214 public String getPackedIndexDirectory() {
215 return packedIndexDirectory;
216 }
217
218 public void setPackedIndexDirectory(String packedIndexDirectory) {
219 toStringCache=null;
220 this.packedIndexDirectory = packedIndexDirectory;
221 }
222
223 @Override
224 public String toString()
225 {
226 if (toStringCache!=null) {
227 return toStringCache;
228 } else
229 {
230 final StringBuilder sb = new StringBuilder( );
231 sb.append( "AbstractRepository" );
232 sb.append( "{ id=\"" ).append( id ).append( '"' );
233 sb.append( ", type=\"").append(type).append('"');
234 sb.append( ", name=\"" ).append( getLocaleString( name ) ).append( '"' );
235 sb.append( ", layout=\"" ).append( layout ).append( '"' );
236 sb.append( ", indexDirectory=\"" ).append( indexDirectory ).append( '"' );
237 sb.append( ", packedIndexDirectory=\"").append(packedIndexDirectory).append('"');
238 sb.append( ", description=\"" ).append( getLocaleString( description ) ).append( '"' );
239 sb.append( '}' );
240 toStringCache=sb.toString( );
241 return toStringCache;
242 }
243 }
244
245
246 }