|
| 1 | +/* |
| 2 | + * Copyright 2015 Google Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.google.gcloud.bigquery; |
| 18 | + |
| 19 | +import com.google.common.collect.ImmutableSet; |
| 20 | +import com.google.gcloud.ServiceOptions; |
| 21 | +import com.google.gcloud.spi.DefaultBigqueryRpc; |
| 22 | +import com.google.gcloud.spi.BigqueryRpc; |
| 23 | +import com.google.gcloud.spi.BigqueryRpcFactory; |
| 24 | + |
| 25 | +import java.util.Set; |
| 26 | + |
| 27 | +public class BigqueryOptions extends ServiceOptions<Bigquery, BigqueryRpc, BigqueryOptions> { |
| 28 | + |
| 29 | + private static final String BIGQUERY_SCOPE = "https://www.googleapis.com/auth/bigquery"; |
| 30 | + private static final Set<String> SCOPES = ImmutableSet.of(BIGQUERY_SCOPE); |
| 31 | + private static final long serialVersionUID = -215981591481708043L; |
| 32 | + |
| 33 | + public static class DefaultBigqueryFactory implements BigqueryFactory { |
| 34 | + |
| 35 | + private static final BigqueryFactory INSTANCE = new DefaultBigqueryFactory(); |
| 36 | + |
| 37 | + @Override |
| 38 | + public Bigquery create(BigqueryOptions options) { |
| 39 | + // TODO(mziccard) return new BigqueryImpl(options); |
| 40 | + return null; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + public static class DefaultBigqueryRpcFactory implements BigqueryRpcFactory { |
| 45 | + |
| 46 | + private static final BigqueryRpcFactory INSTANCE = new DefaultBigqueryRpcFactory(); |
| 47 | + |
| 48 | + @Override |
| 49 | + public BigqueryRpc create(BigqueryOptions options) { |
| 50 | + // TODO(mziccard) return new DefaultBigqueryRpc(options); |
| 51 | + return null; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + public static class Builder extends |
| 56 | + ServiceOptions.Builder<Bigquery, BigqueryRpc, BigqueryOptions, Builder> { |
| 57 | + |
| 58 | + private Builder() { |
| 59 | + } |
| 60 | + |
| 61 | + private Builder(BigqueryOptions options) { |
| 62 | + super(options); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public BigqueryOptions build() { |
| 67 | + return new BigqueryOptions(this); |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + private BigqueryOptions(Builder builder) { |
| 72 | + super(BigqueryFactory.class, BigqueryRpcFactory.class, builder); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + protected BigqueryFactory defaultServiceFactory() { |
| 77 | + return DefaultBigqueryFactory.INSTANCE; |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + protected BigqueryRpcFactory defaultRpcFactory() { |
| 82 | + return DefaultBigqueryRpcFactory.INSTANCE; |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + protected Set<String> scopes() { |
| 87 | + return SCOPES; |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public Builder toBuilder() { |
| 92 | + return new Builder(this); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public int hashCode() { |
| 97 | + return baseHashCode(); |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public boolean equals(Object obj) { |
| 102 | + if (!(obj instanceof BigqueryOptions)) { |
| 103 | + return false; |
| 104 | + } |
| 105 | + BigqueryOptions other = (BigqueryOptions) obj; |
| 106 | + return baseEquals(other); |
| 107 | + } |
| 108 | + |
| 109 | + public static Builder builder() { |
| 110 | + return new Builder(); |
| 111 | + } |
| 112 | +} |
0 commit comments