001package org.kuali.common.devops.metadata.model;
002
003import org.kuali.common.core.build.ValidatingBuilder;
004import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
005
006import com.google.common.base.Function;
007import com.google.common.base.Optional;
008
009@IdiotProofImmutable
010public final class MetadataUrl<T> {
011
012        private final String url;
013        private final Optional<String> content;
014        private final Function<String, T> converter;
015        private final Optional<T> metadata;
016
017        private MetadataUrl(Builder<T> builder) {
018                this.url = builder.url;
019                this.content = builder.content;
020                this.converter = builder.converter;
021                this.metadata = builder.metadata;
022        }
023
024        public static <T> Builder<T> builder() {
025                return new Builder<T>();
026        }
027
028        public static class Builder<T> extends ValidatingBuilder<MetadataUrl<T>> {
029
030                private String url;
031                private Optional<String> content;
032                private Function<String, T> converter;
033                private Optional<T> metadata;
034
035                public Builder<T> metadata(Optional<T> metadata) {
036                        this.metadata = metadata;
037                        return this;
038                }
039
040                public Builder<T> url(String url) {
041                        this.url = url;
042                        return this;
043                }
044
045                public Builder<T> content(Optional<String> content) {
046                        this.content = content;
047                        return this;
048                }
049
050                public Builder<T> converter(Function<String, T> converter) {
051                        this.converter = converter;
052                        return this;
053                }
054
055                @Override
056                public MetadataUrl<T> build() {
057                        return validate(new MetadataUrl<T>(this));
058                }
059
060        }
061
062        public String getUrl() {
063                return url;
064        }
065
066        public Optional<String> getContent() {
067                return content;
068        }
069
070        public Function<String, T> getConverter() {
071                return converter;
072        }
073
074        public Optional<T> getMetadata() {
075                return metadata;
076        }
077
078}