blob: 7985ba28255b14c2d4bb1eabc0dd18eff0b85ea1 [file] [log] [blame]
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.twitter;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.twitter.reference.TwitterConstants.PROPERTY_TWITTER_ENDPOINT;
import static org.jclouds.twitter.reference.TwitterConstants.PROPERTY_TWITTER_PASSWORD;
import static org.jclouds.twitter.reference.TwitterConstants.PROPERTY_TWITTER_USER;
import java.net.URI;
import java.util.Properties;
import org.jclouds.PropertiesBuilder;
/**
* Builds properties used in Twitter Clients
*
* @author Adrian Cole
*/
public class TwitterPropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_TWITTER_ENDPOINT, "http://twitter.com");
return properties;
}
public TwitterPropertiesBuilder(Properties properties) {
super(properties);
}
public TwitterPropertiesBuilder(String id, String secret) {
super();
withCredentials(id, secret);
}
public TwitterPropertiesBuilder withCredentials(String id, String secret) {
properties.setProperty(PROPERTY_TWITTER_USER, checkNotNull(id, "user"));
properties.setProperty(PROPERTY_TWITTER_PASSWORD, checkNotNull(secret, "password"));
return this;
}
public TwitterPropertiesBuilder withEndpoint(URI endpoint) {
properties.setProperty(PROPERTY_TWITTER_ENDPOINT, checkNotNull(endpoint, "endpoint")
.toString());
return this;
}
}