View Javadoc
1   package de.softwareforge.testing.postgres.embedded;
2   
3   import com.google.common.collect.ImmutableMap;
4   import edu.umd.cs.findbugs.annotations.NonNull;
5   import java.sql.SQLException;
6   import java.util.Optional;
7   import javax.annotation.processing.Generated;
8   
9   @Generated("com.google.auto.value.processor.AutoValueProcessor")
10  final class AutoValue_DatabaseInfo extends DatabaseInfo {
11  
12    private final String dbName;
13  
14    private final int port;
15  
16    private final String user;
17  
18    private final ImmutableMap<String, String> connectionProperties;
19  
20    private final Optional<SQLException> exception;
21  
22    private AutoValue_DatabaseInfo(
23        String dbName,
24        int port,
25        String user,
26        ImmutableMap<String, String> connectionProperties,
27        Optional<SQLException> exception) {
28      this.dbName = dbName;
29      this.port = port;
30      this.user = user;
31      this.connectionProperties = connectionProperties;
32      this.exception = exception;
33    }
34  
35    @NonNull
36    @Override
37    public String dbName() {
38      return dbName;
39    }
40  
41    @Override
42    public int port() {
43      return port;
44    }
45  
46    @NonNull
47    @Override
48    public String user() {
49      return user;
50    }
51  
52    @NonNull
53    @Override
54    public ImmutableMap<String, String> connectionProperties() {
55      return connectionProperties;
56    }
57  
58    @NonNull
59    @Override
60    Optional<SQLException> exception() {
61      return exception;
62    }
63  
64    @Override
65    public String toString() {
66      return "DatabaseInfo{"
67          + "dbName=" + dbName + ", "
68          + "port=" + port + ", "
69          + "user=" + user + ", "
70          + "connectionProperties=" + connectionProperties + ", "
71          + "exception=" + exception
72          + "}";
73    }
74  
75    @Override
76    public boolean equals(Object o) {
77      if (o == this) {
78        return true;
79      }
80      if (o instanceof DatabaseInfo) {
81        DatabaseInfo./../../../de/softwareforge/testing/postgres/embedded/DatabaseInfo.html#DatabaseInfo">DatabaseInfo that = (DatabaseInfo) o;
82        return this.dbName.equals(that.dbName())
83            && this.port == that.port()
84            && this.user.equals(that.user())
85            && this.connectionProperties.equals(that.connectionProperties())
86            && this.exception.equals(that.exception());
87      }
88      return false;
89    }
90  
91    @Override
92    public int hashCode() {
93      int h$ = 1;
94      h$ *= 1000003;
95      h$ ^= dbName.hashCode();
96      h$ *= 1000003;
97      h$ ^= port;
98      h$ *= 1000003;
99      h$ ^= user.hashCode();
100     h$ *= 1000003;
101     h$ ^= connectionProperties.hashCode();
102     h$ *= 1000003;
103     h$ ^= exception.hashCode();
104     return h$;
105   }
106 
107   static final class Builder extends DatabaseInfo.Builder {
108     private String dbName;
109     private Integer port;
110     private String user;
111     private ImmutableMap.Builder<String, String> connectionPropertiesBuilder$;
112     private ImmutableMap<String, String> connectionProperties;
113     private Optional<SQLException> exception = Optional.empty();
114     Builder() {
115     }
116     @Override
117     DatabaseInfo.Builder dbName(String dbName) {
118       if (dbName == null) {
119         throw new NullPointerException("Null dbName");
120       }
121       this.dbName = dbName;
122       return this;
123     }
124     @Override
125     DatabaseInfo.Builder port(int port) {
126       this.port = port;
127       return this;
128     }
129     @Override
130     DatabaseInfo.Builder user(String user) {
131       if (user == null) {
132         throw new NullPointerException("Null user");
133       }
134       this.user = user;
135       return this;
136     }
137     @Override
138     DatabaseInfo.Builder connectionProperties(ImmutableMap<String, String> connectionProperties) {
139       if (connectionProperties == null) {
140         throw new NullPointerException("Null connectionProperties");
141       }
142       if (connectionPropertiesBuilder$ != null) {
143         throw new IllegalStateException("Cannot set connectionProperties after calling connectionPropertiesBuilder()");
144       }
145       this.connectionProperties = connectionProperties;
146       return this;
147     }
148     @Override
149     ImmutableMap.Builder<String, String> connectionPropertiesBuilder() {
150       if (connectionPropertiesBuilder$ == null) {
151         if (connectionProperties == null) {
152           connectionPropertiesBuilder$ = ImmutableMap.builder();
153         } else {
154           connectionPropertiesBuilder$ = ImmutableMap.builder();
155           connectionPropertiesBuilder$.putAll(connectionProperties);
156           connectionProperties = null;
157         }
158       }
159       return connectionPropertiesBuilder$;
160     }
161     @Override
162     DatabaseInfo.Builder exception(SQLException exception) {
163       this.exception = Optional.of(exception);
164       return this;
165     }
166     @Override
167     DatabaseInfo build() {
168       if (connectionPropertiesBuilder$ != null) {
169         this.connectionProperties = connectionPropertiesBuilder$.build();
170       } else if (this.connectionProperties == null) {
171         this.connectionProperties = ImmutableMap.of();
172       }
173       if (this.dbName == null
174           || this.port == null
175           || this.user == null) {
176         StringBuilder missing = new StringBuilder();
177         if (this.dbName == null) {
178           missing.append(" dbName");
179         }
180         if (this.port == null) {
181           missing.append(" port");
182         }
183         if (this.user == null) {
184           missing.append(" user");
185         }
186         throw new IllegalStateException("Missing required properties:" + missing);
187       }
188       return new AutoValue_DatabaseInfo(
189           this.dbName,
190           this.port,
191           this.user,
192           this.connectionProperties,
193           this.exception);
194     }
195   }
196 
197 }