View Javadoc
1   package org.kuali.common.devops.metadata.model;
2   
3   import org.kuali.common.core.build.ValidatingBuilder;
4   import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
5   
6   import com.google.common.base.Function;
7   import com.google.common.base.Optional;
8   
9   @IdiotProofImmutable
10  public final class MetadataUrl<T> {
11  
12  	private final String url;
13  	private final Optional<String> content;
14  	private final Function<String, T> converter;
15  	private final Optional<T> metadata;
16  
17  	private MetadataUrl(Builder<T> builder) {
18  		this.url = builder.url;
19  		this.content = builder.content;
20  		this.converter = builder.converter;
21  		this.metadata = builder.metadata;
22  	}
23  
24  	public static <T> Builder<T> builder() {
25  		return new Builder<T>();
26  	}
27  
28  	public static class Builder<T> extends ValidatingBuilder<MetadataUrl<T>> {
29  
30  		private String url;
31  		private Optional<String> content;
32  		private Function<String, T> converter;
33  		private Optional<T> metadata;
34  
35  		public Builder<T> metadata(Optional<T> metadata) {
36  			this.metadata = metadata;
37  			return this;
38  		}
39  
40  		public Builder<T> url(String url) {
41  			this.url = url;
42  			return this;
43  		}
44  
45  		public Builder<T> content(Optional<String> content) {
46  			this.content = content;
47  			return this;
48  		}
49  
50  		public Builder<T> converter(Function<String, T> converter) {
51  			this.converter = converter;
52  			return this;
53  		}
54  
55  		@Override
56  		public MetadataUrl<T> build() {
57  			return validate(new MetadataUrl<T>(this));
58  		}
59  
60  	}
61  
62  	public String getUrl() {
63  		return url;
64  	}
65  
66  	public Optional<String> getContent() {
67  		return content;
68  	}
69  
70  	public Function<String, T> getConverter() {
71  		return converter;
72  	}
73  
74  	public Optional<T> getMetadata() {
75  		return metadata;
76  	}
77  
78  }